Buildiso with AUR packages: Using buildpkg

From Manjaro Linux
Jump to: navigation, search


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/x86_64

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

64-Bit Repository

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

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

Now you 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 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

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.