Build Manjaro ISO image with AUR packages

Hi,

How to build a Manjaro ISO image with AUR packages ?
something go wrong during the build process.

  -> Installing packages to /var/lib/manjaro-tools/buildiso/kde/x86_64/desktopfs
:: Synchronizing package databases...
 core                                                           170,7 KiB   517 KiB/s 00:00 [#####################################################] 100%
 extra                                                         1900,3 KiB  1228 KiB/s 00:02 [#####################################################] 100%
 community                                                        7,0 MiB  1939 KiB/s 00:04 [#####################################################] 100%
 multilib                                                       174,1 KiB  1415 KiB/s 00:00 [#####################################################] 100%
error: target not found: ipscan
:: There are 2 providers available for gtk3-print-backends:
:: Repository extra
   1) gtk3
:: Repository community
   2) gtk3-typeahead

Enter a number (default=1): 
==> ERROR: Failed to install packages to new root
==> ERROR: Failed to install all packages
==> ERROR: A failure occurred in make_image_desktop().
    Aborting...
 --> overlayfs umount: [/var/lib/manjaro-tools/buildiso/kde/x86_64/desktopfs]
 --> umount overlayfs: [/var/lib/manjaro-tools/buildiso/kde/x86_64/desktopfs]
[nls@lap ~]$ 

For some packages I have to add >extra…
example
>extra k3b

#Adding_AUR_packages: Build Manjaro ISOs with buildiso - Manjaro

I thought it wasn’t explain in the wiki, thanks for your reply.
I’ll test it as soon as possible.

The tools will reject packages not in the repo.

I suspect you can cheat the build process by running a local http.server instead of a regular online mirror.

HIghly experimental

Recently I have been playing with a script to create a custom iso from your installed system. It is not quite finished - in any case you are welcome peek into it.

Untested - no support - most likely buggy.

#!/usr/bin/env bash
#
# The purpose of this script is to duplicate a running Manjaro system
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
# Copyright (c) 2021 @linux-aarhus
#
#
# extract system info
# - running kernel            : uname -r | awk -F'.' '{print "linux"$1$2}'
# - system branch             : pacman-mirrors -G
#
# package filtering commands
# - explicit inst. packages   : pacman -Qqetn > pkglist.txt
# - dependencies              : comm -13 <(pacman -Qqdt | sort) <(pacman -Qqdtt | sort) > deplist.txt
# - foreign packages          : pacman -Qqem > aurlist.txt
#
# caveats
# - foreign package repos     : packages from third party repo in pacman cannot be installed
# - possible workaround       : add the repo to a ``user-repos.conf` in the profile folder`
# - duplicates                : if pacman encounters duplicate files the process will break
#
# THIS IS A WORK IN PROGRESS
#

# MODIFY AS NEEDED
# manjaro edition
TPL_EDITION="kde"
# branch to use (default is current branch)
TPL_BRANCH=$(pacman-mirrors -G)
# kernel to use (default is running kernel)
TPL_KERNEL=$(uname -r | awk -F'.' '{print "linux"$1$2}')
# iso profiles work dir
TPL_DIR=manjaro-iso-profiles
# your spin name
MY_TPL="my-manjaro"
# work dir
MY_WORKDIR=$HOME/work-dir
# output dir
MY_ISODIR=$HOME/iso

# modify below lists to fit your usecase
# - only configurations from $HOME is copied
# - be careful not to include files/foldes containing credentials or ssh keys
# - if you need configuration stored in other places you must modify the script accordingly
#
# dotfolders to copy - add foldders as you see fit
CONFIG_FOLDERS=('.config' '.local')
# dotfiles to copy - add files as you see fit
CONFIG_FILES=('.bashrc' '.gtkrc-2.0' '.profile' '.zshrc')
# nasty hack to cheat manjaro-tools into believing in an online user-repo
# one caveat it that you need to remove the repo from before the final build
BUILDREPO="false"
BUILDREPONAME="my-repo"
BUILDREPOURL="http://$HOST"
BUILDREPOPORT="8080"
#
# /END MODIFICATION
# ------------------------------------------------

# upstream iso-profiles repo
CLONE_URL="https://gitlab.manjaro.org/profiles-and-settings/iso-profiles.git"

prepare_online_mirror(){
    # create list of foreign packages
    pacman -Qqem > $MY_WORKDIR/$TPL_DIR/community/$MY_TPL/custom-packages.txt
    # create dir to hold build mirror
    if [ $BUILDREPONAME != "" ]; then
        mkdir -p $MY_WORKDIR/$BUILDREPONAME
    else
        return
    fi

    # change dir into our work dir
    cd $MY_WORKDIR
    # read the custom-packages.txt file
    while IFS= read -r pkg; do
        # clone tha script from AUR
        git clone https://aur.archlinux.org/$pkg.git
        # cd into the script folder
        cd $pkg
        # use makepkg to generate package - install necessary dependencies
        makepkg -s
        # move resulting package to the repo folder
        mv $MY_WORKDIR/$pkg/"$pkg*.pkg.tar.xz" $MY_WORKDIR/online-mirror
        # traverse back to the work-dir
        cd $MY_WORKDIR
    done < $MY_WORKDIR/$TPL_DIR/community/$MY_TPL/custom-packages.txt

    # create a database for the packages
    repo-add $MY_WORKDIR/$BUILDREPONAME/$BUILDREPONAME.db.tar.xz $MY_WORKDIR/$BUILDREPONAME/*.pkg.tar.zx

    # Add an online repo to the build process
    if [ $BUILDREPONAME != "" ]; then
        if [ $BUILDREPOURL != "" ]; then
            echo "[$BUILDREPONAME]\nSiglevel = Optional\nServer = $BUILDREPOURL" > $MY_WORKDIR/$TPL_DIR/community/$TPL_EDITION/user-repos.conf
        fi
    fi
    # start a local http server
    if [ BUILDREPO == "true" ]; then
        bash -c "python -m http.server -d $MY_WORKDIR/$BUILDREPONAME $BUILDREPOPORT" &
    fi
}

# ---- DO NOT RUN AS ROOT -----------------------------------------------------
# You don't want permission issues in your home
if (( $EUID == 0 )); then
    echo "Do not run this script as root!"
    exit 1
fi

# ---- Install the tools as needed ---------------------------------------------
sudo pacman -Syu manjaro-tools-iso-git manjaro-tools-base-git manjaro-tools-yaml-git git base-devel --needed

# ---- we cannot clone into an existing folder ---------------------------------
if ! [ -d "$MY_WORKDIR/$TPL_DIR" ]; then
    mkdir -p $MY_WORKDIR
    cd "$MY_WORKDIR"
    # Clone the profiles repo
    git clone $CLONE_URL "$TPL_DIR"
fi

# ---- Check if edition exist --------------------------------------------------
if ! [ -d $MY_WORKDIR/$TPL_DIR/community/$MY_TPL ]; then
    # copy the profile and rename it
    if [[ $TPL_EDITION =~ (kde|xfce|gnome) ]]; then
        cp -r $MY_WORKDIR/$TPL_DIR/manjaro/$TPL_EDITION $MY_WORKDIR/$TPL_DIR/community
        mv $MY_WORKDIR/$TPL_DIR/community/$TPL_EDITION $MY_WORKDIR/$TPL_DIR/community/$MY_TPL
    else
        cp -r $MY_WORKDIR/$TPL_DIR/community/$TPL_EDITION $MY_WORKDIR/$TPL_DIR/community
        mv $MY_WORKDIR/$TPL_DIR/community/$TPL_EDITION $MY_WORKDIR/$TPL_DIR/community/$MY_TPL
    fi
fi


# ---- Copy configurations ---------------------------------------------------
# The copy process can be amended to copy files from other locations
#
# create the target skel folder
mkdir -p $MY_WORKDIR/$TPL_DIR/community/$MY_TPL/desktop-overlay/etc/skel
# copy dot folders to the profiles desktop-overlay folder
for folder in ${CONFIG_FOLDERS[@]}; do
    echo " ==> copying $folder"
    cp -r $HOME/$folder $MY_WORKDIR/$TPL_DIR/community/$MY_TPL/desktop-overlay/etc/skel
done
# copy dot files
for dotfile in ${CONFIG_FILES[@]}; do
    echo " ==> copying $dotfile"
    cp $HOME/$dotfile $MY_WORKDIR/$TPL_DIR/community/$MY_TPL/desktop-overlay/etc/skel
done

# ---- Create package list ---------------------------------------------------
# create a backup copy of the previous list
cp $MY_WORKDIR/$TPL_DIR/community/$MY_TPL/Packages-Desktop \
        $MY_WORKDIR/$TPL_DIR/community/$MY_TPL/Packages-Desktop-$(date +%Y%m%d%H%M).bak

# creating desktop-package list
comm -13 <(cat /desktopfs-pkgs.txt | sort) <(pacman -Qqetn | sort) > $MY_WORKDIR/$TPL_DIR/community/$MY_TPL/Packages-Desktop

# ---- Setup tools -------------------------------------------------------------
# setup manjaro tools so it can find the iso-profiles
# the tools look for environment variable `run_dir`
mkdir -p $HOME/.config/manjaro-tools
echo "run_dir=$MY_WORKDIR/$TPL_DIR" > $HOME/.config/manjaro-tools/iso-profiles.conf

# ---- Setup tools -------------------------------------------------------------
# setup manjaro tools so it can find the iso-profiles
# the tools look for environment variable `run_dir`
mkdir -p $HOME/.config/manjaro-tools
echo "run_dir=$MY_WORKDIR/$TPL_DIR" > $HOME/.config/manjaro-tools/iso-profiles.conf

# ---- build out custom packages from AUR --------------------------------------
if [ BUILDREPO == "true" ]; then
    prepare_online_mirror
fi

# ---- Prebuild images -------------------------------------------------------
buildiso -p $MY_TPL -k $TPL_KERNEL -b $TPL_BRANCH -r $MY_WORKDIR/build -t $MY_ISODIR -xf

# ---- Remove online mirror --------------------------------------------------
if [ BUILDREPO == "true" ]; then
    # we need to remove online mirror from pacman.cong
    # simply replace with the default file
    cp /usr/share/manjaro-tools/pacman-default.conf $MY_WORKDIR/build/buildiso/$MY_TPL/x86_64/rootfs/etc/pacman.conf
fi

# ---- Assemble ISO ----------------------------------------------------------
buildiso -p $MY_TPL -k $TPL_KERNEL -b $TPL_BRANCH -r $MY_WORKDIR/build -t $MY_ISODIR -zcf

1 Like

Thanks for your reply, I’ll test it as soon as possible, with my feedback.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.