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
(→‎Create directories: updated to reflect dropped support for 32-bit arch)
imported>Fhdk
Line 2: Line 2:




This tutorial is about creating your own online repository. This repository can be used to download (with the help of ''yaourt'') and build (with the help of ''buildpkg'') packages. 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'''.
 


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


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==
==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 name it and place it 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 -p ~/online-repo
~ >>> mkdir ~/online-repo


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.


==Download package files from AUR using yaourt==
==Create your custom package tree==
 
Now, go to your online build directory:
 
cd ~/online-build
 
Next do
 
yaourt -G <package name>


in order to download package files from the AUR to your build directory. You will see a new directory with the package name. In it are various files, including a <code>PKGBUILD</code> file.
Create a folder for the packages you want to build. The name is arbitrary decriptor - you can call it anything you think suitable.


===Example:===
~ >>> mkdir ~/pkgbuild
You want to add the package <code>pcmanfm-qt-git</code> to your ISO. Therefore, you need to download it to your online repository first. You download and unpack it using


yaourt -G pcmanfm-qt-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


You see a new <code>PKGBUILD</code> file in your online build directory:
~ >>> cd ~/pkgbuild
~/pkgbuild >>> git clone https://aur.archlinux.org/kickshaw


~/online-build/pcmanfm-qt-git/PKGBUILD
Now you have a folder with a <code>PKGBUILD</code> file in your repo


~/pkgbuild >>> ls -R
~/pkgbuild >>> cat kickshaw/PKGBUILD


==Building with buildpkg==
==Building with buildpkg==


Up to this point, you have only downloaded and unpacked files from the AUR. Next, you need to build those files into proper packages:
The '''buildpkg''' has some options you need to familiarize yourself with.
 
cd ~/online-build
 
buildpkg -p <package name>
 


If you want to build 32-Bit packages on a 64-Bit system, you can do this by specifying the architecture:
~ >>> 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


buildpkg -a i686 -p <package name>
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


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].
 
===Example:===
As instructed above, try to build <code>pcmanfm-qt-git</code>:
 
buildpkg -p pcmanfm-qt-git
 
The build gets aborted with the following error message:
 
==> Installing missing dependencies...
error: target not found: liblxqt-git
==> ERROR: 'pacman' failed to install missing dependencies.
 
This means <code>liblxqt-git</code> is a dependency of <code>pcmanfm-qt-git</code>. You need to download and build <code>liblxqt-git</code> before you can build <code>pcmanfm-qt-git</code> successfully.
Therefore, do the same (with one slight difference) as you did with <code>pcmanfm-qt-git</code>:
 
yaourt -G liblxqt-git
buildpkg '''-n''' -p liblxqt-git
 
Please note the additional <code>-n</code> argument. This argument installs <code>liblxqt-git</code> in your build environment (<code>pcmanfm-qt-git</code> needs <code>liblxqt-git</code> installed in order to utilize it).
 
Again, you receive an error:
 
==> Installing missing dependencies...
error: target not found: libqtxdg-git
==> ERROR: 'pacman' failed to install missing dependencies.
 
So, <code>liblxqt-git</code> has another dependency: <code>libqtxdg-git</code>
Repeat the whole process with <code>libqtxdg-git</code>:
 
yaourt -G libqtxdg-git
buildpkg -n -p libqtxdg-git
 
Finally, a package gets built (and installed in your build environment) successfully!
 
Now, build the other packages (in reverse order):
 
buildpkg -n -p liblxqt-git
buildpkg -p pcmanfm-qt-git


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


In the last chapter you have built packages. These packages were created in this directory on your system:
The resulting package is created in this directory on your system:


  /var/cache/manjaro-tools/
  /var/cache/manjaro-tools/pkg/<code>$branch</code>/<code>$arch</code>


On a 64-Bit system using the unstable branch the exact path is
On a 64-Bit system using the stable branch the exact path is


  /var/cache/manjaro-tools/pkg/unstable/x86_64
  /var/cache/manjaro-tools/pkg/stable/x86_64


You should see compressed package files. The file name should end with <code>.pkg.tar.xz</code>.
You should see compressed package files. The file name should end with <code>.pkg.tar.xz</code>.


Copy or move your package files to your online repository:


Move all package files to your online repository:
~ >>> cp -r /var/cache/manjaro-tools/pkg/stable ~/online-repo


~/online-repo/x86_64
==Build a .db file==


===Example:===
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'''.
Your online repository should now look like this:


liblxqt-git-0.8.0.23.g079768e-1-x86_64.pkg.tar.xz 
Use the command <code>repo-add</code> to build a database file
libqtxdg-git-1.0.0.7.g0503cf7-1-x86_64.pkg.tar.xz 
pcmanfm-qt-git-0.8.0.4.g99987af-1-x86_64.pkg.tar.xz


 
~ >>> cd ~/online-repo/x86_64
==Build a .db file==
~/online-repo/x86_64 >>> repo-add online-repo.db.tar.gz *.pkg.tar.*
 
  ~/online-repo/x86_64 >>> ls
