Difference between revisions of "Buildiso with AUR packages: Using buildpkg"

Marked this version for translation
m (added languages and translate tags)
(Marked this version for translation)
Line 3: Line 3:


<translate>
<translate>
<!--T:1-->
This tutorial is about creating your own online repository and building a custom package(set) with the help of ''buildpkg''. Later, you can install those packages to your customized Manjaro ISO using '''buildiso'''.
This tutorial is about creating your own online repository and building a custom package(set) with the help of ''buildpkg''. Later, you can install those packages to your customized Manjaro ISO using '''buildiso'''.


<!--T:2-->
Before you start with this tutorial make sure you have completed the prerequisite steps in [[Build Manjaro ISOs with buildiso]].
Before you start with this tutorial make sure you have completed the prerequisite steps in [[Build Manjaro ISOs with buildiso]].


<!--T:3-->
The same XFCE ISO profile will be used as example on this Wiki page.
The same XFCE ISO profile will be used as example on this Wiki page.


==Tools to install==
==Tools to install== <!--T:4-->
Sync your system with the latest packages and ensure you have the following packages installed.
Sync your system with the latest packages and ensure you have the following packages installed.


<!--T:5-->
* git
* git
* manjaro-tools-{base|base-git}
* manjaro-tools-{base|base-git}
* manjaro-tools-{pkg|pkg-git}
* manjaro-tools-{pkg|pkg-git}


<!--T:6-->
It is important that you match your tools packages - don't mix the default and git packages.
It is important that you match your tools packages - don't mix the default and git packages.


==Create directories==
==Create directories== <!--T:7-->


<!--T:8-->
The first thing you should probably do is create a directory for your online repository. The online repository is called '''online-repo''' throughout this tutorial and it is located in your home-folder. You however are free to choose name location to your liking. This'll help keep things organized. Your repository consist of only this folder:
The first thing you should probably do is create a directory for your online repository. The online repository is called '''online-repo''' throughout this tutorial and it is located in your home-folder. You however are free to choose name location to your liking. This'll help keep things organized. Your repository consist of only this folder:


<!--T:9-->
{{UserCmd|command=mkdir ~/online-repo/x86_64}}
{{UserCmd|command=mkdir ~/online-repo/x86_64}}


<!--T:10-->
This online repository is created in your home folder, but you can create it anywhere you want.
This online repository is created in your home folder, but you can create it anywhere you want.


==Create your custom package tree==
==Create your custom package tree== <!--T:11-->


<!--T:12-->
Create a folder for the packages you want to build. The name is arbitrary decriptor - you can call it anything you think suitable.
Create a folder for the packages you want to build. The name is arbitrary decriptor - you can call it anything you think suitable.


<!--T:13-->
{{UserCmd|command=mkdir ~/pkgbuild}}
{{UserCmd|command=mkdir ~/pkgbuild}}


<!--T:14-->
Clone the relevant package(s) from AUR or from Github. Later you might create them yourself! You can select any package to build but as example we build the package <code>kickshaw</code>. Kickshaw is modern menu editor for among others openbox. First you add it to your pkgubild repo. Do this using git
Clone the relevant package(s) from AUR or from Github. Later you might create them yourself! You can select any package to build but as example we build the package <code>kickshaw</code>. Kickshaw is modern menu editor for among others openbox. First you add it to your pkgubild repo. Do this using git


<!--T:15-->
{{UserCmd|command=cd ~/pkgbuild}}
{{UserCmd|command=cd ~/pkgbuild}}


<!--T:16-->
Clone the example package from AUR
Clone the example package from AUR


