Compare commits
	
		
			9 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| bf0a9bc7fc | |||
| a4a690951c | |||
| e05765269e | |||
| 3df364189b | |||
| 974df38738 | |||
| 7b831d8867 | |||
| 7bf4dff1a1 | |||
| 529e73e2ab | |||
| 7be420a24f | 
| @@ -46,6 +46,7 @@ newroot=/mnt | ||||
| hostcache=0 | ||||
| copykeyring=1 | ||||
| copymirrorlist=1 | ||||
| pacmode=-Sy | ||||
|  | ||||
| usage() { | ||||
|     echo "usage: ${0##*/} [options] root [packages...]" | ||||
| @@ -54,6 +55,7 @@ usage() { | ||||
|     echo " -G               Avoid copying the host's pacman keyring to the target" | ||||
|     echo " -i               Avoid auto-confirmation of package selections" | ||||
|     echo " -M               Avoid copying the host's mirrorlist to the target" | ||||
|     echo ' -U               Use pacman -U to install packages' | ||||
|     echo " -h               Print this help message" | ||||
|     echo '' | ||||
|     echo ' basestrap installs packages to the specified new root directory.' | ||||
| @@ -65,7 +67,7 @@ usage() { | ||||
|  | ||||
| orig_argv=("$0" "$@") | ||||
|  | ||||
| opts=':C:cGiM' | ||||
| opts=':C:cGiMU' | ||||
|  | ||||
| while getopts ${opts} arg; do | ||||
|     case "${arg}" in | ||||
| @@ -74,6 +76,7 @@ while getopts ${opts} arg; do | ||||
|         i) interactive=1 ;; | ||||
|         G) copykeyring=0 ;; | ||||
|         M) copymirrorlist=0 ;; | ||||
|         U) pacmode=-U ;; | ||||
|         :) echo "invalid argument ${arg}:$OPTARG"; usage 1;; | ||||
|         ?) usage 0 ;; | ||||
|     esac | ||||
| @@ -109,7 +112,7 @@ if (( copykeyring ));then | ||||
| fi | ||||
|  | ||||
| msg2 'Installing packages to %s' "$newroot" | ||||
| if ! pacman -r "$newroot" -Sy "${pacman_args[@]}"; then | ||||
| if ! unshare --fork --pid pacman -r "$newroot" $pacmode "${pacman_args[@]}"; then | ||||
|     die 'Failed to install packages to new root' | ||||
| fi | ||||
|  | ||||
|   | ||||
| @@ -86,15 +86,13 @@ done | ||||
|  | ||||
| while read -r line; do | ||||
|     mapfile -t lines < <($pacconf_cmd --config "${pac_conf:-$working_dir/etc/pacman.conf}" \ | ||||
|         --repo $line Server | sed -r 's#(.*/)[^/]+/os/.+#\1$repo/os/$arch#') | ||||
|     if [[ ${lines[0]} != ${host_mirrors[0]} ]]; then | ||||
|         for line in "${lines[@]}"; do | ||||
|             if [[ $line = file://* ]]; then | ||||
|                 line=${line#file://} | ||||
|                 in_array "$line" "${cache_dirs[@]}" || cache_dirs+=("$line") | ||||
|             fi | ||||
|         done | ||||
|     fi | ||||
|         --repo $line Server | sed -r 's#(.*/)[^/]+/os/.+#\1#') | ||||
|     for line in "${lines[@]}"; do | ||||
|         if [[ $line = file://* ]]; then | ||||
|             line=${line#file://} | ||||
|             in_array "$line" "${cache_dirs[@]}" || cache_dirs+=("$line") | ||||
|         fi | ||||
|     done | ||||
| done < <($pacconf_cmd --config "${pac_conf:-$working_dir/etc/pacman.conf}" --repo-list) | ||||
|  | ||||
| copy_hostconf () { | ||||
|   | ||||
| @@ -15,6 +15,7 @@ | ||||
| . @libdir@/artools/util-base.sh | ||||
|  | ||||
| working_dir='' | ||||
| umode='' | ||||
|  | ||||
| files=() | ||||
| chroot_args=() | ||||
| @@ -22,6 +23,7 @@ chroot_args=() | ||||
| usage() { | ||||
|     echo "Usage: ${0##*/} [options] working-dir package-list..." | ||||
|     echo ' options:' | ||||
|     echo '    -U            Use pacman -U to install packages' | ||||
|     echo '    -C <file>     Location of a pacman config file' | ||||
|     echo '    -M <file>     Location of a makepkg config file' | ||||
|     echo '    -c <dir>      Set pacman cache' | ||||
| @@ -33,10 +35,11 @@ usage() { | ||||
|  | ||||
| orig_argv=("$0" "$@") | ||||
|  | ||||
| opts='hC:M:c:f:s' | ||||
| opts='hUC:M:c:f:s' | ||||
|  | ||||
| while getopts ${opts} arg; do | ||||
|     case "${arg}" in | ||||
|         U) umode=U ;; | ||||
|         C) pacman_conf="$OPTARG" ;; | ||||
|         M) makepkg_conf="$OPTARG" ;; | ||||
|         c) cache_dir="$OPTARG" ;; | ||||
| @@ -45,8 +48,10 @@ while getopts ${opts} arg; do | ||||
|         h|?) usage ;; | ||||
|         *) error "invalid argument '%s'" "$arg"; usage ;; | ||||
|     esac | ||||
|     chroot_args+=("-$arg") | ||||
|     [[ -v OPTARG ]] && chroot_args+=("$OPTARG") | ||||
|     if [[ $arg != U ]]; then | ||||
|         chroot_args+=("-$arg") | ||||
|         [[ -v OPTARG ]] && chroot_args+=("$OPTARG") | ||||
|     fi | ||||
| done | ||||
| shift $(($OPTIND - 1)) | ||||
|  | ||||
| @@ -88,7 +93,7 @@ for f in "${files[@]}"; do | ||||
|     cp "$f" "$working_dir$f" | ||||
| done | ||||
|  | ||||
| basestrap -Mc ${pacman_conf:+-C "$pacman_conf"} "$working_dir" \ | ||||
| basestrap -${umode}Mc ${pacman_conf:+-C "$pacman_conf"} "$working_dir" \ | ||||
|     ${cache_dirs[@]/#/--cachedir=} "$@" || die 'Failed to install all packages' | ||||
|  | ||||
| printf '%s.UTF-8 UTF-8\n' en_US de_DE > "$working_dir/etc/locale.gen" | ||||
|   | ||||
| @@ -14,6 +14,8 @@ | ||||
|  | ||||
| . @libdir@/artools/util-iso.sh | ||||
|  | ||||
| prepare_artools | ||||
|  | ||||
| gen_iso_fn(){ | ||||
|     local vars=("artix") name | ||||
|     vars+=("${PROFILE}") | ||||
| @@ -50,6 +52,8 @@ prepare_build(){ | ||||
|     basestrap_args+=(-C ${pacman_conf}) | ||||
|     work_dir=${CHROOTS_ISO}/${PROFILE}/artix | ||||
|  | ||||
|     prepare_dir "${ISO_POOL}" | ||||
|  | ||||
|     iso_dir="${ISO_POOL}/${PROFILE}" | ||||
|  | ||||
|     iso_root=${CHROOTS_ISO}/${PROFILE}/iso | ||||
| @@ -75,6 +79,44 @@ display_settings(){ | ||||
|     show_profile | ||||
| } | ||||
|  | ||||
| mk_squash(){ | ||||
|     local timer=$(get_timer) | ||||
|     make_sfs "${work_dir}/rootfs" | ||||
|     [[ -d "${work_dir}/livefs" ]] && make_sfs "${work_dir}/livefs" | ||||
|     show_elapsed_time "${FUNCNAME}" "${timer}" | ||||
| } | ||||
|  | ||||
| mk_iso(){ | ||||
|     touch "${iso_root}/.artix" | ||||
|     msg "Making bootable image" | ||||
|     # Sanity checks | ||||
|     [[ ! -d "${iso_root}" ]] && return 1 | ||||
|     if [[ -f "${iso_dir}/${iso_file}" ]]; then | ||||
|         msg2 "Removing existing bootable image..." | ||||
|         rm -rf "${iso_dir}/${iso_file}" | ||||
|     fi | ||||
|     assemble_iso | ||||
|     chown -R "${OWNER}:$(id --group ${OWNER})" "${iso_dir}" | ||||
| } | ||||
|  | ||||
| mk_boot(){ | ||||
|     local timer=$(get_timer) | ||||
|     run_safe "make_bootfs" | ||||
|     run_safe "make_grub" | ||||
|     show_elapsed_time "${FUNCNAME}" "${timer}" | ||||
| } | ||||
|  | ||||
| mk_chroots(){ | ||||
|     local timer=$(get_timer) | ||||
|     load_pkgs "${ROOT_LIST}" "${INITSYS}" | ||||
|     run_safe "make_rootfs" | ||||
|     if [[ -n ${LIVE_LIST} ]]; then | ||||
|         load_pkgs "${LIVE_LIST}" "${INITSYS}" | ||||
|         run_safe "make_livefs" | ||||
|     fi | ||||
|     show_elapsed_time "${FUNCNAME}" "${timer}" | ||||
| } | ||||
|  | ||||
| build(){ | ||||
|     msg "Start building [%s]" "${PROFILE}" | ||||
|     if ${clean_first};then | ||||
| @@ -95,28 +137,45 @@ build(){ | ||||
|         rm -rf --one-file-system "${iso_root}" | ||||
|     fi | ||||
|  | ||||
|     if ${iso_only}; then | ||||
|         [[ ! -d ${work_dir} ]] && die "Create images: %s -p %s -x" "${cmd}" "${PROFILE}" | ||||
|         compress_images | ||||
|         exit 1 | ||||
|     fi | ||||
|     if ${images_only}; then | ||||
|         prepare_images | ||||
|         warning "Continue compress: %s -p %s -zc ..." "${cmd}" "${PROFILE}" | ||||
|         exit 1 | ||||
|     else | ||||
|         prepare_images | ||||
|         compress_images | ||||
|     fi | ||||
|     case true in | ||||
|         ${chroot_only}) | ||||
|             mk_chroots | ||||
|             warning "Continue squash: %s -p %s -sc ..." "${cmd}" "${PROFILE}" | ||||
|             exit 1 | ||||
|         ;; | ||||
|         ${boot_only}) | ||||
|             mk_boot | ||||
|             warning "Continue iso: %s -p %s -zc ..." "${cmd}" "${PROFILE}" | ||||
|             exit 1 | ||||
|         ;; | ||||
|         ${squash_only}) | ||||
|             mk_squash | ||||
|             warning "Continue boot: %s -p %s -bc ..." "${cmd}" "${PROFILE}" | ||||
|             exit 1 | ||||
|         ;; | ||||
|         ${iso_only}) | ||||
|             [[ ! -d ${work_dir} ]] && die "Create chroot: %s -p %s -x" "${cmd}" "${PROFILE}" | ||||
|             mk_iso | ||||
|         ;; | ||||
|         *) | ||||
|             mk_chroots | ||||
|             mk_boot | ||||
|             mk_squash | ||||
|             mk_iso | ||||
|         ;; | ||||
|     esac | ||||
|     msg "Finished building [%s]" "${PROFILE}" | ||||
|     show_elapsed_time "${FUNCNAME}" "${timer_start}" | ||||
| } | ||||
|  | ||||
| clean_first=true | ||||
| pretend=false | ||||
| images_only=false | ||||
| chroot_only=false | ||||
| iso_only=false | ||||
| persist=false | ||||
| use_dracut=false | ||||
| squash_only=false | ||||
| boot_only=false | ||||
|  | ||||
| basestrap_args=(-GMc) | ||||
| cmd=${0##*/} | ||||
| @@ -136,9 +195,12 @@ usage() { | ||||
|     echo "                       [default: ${GPG_KEY}]" | ||||
|     echo '    -m                 Set SquashFS image mode to persistence' | ||||
|     echo '    -c                 Disable clean work dir' | ||||
|     echo '    -x                 Build images only' | ||||
|     echo '    -x                 Build chroot only' | ||||
|     echo '    -s                 Squash chroot only' | ||||
|     echo '    -b                 Generate iso boot only' | ||||
|     echo '    -z                 Generate iso only' | ||||
|     echo '                       Requires pre built images (-x)' | ||||
|     echo '    -d                 Use dracut instead of mkinitcpio for iso initramfs' | ||||
|     echo '    -q                 Query settings and pretend build' | ||||
|     echo '    -h                 This help' | ||||
|     echo '' | ||||
| @@ -148,7 +210,7 @@ usage() { | ||||
|  | ||||
| orig_argv=("$0" "$@") | ||||
|  | ||||
| opts='p:r:t:i:g:czxmqh' | ||||
| opts='p:r:t:i:g:czsbxmdqh' | ||||
|  | ||||
| while getopts "${opts}" arg; do | ||||
|     case "${arg}" in | ||||
| @@ -158,9 +220,12 @@ while getopts "${opts}" arg; do | ||||
|         i) INITSYS="$OPTARG" ;; | ||||
|         g) GPG_KEY="$OPTARG" ;; | ||||
|         c) clean_first=false ;; | ||||
|         x) images_only=true ;; | ||||
|         x) chroot_only=true ;; | ||||
|         z) iso_only=true ;; | ||||
|         s) squash_only=true ;; | ||||
|         b) boot_only=true ;; | ||||
|         m) persist=true ;; | ||||
|         d) use_dracut=true ;; | ||||
|         q) pretend=true ;; | ||||
|         h|?) usage 0 ;; | ||||
|         *) echo "invalid argument '${arg}'"; usage 1 ;; | ||||
|   | ||||
| @@ -14,6 +14,8 @@ | ||||
|  | ||||
| . @libdir@/artools/util-iso.sh | ||||
|  | ||||
| prepare_artools | ||||
|  | ||||
| connect(){ | ||||
|     echo "${ACCOUNT}@${FILE_HOST}:${FILE_HOME}" | ||||
| } | ||||
|   | ||||
| @@ -14,6 +14,8 @@ | ||||
|  | ||||
| . /usr/lib/artools/util-pkg.sh | ||||
|  | ||||
| prepare_artools | ||||
|  | ||||
| batch_move() { | ||||
|     local name="${1:-pkg_moves}" | ||||
|     local pkglist=${TREE_DIR_ARTIX}/$name.list | ||||
|   | ||||
| @@ -14,6 +14,8 @@ | ||||
|  | ||||
| . @libdir@/artools/util-pkg.sh | ||||
|  | ||||
| prepare_artools | ||||
|  | ||||
| create_first=false | ||||
| rebuild=false | ||||
| no_check=false | ||||
| @@ -90,7 +92,7 @@ if ${create_first} || [[ ! -d "${CHROOTS_PKG}/${repo}-${ARCH}" ]];then | ||||
|     lock_close 9 | ||||
|  | ||||
|     rm -rf --one-file-system "${CHROOTS_PKG}/${repo}-${ARCH}" | ||||
|     mkdir -p "${CHROOTS_PKG}/${repo}-${ARCH}" | ||||
|     (umask 0022; mkdir -p "${CHROOTS_PKG}/${repo}-${ARCH}") | ||||
|     setarch "${ARCH}" mkchroot \ | ||||
|         -C "${pacman_conf}" \ | ||||
|         -M "${makepkg_conf}" \ | ||||
|   | ||||
| @@ -14,6 +14,8 @@ | ||||
|  | ||||
| . @libdir@/artools/util-pkg.sh | ||||
|  | ||||
| prepare_artools | ||||
|  | ||||
| patch_pkg(){ | ||||
|     local pkg="$1" | ||||
|     case $pkg in | ||||
|   | ||||
| @@ -14,6 +14,8 @@ | ||||
|  | ||||
| . @libdir@/artools/util-pkg.sh | ||||
|  | ||||
| prepare_artools | ||||
|  | ||||
| get_path(){ | ||||
|     local repo="$1" pkg=trunk/PKGBUILD | ||||
|     if [[ $repo != trunk ]]; then | ||||
|   | ||||
| @@ -14,6 +14,8 @@ | ||||
|  | ||||
| . @libdir@/artools/util-pkg.sh | ||||
|  | ||||
| prepare_artools | ||||
|  | ||||
| compare(){ | ||||
|     local pkgpath="$1" group="$2" | ||||
|     local pkg=${pkgpath##*/} | ||||
|   | ||||
| @@ -14,6 +14,8 @@ | ||||
|  | ||||
| . @libdir@/artools/util-pkg.sh | ||||
|  | ||||
| prepare_artools | ||||
|  | ||||
| find_cached_pkgfile() { | ||||
|     local searchdirs=("$PKGDEST" "$PWD") results=() | ||||
|     local pkg="$1" | ||||
|   | ||||
| @@ -12,7 +12,6 @@ | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| # GNU General Public License for more details. | ||||
|  | ||||
| . @libdir@/artools/util-base.sh | ||||
| . @libdir@/artools/util-pkg.sh | ||||
|  | ||||
| set -e | ||||
|   | ||||
| @@ -398,13 +398,27 @@ if (( ret != 0 )); then | ||||
| else | ||||
|     if (( run_checkpkg )); then | ||||
|         msg "Running checkpkg" | ||||
|         msg2 "Downloading current versions" | ||||
|         if pacman --noconfirm -Swdd --logfile /dev/null "${pkgnames[@]}"; then | ||||
|             msg2 "Checking packages" | ||||
|             sudo -u "$makepkg_user" checkpkg --rmdir --warn | ||||
|         else | ||||
|             warning "Skipped checkpkg due to missing packages" | ||||
|         # sync off-site databases for up-to-date queries | ||||
|         trap 'rm -rf $dbpath; cleanup' EXIT INT TERM QUIT | ||||
|         dbpath=$(mktemp -d --tmpdir makechrootpkg-database.XXXXXXXXXX) | ||||
|         mkdir -p "$dbpath" | ||||
|         pacman -Sy --dbpath "$dbpath" --logfile /dev/null | ||||
|  | ||||
|         # query current package locations | ||||
|         remotepkgs=($(pacman -Sddp --dbpath "$dbpath" --logfile /dev/null "${pkgnames[@]}")) | ||||
|         if (( $? )); then | ||||
|             warning "Skipped checkpkg due to missing repo packages" | ||||
|             exit 0 | ||||
|         fi | ||||
|         # download package files if any non-local location exists | ||||
|         for remotepkg in "${remotepkgs[@]}"; do | ||||
|             [[ $remotepkg == file://* ]] && continue | ||||
|             msg2 "Downloading current versions" | ||||
|             pacman --noconfirm -Swdd --dbpath "$dbpath" --logfile /dev/null "${pkgnames[@]}" | ||||
|             break | ||||
|         done | ||||
|         msg2 "Checking packages" | ||||
|         sudo -u "$makepkg_user" checkpkg --rmdir --warn | ||||
|     fi | ||||
|     true | ||||
| fi | ||||
|   | ||||
| @@ -146,7 +146,7 @@ run_hook() { | ||||
|  | ||||
|     lower_dir='' | ||||
|     live_root="/run/artix" | ||||
|     bootmnt="/run/bootmnt" | ||||
|     bootmnt="${live_root}/bootmnt" | ||||
|     overlay_root="${live_root}/overlay_root" | ||||
|     cow="${live_root}/cowspace" | ||||
|     cp2ram="${live_root}/copytoram" | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
| # export LC_MESSAGES=C | ||||
| export LANG=C | ||||
|  | ||||
| if [[ -t 2 ]]; then | ||||
| if [[ -t 2 && "$TERM" != dumb ]]; then | ||||
|     colorize | ||||
| else | ||||
|     declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW='' | ||||
|   | ||||
| @@ -167,7 +167,7 @@ configure_calamares(){ | ||||
|     fi | ||||
| } | ||||
|  | ||||
| configure_image(){ | ||||
| configure_chroot(){ | ||||
|     local fs="$1" | ||||
|     msg "Configuring [%s]" "${fs##*/}" | ||||
|     configure_hosts "$fs" | ||||
| @@ -179,3 +179,40 @@ configure_image(){ | ||||
|     write_live_session_conf > "$fs/etc/artools/live.conf" | ||||
|     msg "Done configuring [%s]" "${fs##*/}" | ||||
| } | ||||
|  | ||||
| clean_up_chroot(){ | ||||
|     local path mnt="$1" | ||||
|     msg2 "Cleaning [%s]" "${mnt##*/}" | ||||
|  | ||||
|     path=$mnt/boot | ||||
|     if [[ -d "$path" ]]; then | ||||
|         find "$path" -name 'initramfs*.img' -delete &> /dev/null | ||||
|     fi | ||||
|     path=$mnt/var/lib/pacman/sync | ||||
|     if [[ -d $path ]];then | ||||
|         find "$path" -type f -delete &> /dev/null | ||||
|     fi | ||||
|     path=$mnt/var/cache/pacman/pkg | ||||
|     if [[ -d $path ]]; then | ||||
|         find "$path" -type f -delete &> /dev/null | ||||
|     fi | ||||
|     path=$mnt/var/log | ||||
|     if [[ -d $path ]]; then | ||||
|         find "$path" -type f -delete &> /dev/null | ||||
|     fi | ||||
|     path=$mnt/var/tmp | ||||
|     if [[ -d $path ]];then | ||||
|         find "$path" -mindepth 1 -delete &> /dev/null | ||||
|     fi | ||||
|     path=$mnt/tmp | ||||
|     if [[ -d $path ]];then | ||||
|         find "$path" -mindepth 1 -delete &> /dev/null | ||||
|     fi | ||||
|     find "$mnt" -name *.pacnew -name *.pacsave -name *.pacorig -delete | ||||
|     if [[ -f "$mnt/boot/grub/grub.cfg" ]]; then | ||||
|         rm $mnt/boot/grub/grub.cfg | ||||
|     fi | ||||
|     if [[ -f "$mnt/etc/machine-id" ]]; then | ||||
|         rm $mnt/etc/machine-id | ||||
|     fi | ||||
| } | ||||
|   | ||||
| @@ -12,6 +12,57 @@ | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| # GNU General Public License for more details. | ||||
|  | ||||
| prepare_boot_extras(){ | ||||
|     local src="$1" dest=${iso_root}/boot | ||||
|  | ||||
|     for u in intel amd;do | ||||
|         cp $src/boot/$u-ucode.img $dest/$u-ucode.img | ||||
|         cp $src/usr/share/licenses/$u-ucode/LICENSE $dest/$u-ucode.LICENSE | ||||
|     done | ||||
|  | ||||
|     cp $src/boot/memtest86+/memtest.bin $dest/memtest | ||||
|     cp $src/usr/share/licenses/common/GPL2/license.txt $dest/memtest.COPYING | ||||
| } | ||||
|  | ||||
| ##################dracut################## | ||||
|  | ||||
| prepare_initramfs_dracut(){ | ||||
|     local mnt="$1" | ||||
|     local kver=$(<"$mnt"/usr/src/linux/version) | ||||
|  | ||||
|     printf "%s\n" 'add_dracutmodules+=" dmsquash-live"' > "$mnt"/etc/dracut.conf.d/50-live.conf | ||||
|  | ||||
|     msg "Starting build: %s" "${kver}" | ||||
|     artools-chroot "$mnt" dracut -fqM /boot/initramfs.img "$kver" | ||||
|     msg "Image generation successful" | ||||
|  | ||||
|     cp "$mnt"/boot/initramfs.img "${iso_root}"/boot/initramfs-"${ARCH}".img | ||||
|  | ||||
|     prepare_boot_extras "$mnt" | ||||
| } | ||||
|  | ||||
| configure_grub_dracut(){ | ||||
|     msg "Configuring grub kernel options ..." | ||||
|     local kopts=( | ||||
|         "root=live:LABEL=${iso_label}" | ||||
|         'rd.live.squashimg=rootfs.img' | ||||
|         'rd.live.image' | ||||
|         'rootflags=auto' | ||||
|     ) | ||||
|     [[ "${PROFILE}" != 'base' ]] && kopts+=("rd.live.join=livefs.img") | ||||
|  | ||||
|     local ro_opts=() | ||||
|     local rw_opts=() | ||||
| #         'rd.writable.fsimg=1' | ||||
|  | ||||
|     sed -e "s|@kopts@|${kopts[*]}|" \ | ||||
|         -e "s|@ro_opts@|${ro_opts[*]}|" \ | ||||
|         -e "s|@rw_opts@|${rw_opts[*]}|" \ | ||||
|         -i ${iso_root}/boot/grub/kernels.cfg | ||||
| } | ||||
|  | ||||
| ############################################# | ||||
|  | ||||
| write_mkinitcpio_conf() { | ||||
|     msg2 "Writing mkinitcpio.conf ..." | ||||
|     local conf="$1/etc/mkinitcpio-artix.conf" | ||||
| @@ -35,18 +86,6 @@ prepare_initcpio(){ | ||||
|     cp /etc/initcpio/artix_shutdown $dest/etc/initcpio | ||||
| } | ||||
|  | ||||
| prepare_boot_extras(){ | ||||
|     local src="$1" dest=${iso_root}/boot | ||||
|  | ||||
|     for u in intel amd;do | ||||
|         cp $src/boot/$u-ucode.img $dest/$u-ucode.img | ||||
|         cp $src/usr/share/licenses/$u-ucode/LICENSE $dest/$u-ucode.LICENSE | ||||
|     done | ||||
|  | ||||
|     cp $src/boot/memtest86+/memtest.bin $dest/memtest | ||||
|     cp $src/usr/share/licenses/common/GPL2/license.txt $dest/memtest.COPYING | ||||
| } | ||||
|  | ||||
| prepare_initramfs(){ | ||||
|     local mnt="$1" | ||||
|  | ||||
| @@ -76,9 +115,10 @@ prepare_initramfs(){ | ||||
| } | ||||
|  | ||||
| configure_grub(){ | ||||
|     local ro_opts=("label=${iso_label}") | ||||
|     local rw_opts=("cow_label=${iso_label}") | ||||
|     local kopts=() | ||||
|     msg "Configuring grub kernel options ..." | ||||
|     local ro_opts=() | ||||
|     local rw_opts=() | ||||
|     local kopts=("label=${iso_label}") | ||||
|  | ||||
|     [[ "${PROFILE}" != 'base' ]] && kopts+=('overlay=livefs') | ||||
|  | ||||
|   | ||||
| @@ -72,7 +72,6 @@ make_sfs() { | ||||
|         error "The path %s does not exist" "${sfs_in}" | ||||
|         retrun 1 | ||||
|     fi | ||||
|     local timer=$(get_timer) | ||||
|  | ||||
|     mkdir -p ${iso_root}${live_dir} | ||||
|  | ||||
| @@ -100,15 +99,14 @@ make_sfs() { | ||||
|  | ||||
|         mksquashfs "${mksfs_args[@]}" | ||||
|  | ||||
|         make_checksum "${img_name}" | ||||
|         ${persist} && rm -r "${work_dir}/embed" | ||||
|  | ||||
|         if [[ -n ${GPG_KEY} ]];then | ||||
|             make_sig "${img_name}" | ||||
|         if ! ${use_dracut}; then | ||||
|             make_checksum "${img_name}" | ||||
|             if [[ -n ${GPG_KEY} ]];then | ||||
|                 make_sig "${img_name}" | ||||
|             fi | ||||
|         fi | ||||
|  | ||||
|         ${persist} && rm -r "${work_dir}/embed" | ||||
|     fi | ||||
|     show_elapsed_time "${FUNCNAME}" "${timer_start}" | ||||
| } | ||||
|  | ||||
| get_disturl(){ | ||||
| @@ -146,19 +144,3 @@ assemble_iso(){ | ||||
|         ${iso_root}/ | ||||
| } | ||||
|  | ||||
| make_iso() { | ||||
|     msg "Start [Build ISO]" | ||||
|     touch "${iso_root}/.artix" | ||||
|     make_sfs "${work_dir}/rootfs" | ||||
|     [[ -d "${work_dir}/livefs" ]] && make_sfs "${work_dir}/livefs" | ||||
|  | ||||
|     msg "Making bootable image" | ||||
|     # Sanity checks | ||||
|     [[ ! -d "${iso_root}" ]] && return 1 | ||||
|     if [[ -f "${iso_dir}/${iso_file}" ]]; then | ||||
|         msg2 "Removing existing bootable image..." | ||||
|         rm -rf "${iso_dir}/${iso_file}" | ||||
|     fi | ||||
|     assemble_iso | ||||
|     msg "Done [Build ISO]" | ||||
| } | ||||
|   | ||||
| @@ -37,7 +37,7 @@ track_fs() { | ||||
|     mount "$@" && FS_ACTIVE_MOUNTS=("$5" "${FS_ACTIVE_MOUNTS[@]}") | ||||
| } | ||||
|  | ||||
| mount_overlay(){ | ||||
| mount_overlayfs(){ | ||||
|     FS_ACTIVE_MOUNTS=() | ||||
|     local lower= upper="$1" work="$2" | ||||
|     mkdir -p "${mnt_dir}/work" | ||||
| @@ -52,7 +52,7 @@ mount_overlay(){ | ||||
|     track_fs -t overlay overlay -olowerdir="$lower",upperdir="$upper",workdir="${mnt_dir}/work" "$upper" | ||||
| } | ||||
|  | ||||
| umount_overlay(){ | ||||
| umount_overlayfs(){ | ||||
|     if [[ -n ${FS_ACTIVE_MOUNTS[@]} ]];then | ||||
|         info "overlayfs umount: [%s]" "${FS_ACTIVE_MOUNTS[@]}" | ||||
|         umount "${FS_ACTIVE_MOUNTS[@]}" | ||||
|   | ||||
| @@ -62,43 +62,6 @@ copy_overlay(){ | ||||
|     fi | ||||
| } | ||||
|  | ||||
| clean_up_image(){ | ||||
|     local path mnt="$1" | ||||
|     msg2 "Cleaning [%s]" "${mnt##*/}" | ||||
|  | ||||
|     path=$mnt/boot | ||||
|     if [[ -d "$path" ]]; then | ||||
|         find "$path" -name 'initramfs*.img' -delete &> /dev/null | ||||
|     fi | ||||
|     path=$mnt/var/lib/pacman/sync | ||||
|     if [[ -d $path ]];then | ||||
|         find "$path" -type f -delete &> /dev/null | ||||
|     fi | ||||
|     path=$mnt/var/cache/pacman/pkg | ||||
|     if [[ -d $path ]]; then | ||||
|         find "$path" -type f -delete &> /dev/null | ||||
|     fi | ||||
|     path=$mnt/var/log | ||||
|     if [[ -d $path ]]; then | ||||
|         find "$path" -type f -delete &> /dev/null | ||||
|     fi | ||||
|     path=$mnt/var/tmp | ||||
|     if [[ -d $path ]];then | ||||
|         find "$path" -mindepth 1 -delete &> /dev/null | ||||
|     fi | ||||
|     path=$mnt/tmp | ||||
|     if [[ -d $path ]];then | ||||
|         find "$path" -mindepth 1 -delete &> /dev/null | ||||
|     fi | ||||
|     find "$mnt" -name *.pacnew -name *.pacsave -name *.pacorig -delete | ||||
|     if [[ -f "$mnt/boot/grub/grub.cfg" ]]; then | ||||
|         rm $mnt/boot/grub/grub.cfg | ||||
|     fi | ||||
|     if [[ -f "$mnt/etc/machine-id" ]]; then | ||||
|         rm $mnt/etc/machine-id | ||||
|     fi | ||||
| } | ||||
|  | ||||
| make_rootfs() { | ||||
|     if [[ ! -e ${work_dir}/rootfs.lock ]]; then | ||||
|         msg "Prepare [Base installation] (rootfs)" | ||||
| @@ -110,9 +73,9 @@ make_rootfs() { | ||||
|  | ||||
|         copy_overlay "${ROOT_OVERLAY}" "${rootfs}" | ||||
|  | ||||
|         [[ -z ${LIVE_LIST} ]] && configure_image "${rootfs}" | ||||
|         [[ -z ${LIVE_LIST} ]] && configure_chroot "${rootfs}" | ||||
|  | ||||
|         clean_up_image "${rootfs}" | ||||
|         clean_up_chroot "${rootfs}" | ||||
|  | ||||
|         : > ${work_dir}/rootfs.lock | ||||
|  | ||||
| @@ -127,17 +90,17 @@ make_livefs() { | ||||
|  | ||||
|         prepare_dir "${livefs}" | ||||
|  | ||||
|         mount_overlay "${livefs}" "${work_dir}" | ||||
|         mount_overlayfs "${livefs}" "${work_dir}" | ||||
|  | ||||
|         basestrap "${basestrap_args[@]}" "${livefs}" "${packages[@]}" | ||||
|  | ||||
|         copy_overlay "${LIVE_OVERLAY}" "${livefs}" | ||||
|  | ||||
|         configure_image "${livefs}" | ||||
|         configure_chroot "${livefs}" | ||||
|  | ||||
|         umount_overlay | ||||
|         umount_overlayfs | ||||
|  | ||||
|         clean_up_image "${livefs}" | ||||
|         clean_up_chroot "${livefs}" | ||||
|  | ||||
|         : > ${work_dir}/livefs.lock | ||||
|  | ||||
| @@ -155,11 +118,15 @@ make_bootfs() { | ||||
|  | ||||
|         local bootfs="${work_dir}/bootfs" | ||||
|  | ||||
|         mount_overlay "${bootfs}" "${work_dir}" | ||||
|         mount_overlayfs "${bootfs}" "${work_dir}" | ||||
|  | ||||
|         prepare_initramfs "${bootfs}" | ||||
|         if ${use_dracut}; then | ||||
|             prepare_initramfs_dracut "${bootfs}" | ||||
|         else | ||||
|             prepare_initramfs "${bootfs}" | ||||
|         fi | ||||
|  | ||||
|         umount_overlay | ||||
|         umount_overlayfs | ||||
|  | ||||
|         rm -R ${bootfs} | ||||
|         : > ${work_dir}/bootfs.lock | ||||
| @@ -176,30 +143,13 @@ make_grub(){ | ||||
|  | ||||
|         prepare_grub "${work_dir}/rootfs" "$layer" | ||||
|  | ||||
|         configure_grub | ||||
|         if ${use_dracut}; then | ||||
|             configure_grub_dracut | ||||
|         else | ||||
|             configure_grub | ||||
|         fi | ||||
|  | ||||
|         : > ${work_dir}/grub.lock | ||||
|         msg "Done [/iso/boot/grub]" | ||||
|     fi | ||||
| } | ||||
|  | ||||
| compress_images(){ | ||||
|     local timer=$(get_timer) | ||||
|     run_safe "make_iso" | ||||
|     chown -R "${OWNER}:$(id --group ${OWNER})" "${iso_dir}" | ||||
|     show_elapsed_time "${FUNCNAME}" "${timer}" | ||||
| } | ||||
|  | ||||
| prepare_images(){ | ||||
|     local timer=$(get_timer) | ||||
|     load_pkgs "${ROOT_LIST}" "${INITSYS}" | ||||
|     run_safe "make_rootfs" | ||||
|     if [[ -n ${LIVE_LIST} ]]; then | ||||
|         load_pkgs "${LIVE_LIST}" "${INITSYS}" | ||||
|         run_safe "make_livefs" | ||||
|     fi | ||||
|     run_safe "make_bootfs" | ||||
|     run_safe "make_grub" | ||||
|  | ||||
|     show_elapsed_time "${FUNCNAME}" "${timer}" | ||||
| } | ||||
|   | ||||
| @@ -12,6 +12,8 @@ | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| # GNU General Public License for more details. | ||||
|  | ||||
| shopt -s extglob | ||||
|  | ||||
| get_compliant_name(){ | ||||
|     local gitname="$1" | ||||
|     case $gitname in | ||||
| @@ -145,7 +147,7 @@ find_cached_package() { | ||||
|     for dir in "${searchdirs[@]}"; do | ||||
|         [[ -d $dir ]] || continue | ||||
|  | ||||
|         for pkg in "$dir"/*.pkg.tar.?z; do | ||||
|         for pkg in "$dir"/*.pkg.tar?(.!(sig|*.*)); do | ||||
|             [[ -f $pkg ]] || continue | ||||
|  | ||||
|             # avoid adding duplicates of the same inode | ||||
| @@ -155,7 +157,7 @@ find_cached_package() { | ||||
|  | ||||
|             # split apart package filename into parts | ||||
|             pkgbasename=${pkg##*/} | ||||
|             pkgbasename=${pkgbasename%.pkg.tar.?z} | ||||
|             pkgbasename=${pkgbasename%.pkg.tar*} | ||||
|  | ||||
|             arch=${pkgbasename##*-} | ||||
|             pkgbasename=${pkgbasename%-"$arch"} | ||||
|   | ||||
| @@ -34,7 +34,10 @@ for baselib in ${LIBDIR}/base/*.sh; do | ||||
|     . $baselib | ||||
| done | ||||
|  | ||||
| prepare_dir "${USER_CONF_DIR}" | ||||
| prepare_artools(){ | ||||
|     prepare_dir "${WORKSPACE_DIR}" | ||||
|     prepare_dir "${USER_CONF_DIR}" | ||||
| } | ||||
|  | ||||
| load_base_config(){ | ||||
|  | ||||
| @@ -50,8 +53,6 @@ load_base_config(){ | ||||
|  | ||||
|     WORKSPACE_DIR=${WORKSPACE_DIR:-"/home/${OWNER}/artools-workspace"} | ||||
|  | ||||
|     prepare_dir "${WORKSPACE_DIR}" | ||||
|  | ||||
|     return 0 | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -30,8 +30,6 @@ load_iso_config(){ | ||||
|  | ||||
|     ISO_POOL=${ISO_POOL:-"${WORKSPACE_DIR}/iso"} | ||||
|  | ||||
|     prepare_dir "${ISO_POOL}" | ||||
|  | ||||
|     PROFILE='base' | ||||
|  | ||||
|     ISO_VERSION=${ISO_VERSION:-"$(date +%Y%m%d)"} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user