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

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

From Manjaro
imported>Fhdk
(Marked this version for translation)
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<languages/>
__TOC__
__TOC__


 
<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.


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


<!--T:5-->
* git
* manjaro-tools-{base|base-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.
==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:


~ >>> mkdir ~/online-repo/x86_64
<!--T:9-->
{{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.


~ >>> mkdir ~/pkgbuild
<!--T:13-->
{{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


~ >>> cd ~/pkgbuild
<!--T:15-->
~/pkgbuild >>> git clone https://aur.archlinux.org/kickshaw
{{UserCmd|command=cd ~/pkgbuild}}


Now you have a folder with a <code>PKGBUILD</code> file in your repo
<!--T:16-->
Clone the example package from AUR


~/pkgbuild >>> ls -R
<!--T:17-->
~/pkgbuild >>> cat kickshaw/PKGBUILD
{{UserCmd|command=git clone <nowiki>https://aur.archlinux.org/kickshaw</nowiki>}}


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


<!--T:19-->
{{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.
==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.


~ >>> buildpkg -h                                                                                                      
<!--T:23-->
Usage: buildpkg [options]
{{File|file=buildpkg -h|content=<pre>
    -p <pkg>          Build list or pkg [default: default]
Usage: buildpkg [options]
    -a <arch>          Arch [default: x86_64]
  -p <pkg>          Build list or pkg [default: default]
    -b <branch>        Branch [default: unstable]
  -a <arch>          Arch [default: x86_64]
    -r <dir>          Chroots directory
  -b <branch>        Branch [default: unstable]
                        [default: /var/cache/manjaro-tools]
  -r <dir>          Chroots directory
    -i <pkgs>          Install packages into the working copy of the chroot
                      [default: /var/cache/manjaro-tools]
    -c                Recreate chroot
  -i <pkgs>          Install packages into the working copy of the chroot
    -w                Clean up cache and sources
  -c                Recreate chroot
    -n                Install and run namcap check
  -w                Clean up cache and sources
    -s                Sign packages
  -n                Install and run namcap check
    -u                Udev base-devel group (no systemd)
  -s                Sign packages
    -q                Query settings and pretend build
  -u                Udev base-devel group (no systemd)
    -h                This help
  -q                Query settings and pretend build
  -h                This help
</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.  


~ >>> buildpkg -p kickchaw
<!--T:25-->
{{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].


The buildpkg script creates a closed environment for building the package. This is done, so not to pollute your system with build artifacts.  
<!--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.
==Copy package files to online repository==


The resulting package is created in this directory on your system:
==Copy package files to online repository== <!--T:28-->


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


On a 64-Bit system using the stable branch the exact path is
<!--T:30-->
{{UserCmd|command=ls /var/cache/manjaro-tools/pkg/stable/x86_64}}


/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.xz</code>.


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


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


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


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: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'''.


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


~ >>> cd ~/online-repo/x86_64
<!--T:37-->
~/online-repo/x86_64 >>> repo-add online-repo.db.tar.gz *.pkg.tar.*
{{UserCmd|command=cd ~/online-repo/x86_64}}
~/online-repo/x86_64 >>> ls
{{UserCmd|command=repo-add online-repo.db.tar.gz *.pkg.tar.*}}
kickshaw-0.5-2-x86_64.pkg.tar.xz  online-repo.db online-repo.db.tar.gz online-repo.files online-repo.files.tar.gz
{{File|file=~/online-repo/x86_64|content=<pre>
kickshaw-0.5-2-x86_64.pkg.tar.zst
online-repo.db
online-repo.db.tar.gz
online-repo.files
online-repo.files.tar.gz
</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.


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


http://www.myserver.com/repository/online-repo/x86_64/
==Add online-repo to your iso-profile== <!--T:43-->


==Add online-repo to your iso-profile==
<!--T:44-->
Create a file
{{File|file=${profile_dir}/user-repos.conf|content=<pre>
[online-repo]
SigLevel = Never
Server = <nowiki>http://www.myserver.com/repository/online-repo/$repo/$arch</nowiki></pre>}}


Create a file
<!--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).


${profile_dir}/user-repos.conf
<!--T:56-->
NB: '''${profile_dir}''' is not the '''iso-profiles''' directory but the specific sub-directory for a build, e.g. '''iso-profiles/manjaro/kde'''. Put your file '''user-repos.conf''' there to be found during the build process.


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


[online-repo]
<!--T:47-->
SigLevel = Never
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:
Server = http://www.myserver.com/repository/online-repo/$repo/$arch


Custom non-online repositories will be added to the resulting pacman.conf. This means AUR packages are best installed from a custom online repository (as demonstrated by <code>[online-repo]</code> in this tutorial). Packages neither available in the Manjaro repositories nor in the AUR are best installed from a custom non-online repository (see <code>[infinality-bundle]</code> as example).
<!--T:48-->
{{File|file=~/iso-profiles/manjaro/xfce/Packages-Desktop|content=<pre>
ffmpegthumbnailer
gconf # fix qt-theme
gnome-keyring # fix wlan segfault
gufw # firewall
accountsservice
lightdm-gtk-greeter
lightdm-gtk-greeter-settings
light-locker
manjaro-settings-manager
menulibre


==Add package names to ISO profile==
<!--T:49-->
## AUR packages
kickshaw</pre>}}


Using the example mentioned in [https://wiki.manjaro.org/index.php?title=Build_Manjaro_ISOs_with_buildiso#Packages-Xfce here], you can now add the AUR package names to your <code>Packages-Xfce</code> file.
==Cleaning build environment== <!--T:50-->
 
Attention: You need to add all dependency names '''before''' the package name (only for dependencies from the AUR).
 
Now you add <code>kickshaw</code> to your package list for your ISO profile. This means your <code>/usr/share/manjaro-tools/iso-profiles/official/xfce/Packages-Xfce</code> file should look something like this:
 
## XFCE Main Packages
ffmpegthumbnailer
gconf # fix qt-theme
gnome-keyring # fix wlan segfault
gufw # firewall
accountsservice
lightdm-gtk-greeter
lightdm-gtk-greeter-settings
light-locker
manjaro-settings-manager
menulibre
...
## AUR packages
'''kickshaw'''
 
=Cleaning build environment=


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


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


=More=
==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-->
Please remember to install <code>yaourt</code>, <code>octopi</code>, or <code>pamac</code> on your ISO, too. Only these Programs can update packages from the AUR.
Creating an online repo requires you to keep the repo up-to-date when changes are made upstream.
 
</translate>
 
[[Category:Contents Page{{#translation:}}]]
[[Category:Contents Page]]
[[Category:ISO{{#translation:}}]]
[[Category:Development{{#translation:}}]]

Latest revision as of 06:46, 13 May 2024

Other languages:
English • ‎русский

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.

Before you start with this tutorial make sure you have completed the prerequisite steps in Build Manjaro ISOs with buildiso.

The same XFCE ISO profile will be used as example on this Wiki page.

Tools to install

Sync your system with the latest packages and ensure you have the following packages installed.

  • git
  • manjaro-tools-{base|base-git}
  • manjaro-tools-{pkg|pkg-git}

It is important that you match your tools packages - don't mix the default and git packages.

Create directories

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:

user $ mkdir ~/online-repo/x86_64 COPY TO CLIPBOARD


This online repository is created in your home folder, but you can create it anywhere you want.

Create your custom package tree

Create a folder for the packages you want to build. The name is arbitrary decriptor - you can call it anything you think suitable.

user $ mkdir ~/pkgbuild COPY TO CLIPBOARD


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 kickshaw. Kickshaw is modern menu editor for among others openbox. First you add it to your pkgubild repo. Do this using git

user $ cd ~/pkgbuild COPY TO CLIPBOARD


Clone the example package from AUR

user $ git clone https://aur.archlinux.org/kickshaw COPY TO CLIPBOARD


Now you have a folder with a PKGBUILD file in your pkgbuild repository.

user $ ls -R ~/pkgbuild COPY TO CLIPBOARD


It is best practice to always familarize yourself with the content of the package to ensure everything is as expected.

Building with buildpkg

The buildpkg has some options you need to familiarize yourself with.

buildpkg -h
Usage: buildpkg [options]
   -p <pkg>           Build list or pkg [default: default]
   -a <arch>          Arch [default: x86_64]
   -b <branch>        Branch [default: unstable]
   -r <dir>           Chroots directory
                      [default: /var/cache/manjaro-tools]
   -i <pkgs>          Install packages into the working copy of the chroot
   -c                 Recreate chroot
   -w                 Clean up cache and sources
   -n                 Install and run namcap check
   -s                 Sign packages
   -u                 Udev base-devel group (no systemd)
   -q                 Query settings and pretend build
   -h                 This help

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 -p argument is the name of the folder holding the PKGBUILD instructionset.

user $ buildpkg -p kickchaw COPY TO CLIPBOARD


For more examples how to use buildpkg, look here.

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

The resulting package is saved in the location defined in your manjaro-tools.conf on your system (default is the cache folder)

user $ ls /var/cache/manjaro-tools/pkg/stable/x86_64 COPY TO CLIPBOARD


You should see compressed package files. The file name should end with .pkg.tar.zst.

Copy or move your package files to your online repository:

user $ mv /var/cache/manjaro-tools/pkg/stable/x86_64 ~/online-repo COPY TO CLIPBOARD


Build a .db file

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.

Use the command repo-add to build a database file inside your designated repo folder

user $ cd ~/online-repo/x86_64 COPY TO CLIPBOARD


user $ repo-add online-repo.db.tar.gz *.pkg.tar.* COPY TO CLIPBOARD


~/online-repo/x86_64
kickshaw-0.5-2-x86_64.pkg.tar.zst
online-repo.db
online-repo.db.tar.gz
online-repo.files
online-repo.files.tar.gz

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.

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

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.

http://www.myserver.com/repository/online-repo/x86_64/

Add online-repo to your iso-profile

Create a file

${profile_dir}/user-repos.conf
[online-repo]
SigLevel = Never
Server = http://www.myserver.com/repository/online-repo/$repo/$arch

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 [online-repo] as shown this article).

NB: ${profile_dir} is not the iso-profiles directory but the specific sub-directory for a build, e.g. iso-profiles/manjaro/kde. Put your file user-repos.conf there to be found during the build process.

Add package names to ISO profile

Now you add kickshaw to your package list for your ISO profile. This means your Packages-Desktop file should look something like this:

~/iso-profiles/manjaro/xfce/Packages-Desktop
ffmpegthumbnailer
gconf # fix qt-theme
gnome-keyring # fix wlan segfault
gufw # firewall
accountsservice
lightdm-gtk-greeter
lightdm-gtk-greeter-settings
light-locker
manjaro-settings-manager
menulibre

## AUR packages
kickshaw

Cleaning build environment

For removing your build environment from your hard drive, execute:

user $ sudo rm -r /var/lib/manjaro-tools/buildpkg COPY TO CLIPBOARD


NOTE

Now, you can continue to adjust your manjaro-tools.conf or build your ISO.

Creating an online repo requires you to keep the repo up-to-date when changes are made upstream.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.