<!--T:17-->
{{UserCmd|command=git clone <nowiki>https://aur.archlinux.org/kickshaw</nowiki>}}
{{UserCmd|command=git clone <nowiki>https://aur.archlinux.org/kickshaw</nowiki>}}


<!--T:18-->
Now you have a folder with a <code>PKGBUILD</code> file in your pkgbuild repository.
Now you have a folder with a <code>PKGBUILD</code> file in your pkgbuild repository.


<!--T:19-->
{{UserCmd|command=ls -R ~/pkgbuild}}
{{UserCmd|command=ls -R ~/pkgbuild}}


<!--T:20-->
It is best practice to always familarize yourself with the content of the package to ensure everything is as expected.
It is best practice to always familarize yourself with the content of the package to ensure everything is as expected.


==Building with buildpkg==
==Building with buildpkg== <!--T:21-->


<!--T:22-->
The '''buildpkg''' has some options you need to familiarize yourself with.
The '''buildpkg''' has some options you need to familiarize yourself with.


<!--T:23-->
{{File|file=buildpkg -h|content=<pre>
{{File|file=buildpkg -h|content=<pre>
Usage: buildpkg [options]
Usage: buildpkg [options]
Line 67: Line 86:
</pre>}}
</pre>}}


<!--T:24-->
Next thing to do is build the package. Please note that you must be located one level above your actual PKGBUILD. Understand this as the <code>-p</code> argument is '''the name of the folder''' holding the PKGBUILD instructionset.  
Next thing to do is build the package. Please note that you must be located one level above your actual PKGBUILD. Understand this as the <code>-p</code> argument is '''the name of the folder''' holding the PKGBUILD instructionset.  


<!--T:25-->
{{UserCmd|command=buildpkg -p kickchaw}}
{{UserCmd|command=buildpkg -p kickchaw}}


<!--T:26-->
For more examples how to use '''buildpkg''', look [https://wiki.manjaro.org/index.php?title=Manjaro-tools#buildpkg here].
For more examples how to use '''buildpkg''', look [https://wiki.manjaro.org/index.php?title=Manjaro-tools#buildpkg here].


<!--T:27-->
The buildpkg script creates a closed environment for building the package. This is done, so not to pollute your system with build artifacts.
The buildpkg script creates a closed environment for building the package. This is done, so not to pollute your system with build artifacts.


==Copy package files to online repository==
==Copy package files to online repository== <!--T:28-->


<!--T:29-->
The resulting package is saved in the location defined in your manjaro-tools.conf on your system (default is the cache folder)
The resulting package is saved in the location defined in your manjaro-tools.conf on your system (default is the cache folder)


<!--T:30-->
{{UserCmd|command=ls /var/cache/manjaro-tools/pkg/stable/x86_64}}
{{UserCmd|command=ls /var/cache/manjaro-tools/pkg/stable/x86_64}}


<!--T:31-->
You should see compressed package files. The file name should end with <code>.pkg.tar.zst</code>.
You should see compressed package files. The file name should end with <code>.pkg.tar.zst</code>.


<!--T:32-->
Copy or move your package files to your online repository:
Copy or move your package files to your online repository:


<!--T:33-->
{{UserCmd|command=mv /var/cache/manjaro-tools/pkg/stable/x86_64 ~/online-repo}}
{{UserCmd|command=mv /var/cache/manjaro-tools/pkg/stable/x86_64 ~/online-repo}}


==Build a .db file==
==Build a .db file== <!--T:34-->


<!--T:35-->
To keep track of available packages the ''pacman'' package manager uses database files which is downloaded and kept on your computer. You need to create such a database file for your repo. It is crucial that your database filename is the same as your repo name. If your repo is named '''online-repo''' then your database name must be '''online-repo.db.tar.gz'''.
To keep track of available packages the ''pacman'' package manager uses database files which is downloaded and kept on your computer. You need to create such a database file for your repo. It is crucial that your database filename is the same as your repo name. If your repo is named '''online-repo''' then your database name must be '''online-repo.db.tar.gz'''.


<!--T:36-->
Use the command <code>repo-add</code> to build a database file inside your designated repo folder
Use the command <code>repo-add</code> to build a database file inside your designated repo folder


<!--T:37-->
{{UserCmd|command=cd ~/online-repo/x86_64}}
{{UserCmd|command=cd ~/online-repo/x86_64}}
{{UserCmd|command=repo-add online-repo.db.tar.gz *.pkg.tar.*}}
{{UserCmd|command=repo-add online-repo.db.tar.gz *.pkg.tar.*}}
Line 103: Line 134:
</pre>}}
</pre>}}


<!--T:38-->
Every time you change the content of your online repository, the database must be rebuild! Otherwise, ''buildiso'' will complain later about missing packages in your online repository.
Every time you change the content of your online repository, the database must be rebuild! Otherwise, ''buildiso'' will complain later about missing packages in your online repository.


<!--T:39-->
Two of the files are symlinks which may or may not work on your chosen host so they can be left out.
Two of the files are symlinks which may or may not work on your chosen host so they can be left out.


==Upload online-repo to Host Server==
==Upload online-repo to Host Server== <!--T:40-->


<!--T:41-->
Now you need to upload online-repo to your Host Server. Upload everything from online-repo to your Host Server. Your web address as to match the name of the directory folder you created. This is what your web address should look like after upload online-repo to your Host Server.
Now you need to upload online-repo to your Host Server. Upload everything from online-repo to your Host Server. Your web address as to match the name of the directory folder you created. This is what your web address should look like after upload online-repo to your Host Server.


  <nowiki>http://www.myserver.com/repository/online-repo/x86_64/</nowiki>
  <!--T:42-->
<nowiki>http://www.myserver.com/repository/online-repo/x86_64/</nowiki>


==Add online-repo to your iso-profile==
==Add online-repo to your iso-profile== <!--T:43-->


<!--T:44-->
Create a file
Create a file
{{File|file=${profile_dir}/user-repos.conf|content=<pre>
{{File|file=${profile_dir}/user-repos.conf|content=<pre>
Line 121: Line 157:
Server = <nowiki>http://www.myserver.com/repository/online-repo/$repo/$arch</nowiki></pre>}}
Server = <nowiki>http://www.myserver.com/repository/online-repo/$repo/$arch</nowiki></pre>}}


<!--T:45-->
Custom online repositories will be added to the resulting '''pacman.conf'''. This means AUR packages cannot be installed unless you are using webserver to provide <code>[online-repo]</code> as shown this article).
Custom online repositories will be added to the resulting '''pacman.conf'''. This means AUR packages cannot be installed unless you are using webserver to provide <code>[online-repo]</code> as shown this article).


==Add package names to ISO profile==
==Add package names to ISO profile== <!--T:46-->


<!--T:47-->
Now you add <code>kickshaw</code> to your package list for your ISO profile. This means your '''Packages-Desktop''' file should look something like this:
Now you add <code>kickshaw</code> to your package list for your ISO profile. This means your '''Packages-Desktop''' file should look something like this:


<!--T:48-->
{{File|file=~/iso-profiles/manjaro/xfce/Packages-Desktop|content=<pre>
{{File|file=~/iso-profiles/manjaro/xfce/Packages-Desktop|content=<pre>
ffmpegthumbnailer
ffmpegthumbnailer
Line 139: Line 178:
menulibre
menulibre


<!--T:49-->
## AUR packages
## AUR packages
kickshaw</pre>}}
kickshaw</pre>}}


==Cleaning build environment==
==Cleaning build environment== <!--T:50-->


<!--T:51-->
For removing your build environment from your hard drive, execute:
For removing your build environment from your hard drive, execute:


<!--T:52-->
{{UserCmd|command=sudo rm -r /var/lib/manjaro-tools/buildpkg}}
{{UserCmd|command=sudo rm -r /var/lib/manjaro-tools/buildpkg}}


==NOTE==
==NOTE== <!--T:53-->


<!--T:54-->
Now, you can continue to [https://wiki.manjaro.org/index.php?title=Build_Manjaro_ISOs_with_buildiso#manjaro-tools.conf adjust your manjaro-tools.conf] or [https://wiki.manjaro.org/index.php?title=Build_Manjaro_ISOs_with_buildiso#Build_your_ISO build your ISO].
Now, you can continue to [https://wiki.manjaro.org/index.php?title=Build_Manjaro_ISOs_with_buildiso#manjaro-tools.conf adjust your manjaro-tools.conf] or [https://wiki.manjaro.org/index.php?title=Build_Manjaro_ISOs_with_buildiso#Build_your_ISO build your ISO].


<!--T:55-->
Creating an online repo requires you to keep the repo up-to-date when changes are made upstream.
Creating an online repo requires you to keep the repo up-to-date when changes are made upstream.
</translate>
</translate>