Use the command <code>repo-add</code> to build a database file. Run the following commands in a terminal:
  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
 
  cd ~/online-repo/x86_64
  repo-add online-repo.db.tar.gz *.pkg.tar.*


Every time you add packages to your online repositories, these commands need to be executed again! Otherwise, ''buildiso'' will complain later about missing packages in your online repository.
Every time you add packages to your online repositories, these commands need to be executed again! Otherwise, ''buildiso'' will complain later about missing packages in your online repository.
===Example:===
After running those commands, your online repository looks like this:
online-repo.db.tar
online-repo.db
liblxqt-git-0.8.0.23.g079768e-1-x86_64.pkg.tar.xz 
libqtxdg-git-1.0.0.7.g0503cf7-1-x86_64.pkg.tar.xz 
pcmanfm-qt-git-0.8.0.4.g99987af-1-x86_64.pkg.tar.xz


==Upload online-repo to Host Server==
==Upload online-repo to Host Server==
Line 148: Line 98:
64-Bit Repository
64-Bit Repository
  http://www.myserver.com/repository/online-repo/x86/
  http://www.myserver.com/repository/online-repo/x86/
32-Bit Repository
http://www.myserver.com/repository/online-repo/i686


==Add online-repo to your iso-profile==
==Add online-repo to your iso-profile==
Line 165: Line 111:
  Server = http://www.myserver.com/repository/online-repo/$repo/$arch
  Server = http://www.myserver.com/repository/online-repo/$repo/$arch


===Example:===
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).
 
[online-repo]
SigLevel = Never
Server = http://www.myserver.com/repository/online-repo/$repo/$arch
 
Custom online repositories will get removed automatically from this file before it gets copied over to the installed system, whereas custom non-online repositories will be kept. 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).


==Add package names to ISO profile==
==Add package names to ISO profile==
Line 180: Line 120:


===Example:===
===Example:===
You can now add <code>pcmanfm-qt-git</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 exactly like this:
You can now 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 exactly like this:


  ## XFCE Main Packages
  ## XFCE Main Packages
Line 197: Line 137:
   
   
  ## AUR packages
  ## AUR packages
  '''libqtxdg-git'''
  '''kickshaw'''
'''liblxqt-git'''
'''pcmanfm-qt-git'''
 
The order of package installations to your ISO is from top to bottom. Please note the '''exact''' order of the last 3 packages. <code>pcmanfm-qt-git</code> depends on <code>liblxqt-git</code>, which depends on <code>libqtxdg-git</code> (see chapter 4.1). Therefore, <code>liblxqt-git</code> needs to be the first package, which gets installed!
 


=Cleaning build environment=
=Cleaning build environment=

Revision as of 09:07, 23 September 2017


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.

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:

~ >>> mkdir ~/online-repo

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.

~ >>> mkdir ~/pkgbuild

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

~ >>> cd ~/pkgbuild
~/pkgbuild >>> git clone https://aur.archlinux.org/kickshaw

Now you have a folder with a PKGBUILD file in your repo

~/pkgbuild >>> ls -R 
~/pkgbuild >>> cat kickshaw/PKGBUILD

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.

~ >>> buildpkg -p kickchaw

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 created in this directory on your system:

/var/cache/manjaro-tools/pkg/$branch/$arch

On a 64-Bit system using the stable branch the exact path is

/var/cache/manjaro-tools/pkg/stable/x86_64

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

Copy or move your package files to your online repository:

~ >>> cp -r /var/cache/manjaro-tools/pkg/stable ~/online-repo

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

~ >>> cd ~/online-repo/x86_64
~/online-repo/x86_64 >>> repo-add online-repo.db.tar.gz *.pkg.tar.*
~/online-repo/x86_64 >>> ls
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

Every time you add packages to your online repositories, these commands need to be executed again! Otherwise, buildiso will complain later about missing packages in your online repository.

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.

Example:

This is what your web address should look like after upload online-repo to your Host Server.

64-Bit Repository

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

Add online-repo to your iso-profile

Create a file

${profile_dir}/user-repos.conf

Add these lines

[online-repo]
SigLevel = Never
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 [online-repo] in this tutorial). Packages neither available in the Manjaro repositories nor in the AUR are best installed from a custom non-online repository (see [infinality-bundle] as example).

Add package names to ISO profile

Using the example mentioned in here, you can now add the AUR package names to your Packages-Xfce file.

Attention: You need to add all dependency names before the package name (only for dependencies from the AUR).

Example:

You can now add kickshaw to your package list for your ISO profile. This means your /usr/share/manjaro-tools/iso-profiles/official/xfce/Packages-Xfce file should look exactly 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

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

sudo rm -r /var/lib/manjaro-tools/buildpkg


More

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


Please remember to install yaourt, octopi, or pamac on your ISO, too. Only these Programs can update packages from the AUR.

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