├── .gitignore ├── Makefile ├── README.md ├── bin ├── artools-chroot.in ├── basestrap.in ├── buildiso.in ├── buildpkg.in ├── buildtree.in ├── checkpkg.in ├── chroot-run.in ├── commitpkg.in ├── deployiso.in ├── deploypkg.in ├── find-libdeps.in ├── finddeps.in ├── fstabgen.in ├── lddd.in ├── mkchroot.in ├── mkchrootpkg.in ├── mkpkgclean.in └── signfile.in ├── data ├── artools.conf ├── makepkg.conf ├── mkinitcpio.conf ├── pacman-default.conf ├── pacman-goblins.conf ├── pacman-gremlins.conf ├── pacman-lib32-goblins.conf ├── pacman-lib32-gremlins.conf ├── pacman-lib32.conf └── patches │ └── artix-bash.patch ├── initcpio ├── Makefile ├── hooks │ ├── artix │ ├── artix_loop_mnt │ ├── artix_pxe_common │ ├── artix_pxe_http │ ├── artix_pxe_nbd │ ├── artix_pxe_nfs │ └── artix_shutdown ├── install │ ├── artix │ ├── artix_kms │ ├── artix_loop_mnt │ ├── artix_pxe_common │ ├── artix_pxe_http │ ├── artix_pxe_nbd │ ├── artix_pxe_nfs │ └── artix_shutdown └── script │ └── artix_shutdown └── lib ├── util-chroot.sh ├── util-fstab.sh ├── util-iso-grub.sh ├── util-iso-profile.sh ├── util-iso-publish.sh ├── util-iso-yaml.sh ├── util-iso.sh ├── util-mount.sh ├── util-msg.sh ├── util-pkg.sh └── util.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.tar.gz 3 | *.tar.xz 4 | .kateproject.d 5 | data/schemas/*.conf 6 | .project 7 | iso-profiles 8 | live-services 9 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VERSION=0.8 2 | 3 | CHROOT_VERSION=0.8 4 | 5 | TOOLS = artools 6 | ifdef PREFIX 7 | PREFIX = /usr/local 8 | endif 9 | SYSCONFDIR = /etc 10 | BINDIR = $(PREFIX)/bin 11 | LIBDIR = $(PREFIX)/lib 12 | DATADIR = $(PREFIX)/share 13 | 14 | DIRMODE = -dm0755 15 | FILEMODE = -m0644 16 | MODE = -m0755 17 | 18 | LN = ln -sf 19 | RM = rm -f 20 | RMD = rm -fr --one-file-system 21 | M4 = m4 -P 22 | CHMODAW = chmod a-w 23 | CHMODX = chmod +x 24 | 25 | ifdef WITH-PKG 26 | WITH-PKG = no 27 | else 28 | WITH-PKG = yes 29 | endif 30 | ifdef WITH-ISO 31 | WITH-ISO = no 32 | else 33 | WITH-ISO = yes 34 | endif 35 | 36 | CPIODIR = $(SYSCONFDIR)/initcpio 37 | 38 | SYSCONF = \ 39 | data/artools.conf 40 | 41 | BIN_BASE = \ 42 | bin/mkchroot \ 43 | bin/basestrap \ 44 | bin/artools-chroot \ 45 | bin/fstabgen \ 46 | bin/signfile \ 47 | bin/chroot-run 48 | 49 | LIBS_BASE = \ 50 | lib/util.sh \ 51 | lib/util-msg.sh \ 52 | lib/util-mount.sh \ 53 | lib/util-chroot.sh \ 54 | lib/util-fstab.sh 55 | 56 | SHARED_BASE = \ 57 | $(wildcard data/pacman*.conf) 58 | 59 | BIN_PKG = \ 60 | bin/checkpkg \ 61 | bin/lddd \ 62 | bin/finddeps \ 63 | bin/find-libdeps \ 64 | bin/mkchrootpkg \ 65 | bin/buildpkg \ 66 | bin/buildtree \ 67 | bin/deploypkg \ 68 | bin/commitpkg \ 69 | bin/mkpkgclean 70 | 71 | LIBS_PKG = \ 72 | $(wildcard lib/util-pkg*.sh) 73 | 74 | SHARED_PKG = \ 75 | data/makepkg.conf 76 | 77 | PATCHES = \ 78 | $(wildcard data/patches/*.patch) 79 | 80 | COMMITPKG_SYMS = \ 81 | extrapkg \ 82 | corepkg \ 83 | testingpkg \ 84 | stagingpkg \ 85 | communitypkg \ 86 | community-testingpkg \ 87 | community-stagingpkg \ 88 | multilibpkg \ 89 | multilib-testingpkg \ 90 | multilib-stagingpkg 91 | 92 | BIN_ISO = \ 93 | bin/buildiso \ 94 | bin/deployiso 95 | 96 | BIN_ISO_SYMS = \ 97 | buildiso-gremlins \ 98 | buildiso-goblins 99 | 100 | LIBS_ISO = \ 101 | $(wildcard lib/util-iso*.sh) 102 | 103 | SHARED_ISO = \ 104 | data/mkinitcpio.conf 105 | 106 | ifeq ($(WITH-PKG),yes) 107 | 108 | all: $(BIN_PKG) 109 | 110 | endif 111 | 112 | ifeq ($(WITH-ISO),yes) 113 | 114 | all: $(BIN_ISO) 115 | 116 | endif 117 | 118 | all: $(BIN_BASE) 119 | 120 | EDIT = sed -e "s|@datadir[@]|$(DATADIR)/$(TOOLS)|g" \ 121 | -e "s|@sysconfdir[@]|$(SYSCONFDIR)/$(TOOLS)|g" \ 122 | -e "s|@libdir[@]|$(LIBDIR)/$(TOOLS)|g" \ 123 | -e "s|@version@|$(VERSION)|" \ 124 | -e "s|@chroot_version@|$(CHROOT_VERSION)|" 125 | 126 | %: %.in Makefile 127 | @echo "GEN $@" 128 | @$(RM) "$@" 129 | @$(M4) $@.in | $(EDIT) >$@ 130 | @$(CHMODAW) "$@" 131 | @$(CHMODX) "$@" 132 | 133 | clean: 134 | $(RM) $(BIN_BASE) $(BIN_PKG) $(BIN_ISO) 135 | 136 | install_base: 137 | install $(DIRMODE) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS) 138 | install $(FILEMODE) $(SYSCONF) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS) 139 | 140 | install $(DIRMODE) $(DESTDIR)$(BINDIR) 141 | install $(MODE) $(BIN_BASE) $(DESTDIR)$(BINDIR) 142 | 143 | install $(DIRMODE) $(DESTDIR)$(LIBDIR)/$(TOOLS) 144 | install $(FILEMODE) $(LIBS_BASE) $(DESTDIR)$(LIBDIR)/$(TOOLS) 145 | 146 | install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS) 147 | install $(FILEMODE) $(SHARED_BASE) $(DESTDIR)$(DATADIR)/$(TOOLS) 148 | 149 | install_pkg: 150 | install $(DIRMODE) $(DESTDIR)$(BINDIR) 151 | install $(MODE) $(BIN_PKG) $(DESTDIR)$(BINDIR) 152 | 153 | $(LN) find-libdeps $(DESTDIR)$(BINDIR)/find-libprovides 154 | 155 | for l in $(COMMITPKG_SYMS); do $(LN) commitpkg $(DESTDIR)$(BINDIR)/$$l; done 156 | 157 | install $(DIRMODE) $(DESTDIR)$(LIBDIR)/$(TOOLS) 158 | install $(FILEMODE) $(LIBS_PKG) $(DESTDIR)$(LIBDIR)/$(TOOLS) 159 | 160 | install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS) 161 | install $(FILEMODE) $(SHARED_PKG) $(DESTDIR)$(DATADIR)/$(TOOLS) 162 | 163 | install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS)/patches 164 | install $(FILEMODE) $(PATCHES) $(DESTDIR)$(DATADIR)/$(TOOLS)/patches 165 | install_cpio: 166 | +make CPIODIR=$(CPIODIR) DESTDIR=$(DESTDIR) -C initcpio install 167 | 168 | install_iso: install_cpio 169 | install $(DIRMODE) $(DESTDIR)$(BINDIR) 170 | install $(MODE) $(BIN_ISO) $(DESTDIR)$(BINDIR) 171 | 172 | for l in $(BIN_ISO_SYMS); do $(LN) buildiso $(DESTDIR)$(BINDIR)/$$l; done 173 | 174 | install $(DIRMODE) $(DESTDIR)$(LIBDIR)/$(TOOLS) 175 | install $(FILEMODE) $(LIBS_ISO) $(DESTDIR)$(LIBDIR)/$(TOOLS) 176 | 177 | install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS) 178 | install $(FILEMODE) $(SHARED_ISO) $(DESTDIR)$(DATADIR)/$(TOOLS) 179 | 180 | uninstall_base: 181 | for f in $(notdir $(SYSCONF)); do $(RM) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)/$$f; done 182 | for f in $(notdir $(BIN_BASE)); do $(RM) $(DESTDIR)$(BINDIR)/$$f; done 183 | for f in $(notdir $(LIBS_BASE)); do $(RM) $(DESTDIR)$(LIBDIR)/$(TOOLS)/$$f; done 184 | for f in $(notdir $(SHARED_BASE)); do $(RM) $(DESTDIR)$(DATADIR)/$(TOOLS)/$$f; done 185 | $(RMD) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS) 186 | $(RMD) $(DESTDIR)$(LIBDIR)/$(TOOLS) 187 | $(RMD) $(DESTDIR)$(DATADIR)/$(TOOLS) 188 | 189 | uninstall_pkg: 190 | for f in $(notdir $(BIN_PKG)); do $(RM) $(DESTDIR)$(BINDIR)/$$f; done 191 | $(RM) $(DESTDIR)$(BINDIR)/find-libprovides 192 | for l in $(COMMITPKG_SYMS); do $(RM) $(DESTDIR)$(BINDIR)/$$l; done 193 | for f in $(notdir $(LIBS_PKG)); do $(RM) $(DESTDIR)$(LIBDIR)/$(TOOLS)/$$f; done 194 | for f in $(notdir $(PATCHES)); do $(RM) $(DESTDIR)$(DATADIR)/$(TOOLS)/patches/$$f; done 195 | for f in $(notdir $(SHARED_PKG)); do $(RM) $(DESTDIR)$(DATADIR)/$(TOOLS)/$$f; done 196 | 197 | uninstall_cpio: 198 | +make CPIODIR=$(CPIODIR) DESTDIR=$(DESTDIR) -C initcpio uninstall 199 | 200 | uninstall_iso: uninstall_cpio 201 | for f in $(notdir $(BIN_ISO)); do $(RM) $(DESTDIR)$(BINDIR)/$$f; done 202 | for l in $(notdir $(BIN_ISO_SYMS)); do $(RM) $(DESTDIR)$(BINDIR)/$$l; done 203 | for f in $(notdir $(LIBS_ISO)); do $(RM) $(DESTDIR)$(LIBDIR)/$(TOOLS)/$$f; done 204 | for f in $(notdir $(SHARED_ISO)); do $(RM) $(DESTDIR)$(DATADIR)/$(TOOLS)/$$f; done 205 | 206 | ifeq ($(WITH-PKG),yes) 207 | 208 | install: install_pkg 209 | 210 | uninstall: uninstall_pkg 211 | 212 | endif 213 | 214 | ifeq ($(WITH-ISO),yes) 215 | 216 | install: install_iso 217 | 218 | uninstall: uninstall_iso 219 | 220 | endif 221 | 222 | install: install_base 223 | 224 | uninstall: uninstall_base 225 | 226 | dist: 227 | git archive --format=tar --prefix=$(TOOLS)-$(VERSION)/ $(VERSION) | gzip -9 > $(TOOLS)-$(VERSION).tar.gz 228 | gpg --detach-sign --use-agent $(TOOLS)-$(VERSION).tar.gz 229 | 230 | .PHONY: all clean install uninstall dist 231 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | artools 2 | ============= 3 | 4 | #### Make flags 5 | 6 | 7 | * PREFIX=/usr/local (default if defined) 8 | * SYSCONFDIR=/etc 9 | * WITH-PKG=yes 10 | * WITH-ISO=yes 11 | 12 | 13 | #### Dependencies 14 | 15 | ##### Buildtime: 16 | 17 | * make 18 | * git 19 | * m4 20 | 21 | ##### Runtime: 22 | 23 | - base: 24 | 25 | * openssh 26 | * rsync 27 | * haveged 28 | * os-prober 29 | * gnupg 30 | * pacman 31 | 32 | - pkg: 33 | 34 | * namcap 35 | * git 36 | 37 | - iso: 38 | * dosfstools 39 | * libisoburn 40 | * squashfs-tools 41 | * mkinitcpio 42 | * mktorrent 43 | * grub 44 | 45 | #### Configuration 46 | 47 | artools.conf is the central configuration file for artools. 48 | By default, the config is installed in 49 | 50 | /etc/artools/artools.conf 51 | 52 | A user artools.conf can be placed in 53 | 54 | $HOME/.config/artools/artools.conf 55 | 56 | 57 | If the userconfig is present, artools will load the userconfig values, however, if variables have been set in the systemwide 58 | 59 | These values take precedence over the userconfig. 60 | Best practise is to leave systemwide file untouched. 61 | By default it is commented and shows just initialization values done in code. 62 | 63 | Tools configuration is done in artools.conf or by args. 64 | Specifying args will override artools.conf settings. 65 | 66 | Both, pacman.conf and makepkg.conf for chroots are loaded from 67 | 68 | /usr/share/artools/{makepkg,pacman-*}.conf 69 | 70 | and can be overridden dropping them in 71 | 72 | $HOME/.config/artools/ 73 | -------------------------------------------------------------------------------- /bin/artools-chroot.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | shopt -s extglob 15 | 16 | LIBDIR='@libdir@' 17 | SYSCONFDIR='@sysconfdir@' 18 | 19 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 20 | import ${LIBDIR}/util.sh 21 | import ${LIBDIR}/util-mount.sh 22 | 23 | display_settings(){ 24 | show_version 25 | show_config 26 | 27 | msg "ARGS:" 28 | msg2 "automount: %s" "${automount}" 29 | msg2 "run_args: %s" "${run_args[*]}" 30 | 31 | msg "PATHS:" 32 | msg2 "chrootdir: %s" "${chrootdir}" 33 | } 34 | 35 | load_user_info 36 | 37 | load_config "${AT_USERCONFDIR}/artools.conf" || load_config "${SYSCONFDIR}/artools.conf" 38 | 39 | automount=false 40 | pretend=false 41 | 42 | usage() { 43 | echo "usage: ${0##*/} -a [or] ${0##*/} chroot-dir [command]" 44 | echo ' -a Automount detected linux system' 45 | echo ' -q Query settings and pretend' 46 | echo ' -h Print this help message' 47 | echo '' 48 | echo " If 'command' is unspecified, ${0##*/} will launch /bin/sh." 49 | echo '' 50 | echo " If 'automount' is true, ${0##*/} will launch /bin/bash" 51 | echo " and ${chrootdir}." 52 | echo '' 53 | echo '' 54 | exit $1 55 | } 56 | 57 | orig_argv=("$0" "$@") 58 | 59 | opts=':haq' 60 | 61 | while getopts ${opts} arg; do 62 | case "${arg}" in 63 | a) automount=true ;; 64 | q) pretend=true ;; 65 | h|?) usage 0 ;; 66 | *) echo "invalid argument ${arg}"; usage 1 ;; 67 | esac 68 | done 69 | shift $(( OPTIND - 1 )) 70 | 71 | check_root 72 | 73 | if ${automount};then 74 | chrootdir=/mnt 75 | run_args=/bin/bash 76 | 77 | ${pretend} && display_settings && exit 1 78 | 79 | select_os "${chrootdir}" 80 | else 81 | chrootdir=$1 82 | shift 83 | run_args="$@" 84 | 85 | [[ -d ${chrootdir} ]] || die "Can't create chroot on non-directory %s" "${chrootdir}" 86 | 87 | ${pretend} && display_settings && exit 1 88 | 89 | chroot_api_mount "${chrootdir}" || die "failed to setup API filesystems in chroot %s" "${chrootdir}" 90 | chroot_add_resolv_conf "${chrootdir}" 91 | fi 92 | 93 | SHELL=/bin/sh unshare --fork --pid chroot "${chrootdir}" ${run_args[*]} 94 | -------------------------------------------------------------------------------- /bin/basestrap.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Assumptions: 5 | # 1) User has partitioned, formatted, and mounted partitions on /mnt 6 | # 2) Network is functional 7 | # 3) Arguments passed to the script are valid pacman targets 8 | # 4) A valid mirror appears in /etc/pacman.d/mirrorlist 9 | # 10 | 11 | version=@version@ 12 | 13 | shopt -s extglob 14 | 15 | DATADIR='@datadir@' 16 | LIBDIR='@libdir@' 17 | 18 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 19 | import ${LIBDIR}/util.sh 20 | import ${LIBDIR}/util-mount.sh 21 | import ${LIBDIR}/util-chroot.sh 22 | 23 | copy_mirrorlist(){ 24 | cp -a /etc/pacman.d/mirrorlist "$1/etc/pacman.d/" 25 | } 26 | 27 | copy_keyring(){ 28 | if [[ -d /etc/pacman.d/gnupg ]] && [[ ! -d $1/etc/pacman.d/gnupg ]]; then 29 | cp -a /etc/pacman.d/gnupg "$1/etc/pacman.d/" 30 | fi 31 | } 32 | 33 | create_min_fs(){ 34 | msg "Creating install root at %s" "$1" 35 | mkdir -m 0755 -p $1/var/{cache/pacman/pkg,lib/pacman,log} $1/{dev,etc} 36 | mkdir -m 1777 -p $1/{tmp,run} 37 | mkdir -m 0555 -p $1/{sys,proc} 38 | # if [[ ! -f $1/etc/machine-id ]];then 39 | # touch $1/etc/machine-id 40 | # fi 41 | } 42 | 43 | newroot=/mnt 44 | 45 | hostcache=false 46 | copykeyring=true 47 | copymirrorlist=true 48 | directory=false 49 | interactive=false 50 | 51 | usage() { 52 | echo "usage: ${0##*/} [options] root [packages...]" 53 | echo " -C Use an alternate config file for pacman" 54 | echo " -c Use the package cache on the host, rather than the target" 55 | echo " -G Avoid copying the host's pacman keyring to the target" 56 | echo " -i Avoid auto-confirmation of package selections" 57 | echo " -M Avoid copying the host's mirrorlist to the target" 58 | echo " -h Print this help message" 59 | echo '' 60 | echo ' basestrap installs packages to the specified new root directory.' 61 | echo ' If no packages are given, basestrap defaults to the "base" group.' 62 | echo '' 63 | echo '' 64 | exit $1 65 | } 66 | 67 | orig_argv=("$0" "$@") 68 | 69 | opts=':C:cGiM' 70 | 71 | while getopts ${opts} arg; do 72 | case "${arg}" in 73 | C) pacman_conf=$OPTARG ;; 74 | c) hostcache=true ;; 75 | i) interactive=true ;; 76 | G) copykeyring=false ;; 77 | M) copymirrorlist=false ;; 78 | :) echo "invalid argument ${arg}:$OPTARG"; usage 1;; 79 | ?) usage 0 ;; 80 | esac 81 | done 82 | shift $(( OPTIND - 1 )) 83 | 84 | check_root 85 | 86 | (( $# )) || die "No root directory specified" 87 | newroot=$1; shift 88 | pacman_args=("${@:-base}") 89 | 90 | ${hostcache} || pacman_args+=(--cachedir="$newroot/var/cache/pacman/pkg") 91 | 92 | ${interactive} || pacman_args+=(--noconfirm) 93 | 94 | [[ -n $pacman_conf ]] && pacman_args+=(--config="$pacman_conf") 95 | 96 | [[ -d $newroot ]] || die "%s is not a directory" "$newroot" 97 | 98 | # create obligatory directories 99 | create_min_fs "$newroot" 100 | 101 | # mount API filesystems 102 | chroot_api_mount "$newroot" || die "failed to setup API filesystems in new root" 103 | 104 | msg2 'Installing packages to %s' "$newroot" 105 | if ! pacman -r "$newroot" -Sy "${pacman_args[@]}"; then 106 | die 'Failed to install packages to new root' 107 | fi 108 | 109 | if ${copykeyring};then 110 | copy_keyring "$newroot" 111 | fi 112 | 113 | if ${copymirrorlist};then 114 | copy_mirrorlist "$newroot" 115 | fi 116 | -------------------------------------------------------------------------------- /bin/buildiso.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | DATADIR='@datadir@' 16 | SYSCONFDIR='@sysconfdir@' 17 | 18 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 19 | import ${LIBDIR}/util.sh 20 | import ${LIBDIR}/util-iso.sh 21 | 22 | prepare_build(){ 23 | timer_start=$(get_timer) 24 | 25 | load_profile "${profile}" 26 | 27 | local pacman_conf pac_file="pacman-default.conf" 28 | 29 | case "${stablility}" in 30 | 'gremlins'|'goblins') pac_file="pacman-${stablility}.conf" ;; 31 | esac 32 | 33 | pacman_conf="${DATADIR}/$pac_file" 34 | [[ -f $AT_USERCONFDIR/$pac_file ]] && pacman_conf="$AT_USERCONFDIR/$pac_file" 35 | 36 | iso_file=$(gen_iso_fn).iso 37 | 38 | mkchroot_args+=(-C ${pacman_conf}) 39 | work_dir=${chroots_iso}/${profile}/${target_arch} 40 | 41 | iso_dir="${iso_pool}/${profile}" 42 | 43 | iso_root=${chroots_iso}/${profile}/iso 44 | mnt_dir=${chroots_iso}/${profile}/mnt 45 | prepare_dir "${mnt_dir}" 46 | prepare_dir "${iso_dir}" 47 | } 48 | 49 | show_profile(){ 50 | msg2 "iso_file: %s" "${iso_file}" 51 | if ${verbose};then 52 | msg2 "autologin: %s" "${autologin}" 53 | 54 | msg2 "hostname: %s" "${hostname}" 55 | msg2 "username: %s" "${username}" 56 | msg2 "password: %s" "${password}" 57 | msg2 "addgroups: %s" "${addgroups}" 58 | 59 | msg2 "services_live: %s" "${services_live[*]}" 60 | msg2 "services: %s" "${services[*]}" 61 | fi 62 | } 63 | 64 | display_settings(){ 65 | show_version 66 | show_config 67 | 68 | msg "OPTIONS:" 69 | msg2 "profile: %s" "${profile}" 70 | msg2 "initsys: %s" "${initsys}" 71 | [[ -n ${gpgkey} ]] && msg2 "gpgkey: %s" "${gpgkey}" 72 | msg2 "stablility: %s" "${stablility}" 73 | 74 | msg "ARGS:" 75 | msg2 "clean_first: %s" "${clean_first}" 76 | msg2 "images_only: %s" "${images_only}" 77 | msg2 "iso_only: %s" "${iso_only}" 78 | msg2 "persist: %s" "${persist}" 79 | 80 | msg "ISO SETTINGS:" 81 | msg2 "iso_version: %s" "${iso_version}" 82 | 83 | msg "BUILD:" 84 | show_profile 85 | } 86 | 87 | build(){ 88 | msg "Start building [%s]" "${profile}" 89 | if ${clean_first};then 90 | for copy in "${work_dir}"/*; do 91 | [[ -d $copy ]] || continue 92 | msg2 "Deleting chroot copy '%s'..." "$(basename "${copy}")" 93 | 94 | lock 9 "$copy.lock" "Locking chroot copy '%s'" "$copy" 95 | 96 | subvolume_delete_recursive "${copy}" 97 | rm -rf --one-file-system "${copy}" 98 | done 99 | lock_close 9 100 | 101 | rm -rf --one-file-system "${work_dir}" 102 | clean_iso_root "${iso_root}" 103 | fi 104 | 105 | if ${iso_only}; then 106 | [[ ! -d ${work_dir} ]] && die "Create images: buildiso -p %s -x" "${profile}" 107 | compress_images 108 | exit 1 109 | fi 110 | if ${images_only}; then 111 | prepare_images 112 | warning "Continue compress: buildiso -p %s -zc ..." "${profile}" 113 | exit 1 114 | else 115 | prepare_images 116 | compress_images 117 | fi 118 | msg "Finished building [%s]" "${profile}" 119 | show_elapsed_time "${FUNCNAME}" "${timer_start}" 120 | } 121 | 122 | load_user_info 123 | 124 | load_config "${AT_USERCONFDIR}/artools.conf" || load_config "${SYSCONFDIR}/artools.conf" 125 | 126 | clean_first=true 127 | pretend=false 128 | images_only=false 129 | iso_only=false 130 | verbose=false 131 | persist=false 132 | 133 | mkchroot_args=() 134 | cmd=${0##*/} 135 | stablility=${cmd##*-} 136 | 137 | usage() { 138 | echo "Usage: ${0##*/} [options]" 139 | echo " -p Profile [default: ${profile}]" 140 | echo ' -r Chroots directory' 141 | echo " [default: ${chroots_iso}]" 142 | echo ' -t Target directory' 143 | echo " [default: ${iso_pool}]" 144 | echo ' -i Init system to use' 145 | echo " [default: ${initsys}]" 146 | echo ' -g The gpg key for sfs signing' 147 | echo " [default: ${gpgkey}]" 148 | echo ' -m Set SquashFS image mode to persistence' 149 | echo ' -c Disable clean work dir' 150 | echo ' -x Build images only' 151 | echo ' -z Generate iso only' 152 | echo ' Requires pre built images (-x)' 153 | echo ' -v Verbose output to log file, show profile detail (-q)' 154 | echo ' -q Query settings and pretend build' 155 | echo ' -h This help' 156 | echo '' 157 | echo '' 158 | exit $1 159 | } 160 | 161 | orig_argv=("$0" "$@") 162 | 163 | opts='p:r:t:i:g:czxmvqh' 164 | 165 | while getopts "${opts}" arg; do 166 | case "${arg}" in 167 | p) profile="$OPTARG" ;; 168 | r) chroots_iso="$OPTARG" ;; 169 | t) iso_pool="$OPTARG" ;; 170 | i) initsys="$OPTARG" ;; 171 | g) gpgkey="$OPTARG" ;; 172 | c) clean_first=false ;; 173 | x) images_only=true ;; 174 | z) iso_only=true ;; 175 | m) persist=true ;; 176 | v) verbose=true ;; 177 | q) pretend=true ;; 178 | h|?) usage 0 ;; 179 | *) echo "invalid argument '${arg}'"; usage 1 ;; 180 | esac 181 | done 182 | 183 | shift $(($OPTIND - 1)) 184 | 185 | check_root 186 | 187 | prepare_traps 188 | 189 | prepare_build 190 | 191 | ${pretend} && display_settings && exit 1 192 | 193 | build 194 | -------------------------------------------------------------------------------- /bin/buildpkg.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | shopt -s nullglob 15 | 16 | LIBDIR='@libdir@' 17 | DATADIR='@datadir@' 18 | SYSCONFDIR='@sysconfdir@' 19 | 20 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 21 | import ${LIBDIR}/util.sh 22 | import ${LIBDIR}/util-chroot.sh 23 | 24 | show_pkg(){ 25 | source PKGBUILD 26 | for n in ${pkgname[@]}; do 27 | msg2 "%s" "$n" 28 | done 29 | } 30 | 31 | display_settings(){ 32 | show_version 33 | show_config 34 | 35 | msg "OPTIONS:" 36 | msg2 "chroots_pkg: %s" "${chroots_pkg}" 37 | msg2 "repository: %s" "${repository}" 38 | 39 | msg "ARGS:" 40 | msg2 "create_first: %s" "${create_first}" 41 | msg2 "makepkg_args: %s" "${makepkg_args[*]}" 42 | msg2 "mkchrootpkg_args: %s" "${mkchrootpkg_args[*]}" 43 | 44 | msg "BUILD:" 45 | show_pkg 46 | } 47 | 48 | load_user_info 49 | 50 | load_config "${AT_USERCONFDIR}/artools.conf" || load_config "${SYSCONFDIR}/artools.conf" 51 | 52 | create_first=false 53 | pretend=false 54 | 55 | mkchroot_args=() 56 | mkchrootpkg_args=(-c -n) 57 | 58 | repository='default' 59 | 60 | prepare_build(){ 61 | local pac_file= mp_file='makepkg.conf' 62 | 63 | base_devel=('base-devel') 64 | 65 | case ${repository} in 66 | 'system'|'world'|'galaxy') repository='default' ;; 67 | lib32*) base_devel+=('multilib-devel') ;; 68 | galaxy-gremlins|galaxy-goblins) repository=${repository#*-} ;; 69 | esac 70 | local pac_file="pacman-${repository}.conf" 71 | 72 | local pacman_conf="${DATADIR}/$pac_file" 73 | [[ -f $AT_USERCONFDIR/$pac_file ]] && pacman_conf="$AT_USERCONFDIR/$pac_file" 74 | 75 | work_dir="${chroots_pkg}/${repository}-${target_arch}" 76 | 77 | local makepkg_conf="${DATADIR}/$mp_file" 78 | [[ -f $AT_USERCONFDIR/$mp_file ]] && makepkg_conf="$AT_USERCONFDIR/$mp_file" 79 | 80 | mkchroot_args+=(-C "${pacman_conf}" -M "${makepkg_conf}" "${work_dir}/root") 81 | 82 | mkchrootpkg_args+=(-r "${work_dir}" "${makepkg_args[@]}") 83 | } 84 | 85 | build(){ 86 | local timer_start=$(get_timer) 87 | 88 | exec mkchrootpkg "${mkchrootpkg_args[@]}" 89 | show_elapsed_time "${FUNCNAME}" "${timer_start}" 90 | } 91 | 92 | usage() { 93 | echo "Usage: ${0##*/} [options] -- [makepkg_args]" 94 | echo " -r Repository [default: ${repository}]" 95 | echo ' -c Create root chroot' 96 | echo ' -q Query settings and pretend build' 97 | echo ' -h This help' 98 | echo '' 99 | echo "Default makepkg_args args: ${makepkg_args[*]}" 100 | echo '' 101 | exit $1 102 | } 103 | 104 | orig_argv=("$0" "$@") 105 | 106 | opts='r:cqh' 107 | 108 | while getopts "${opts}" arg; do 109 | case "${arg}" in 110 | r) repository="$OPTARG" ;; 111 | c) create_first=true ;; 112 | q) pretend=true ;; 113 | h|?) usage 0 ;; 114 | *) echo "invalid argument '%s'" "${arg}"; usage 1 ;; 115 | esac 116 | done 117 | 118 | makepkg_args+=("${@:$OPTIND}") 119 | 120 | check_root 121 | 122 | prepare_build 123 | 124 | ${pretend} && display_settings && exit 125 | 126 | if ${create_first} || [[ ! -d ${work_dir}/root ]];then 127 | msg "Creating chroot for [%s] (%s)..." "${repository}" "${target_arch}" 128 | 129 | for copy in "${work_dir}"/*; do 130 | [[ -d $copy ]] || continue 131 | msg2 "Deleting chroot copy '%s'..." "$(basename "${copy}")" 132 | 133 | lock 9 "$copy.lock" "Locking chroot copy '%s'" "$copy" 134 | 135 | subvolume_delete_recursive "${copy}" 136 | rm -rf --one-file-system "${copy}" 137 | done 138 | lock_close 9 139 | 140 | rm -rf --one-file-system "${work_dir}" 141 | mkdir -p "${work_dir}" 142 | setarch "${target_arch}" mkchroot \ 143 | "${mkchroot_args[@]}" "${base_devel[@]}" || abort 144 | else 145 | lock 9 "${work_dir}/root.lock" "Locking clean chroot" 146 | chroot-run "${mkchroot_args[@]}" \ 147 | pacman -Syu --noconfirm || abort 148 | fi 149 | 150 | build 151 | -------------------------------------------------------------------------------- /bin/buildtree.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | SYSCONFDIR='@sysconfdir@' 16 | DATADIR='@datadir@' 17 | 18 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 19 | import ${LIBDIR}/util.sh 20 | import ${LIBDIR}/util-pkg.sh 21 | 22 | pull_tree_arch(){ 23 | cd ${tree_dir_arch} 24 | for tree in packages community;do 25 | if [[ -d ${tree} ]];then 26 | cd ${tree} 27 | msg "Checking (%s)" "${tree}" 28 | pull_tree 29 | cd .. 30 | else 31 | msg "Cloning (%s) ..." "$tree" 32 | clone_tree "${host_tree_arch}/${tree}" 33 | fi 34 | done 35 | } 36 | 37 | pull_tree_artix(){ 38 | cd ${tree_dir_artix} 39 | for tree in packages packages-galaxy;do 40 | if [[ -d ${tree} ]];then 41 | cd ${tree} 42 | git config --bool pull.rebase true 43 | git config commit.gpgsign true 44 | if [[ -n "${GPGKEY}" ]];then 45 | git config user.signingkey "${GPGKEY}" 46 | else 47 | warning "No GPGKEY configured in makepkg.conf!" 48 | fi 49 | msg "Checking (%s)" "${tree}" 50 | pull_tree 51 | cd .. 52 | else 53 | msg "Cloning (%s) ..." "$tree" 54 | clone_tree "${host_tree_artix}/${tree}" 55 | fi 56 | done 57 | } 58 | 59 | show_version_table(){ 60 | msg_table_header "%-20s %-20s %-25s %-30s %-30s" "Arch Repo" "Artix Repo" "Package" "Arch version" "Artix version" 61 | for tree in packages packages-galaxy;do 62 | local git=$(find ${tree_dir_artix}/$tree/ -mindepth 1 -maxdepth 1 -type d) 63 | for pkg_path in ${git[@]}; do 64 | local artixrepo=$(find_repo "$pkg_path" "${unstable}" "${staging}") 65 | if [[ -d $pkg_path/repos/$artixrepo ]];then 66 | source $pkg_path/repos/$artixrepo/PKGBUILD 2>/dev/null 67 | local pkg=${pkg_path##*/} 68 | local artixver=$(get_full_version $pkg) 69 | local src=$(get_import_path "$tree" "$pkg") 70 | local archrepo=$(find_repo "$src/$pkg" "${unstable}" "${staging}") 71 | if [[ -d $src/$pkg/repos/$archrepo ]];then 72 | source $src/$pkg/repos/$archrepo/PKGBUILD 2>/dev/null 73 | local archver=$(get_full_version $pkg) 74 | fi 75 | if ${artix};then 76 | if [ $(vercmp "$artixver" "$archver") -eq 0 ] || [ $(vercmp "$artixver" "$archver") -gt 0 ];then 77 | local ar=$(arch_to_artix_repo "$artixrepo") 78 | case $ar in 79 | *goblins) 80 | if [[ "$archrepo" == "$artixrepo" ]];then 81 | msg_row "%-20s %-20s %-25s %-30s %-30s" "${archrepo%-*}" "${ar}" "$pkg" "$archver" "$artixver" 82 | else 83 | msg_row_notify "%-20s %-20s %-25s %-30s %-30s" "${archrepo%-*}" "${ar}" "$pkg" "$archver" "$artixver" 84 | fi 85 | ;; 86 | *gremlins) 87 | if [[ "$archrepo" == "$artixrepo" ]];then 88 | msg_row "%-20s %-20s %-25s %-30s %-30s" "${archrepo%-*}" "${ar}" "$pkg" "$archver" "$artixver" 89 | else 90 | msg_row_notify "%-20s %-20s %-25s %-30s %-30s" "${archrepo%-*}" "${ar}" "$pkg" "$archver" "$artixver" 91 | fi 92 | ;; 93 | esac 94 | fi 95 | else 96 | if [ $(vercmp "$artixver" "$archver") -lt 0 ];then 97 | local ar=$(arch_to_artix_repo "$artixrepo") 98 | ${upgrades} && msg_row_upgrade "%-20s %-20s %-25s %-30s %-30s" "${archrepo%-*}" "${ar}" "$pkg" "$archver" "$artixver" 99 | fi 100 | if [ $(vercmp "$artixver" "$archver") -gt 0 ];then 101 | local ar=$(arch_to_artix_repo "$artixrepo") 102 | if [[ -n $archver ]] && [[ -n $archrepo ]];then 103 | ${downgrades} && msg_row_downgrade "%-20s %-20s %-25s %-30s %-30s" "${archrepo%-*}" "${ar}" "$pkg" "$archver" "$artixver" 104 | fi 105 | fi 106 | fi 107 | unset pkgver epoch pkgrel artixver archver _package 108 | fi 109 | done 110 | done 111 | } 112 | 113 | show_deps(){ 114 | local src="$1" repo="$2" 115 | source $src/PKGBUILD 2>/dev/null 116 | [[ $arch == 'any' ]] && CARCH=any 117 | local archver=$(get_full_version $pkg) 118 | msg "git tree: %s" "$git_tree_arch" 119 | msg2 "repo: %s" "$repo" 120 | msg2 "Package Name: %s" "$pkg" 121 | msg2 "Arch Version: %s" "$archver" 122 | msg2 "arch: %s" "$CARCH" 123 | [[ -n ${makedepends[@]} ]] && msg2 "makedepends: %s" "${makedepends[*]}" 124 | [[ -n ${checkdepends[@]} ]] && msg2 "checkdepends: %s" "${checkdepends[*]}" 125 | [[ -n ${depends[@]} ]] && msg2 "depends: %s" "${depends[*]}" 126 | [[ -n ${optdepends[@]} ]] && msg2 "optdepends: %s" "${optdepends[@]}" 127 | } 128 | 129 | from_arch(){ 130 | local pkg="$1" src= dest= 131 | local git_tree_arch=$(find_tree "${tree_dir_arch}" "$pkg") 132 | [[ -z $git_tree_arch ]] && die "Package '%s' does not exist!" "$pkg" 133 | 134 | local pkg_path=${tree_dir_arch}/$git_tree_arch/$pkg 135 | local repo=$(find_repo "$pkg_path" "${unstable}") 136 | 137 | src=$pkg_path/repos/$repo 138 | $trunk && src=$pkg_path/trunk 139 | 140 | local git_tree_artix=$(find_tree "${tree_dir_artix}" "$pkg") 141 | dest=${tree_dir_artix}/$git_tree_artix/$pkg/trunk 142 | 143 | cd ${tree_dir_arch}/$git_tree_arch 144 | 145 | show_deps "$src" "$repo" 146 | 147 | if [[ -d $dest ]];then 148 | cd ${tree_dir_artix}/$git_tree_artix 149 | 150 | source $dest/PKGBUILD 2>/dev/null 151 | local artixver=$(get_full_version $pkg) 152 | 153 | msg2 "Artix Version: %s" "$artixver" 154 | info "Update from archlinux (%s)" "$git_tree_arch" 155 | rsync "${rsync_args[@]}" $src/ $dest/ 156 | patch_pkg "$pkg" "$tree" 157 | else 158 | [[ $git_tree_arch == 'packages' ]] && git_tree_artix=$git_tree_arch 159 | [[ $git_tree_arch == 'community' ]] && git_tree_artix='packages-galaxy' 160 | 161 | cd ${tree_dir_artix}/$git_tree_artix 162 | 163 | dest=${tree_dir_artix}/$git_tree_artix/$pkg/trunk 164 | mkdir $pkg 165 | 166 | info "Import from archlinux (%s)" "$git_tree_arch" 167 | rsync "${rsync_args[@]}" $src/ $dest/ 168 | patch_pkg "$pkg" "$tree" 169 | fi 170 | } 171 | 172 | view_build(){ 173 | local pkg="$1" src= 174 | local git_tree_arch=$(find_tree "${tree_dir_arch}" "$pkg") 175 | [[ -z $git_tree_arch ]] && die "Package '%s' does not exist!" "$pkg" 176 | 177 | local pkg_path=${tree_dir_arch}/$git_tree_arch/$pkg 178 | local repo=$(find_repo "$pkg_path" "${unstable}") 179 | 180 | src=$pkg_path/repos/$repo 181 | 182 | show_deps "$src" "$repo" 183 | } 184 | 185 | sync_repos(){ 186 | ${sync_arch} && pull_tree_arch 187 | pull_tree_artix 188 | } 189 | 190 | display_settings(){ 191 | show_version 192 | show_config 193 | 194 | msg "OPTIONS:" 195 | msg2 "package: %s" "${package}" 196 | 197 | msg "ARGS:" 198 | msg2 "sync: %s" "${sync}" 199 | msg2 "sync_arch: %s" "${sync_arch}" 200 | msg2 "compare: %s" "${compare}" 201 | msg2 "upgrades: %s" "${upgrades}" 202 | msg2 "downgrades: %s" "${downgrades}" 203 | msg2 "artix: %s" "${artix}" 204 | msg2 "staging: %s" "${staging}" 205 | msg2 "unstable: %s" "${unstable}" 206 | msg2 "import: %s" "${import}" 207 | msg2 "view: %s" "${view}" 208 | msg2 "trunk: %s" "${trunk}" 209 | 210 | msg "PATHS:" 211 | msg2 "tree_dir_artix: %s" "${tree_dir_artix}" 212 | msg2 "tree_dir_arch: %s" "${tree_dir_arch}" 213 | } 214 | 215 | load_user_info 216 | 217 | load_config "${AT_USERCONFDIR}/artools.conf" || load_config "${SYSCONFDIR}/artools.conf" 218 | load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf" 219 | load_vars /etc/makepkg.conf 220 | 221 | pretend=false 222 | sync=false 223 | sync_arch=true 224 | compare=false 225 | unstable=false 226 | staging=true 227 | upgrades=false 228 | downgrades=false 229 | artix=false 230 | import=false 231 | view=false 232 | trunk=false 233 | package='' 234 | 235 | rsync_args=(-aWxvci --progress --delete-before --no-R --no-implied-dirs) 236 | 237 | usage() { 238 | echo "Usage: ${0##*/} [options]" 239 | echo ' -p Package name' 240 | echo " -s Clone or pull repos" 241 | echo " -z Don't clone or pull arch repos" 242 | echo ' -c Compare packages' 243 | echo ' -u Show upgrade packages' 244 | echo ' -d Show downgrade packages' 245 | echo ' -a Show testing packages' 246 | echo " -y Don't inlcude staging packages" 247 | echo ' -x Include unstable kde and gnome' 248 | echo ' -i Import a package from arch repos' 249 | echo ' -t Import from arch trunk' 250 | echo ' -v View package depends' 251 | echo ' -q Query settings' 252 | echo ' -h This help' 253 | echo '' 254 | echo '' 255 | exit $1 256 | } 257 | 258 | orig_argv=("$0" "$@") 259 | 260 | opts='p:csudayiztxvqh' 261 | 262 | while getopts "${opts}" arg; do 263 | case "${arg}" in 264 | p) package="$OPTARG" ;; 265 | s) sync=true ;; 266 | z) sync_arch=false ;; 267 | c) compare=true ;; 268 | u) upgrades=true ;; 269 | d) downgrades=true ;; 270 | a) artix=true ;; 271 | y) staging=false ;; 272 | i) import=true ;; 273 | t) trunk=true ;; 274 | v) view=true ;; 275 | x) unstable=true ;; 276 | q) pretend=true ;; 277 | h|?) usage 0 ;; 278 | *) echo "invalid argument '${arg}'"; usage 1 ;; 279 | esac 280 | done 281 | 282 | shift $(($OPTIND - 1)) 283 | 284 | prepare_dir "${tree_dir_artix}" 285 | prepare_dir "${tree_dir_arch}" 286 | 287 | ${pretend} && display_settings && exit 1 288 | 289 | ${sync} && sync_repos 290 | 291 | ${view} && view_build "${package}" 292 | 293 | ${compare} && show_version_table 294 | 295 | ${import} && from_arch "${package}" 296 | -------------------------------------------------------------------------------- /bin/checkpkg.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | 16 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 17 | import ${LIBDIR}/util.sh 18 | import ${LIBDIR}/util-pkg.sh 19 | 20 | shopt -s extglob 21 | 22 | load_user_info 23 | 24 | load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf" 25 | load_vars /etc/makepkg.conf 26 | 27 | if [[ ! -f PKGBUILD ]]; then 28 | die 'This must be run in the directory of a built package.' 29 | fi 30 | 31 | . ./PKGBUILD 32 | if [[ $arch == 'any' ]]; then 33 | CARCH='any' 34 | fi 35 | 36 | STARTDIR=$(pwd) 37 | TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX) 38 | 39 | for _pkgname in "${pkgname[@]}"; do 40 | target_pkgver=$(get_full_version "$_pkgname") 41 | if ! pkgfile=$(find_cached_package "$_pkgname" "$target_pkgver" "$CARCH"); then 42 | die 'tarball not found for package: %s' "${_pkgname}-$target_pkgver" 43 | fi 44 | 45 | ln -s "$pkgfile" "$TEMPDIR" 46 | 47 | pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$_pkgname") 48 | 49 | if [[ $? -ne 0 ]]; then 50 | die "Couldn't download previous package for %s." "$_pkgname" 51 | fi 52 | 53 | oldpkg=${pkgurl##*://*/} 54 | 55 | if [[ ${oldpkg##*/} = ${pkgfile##*/} ]]; then 56 | die "The built package (%s) is the one in the repo right now!" "$_pkgname" 57 | fi 58 | 59 | if [[ $pkgurl = file://* ]]; then 60 | ln -s "${pkgurl#file://}" "$TEMPDIR/$oldpkg" 61 | elif [[ -f "$PKGDEST/$oldpkg" ]]; then 62 | ln -s "$PKGDEST/$oldpkg" "$TEMPDIR/$oldpkg" 63 | elif [[ -f "$STARTDIR/$oldpkg" ]]; then 64 | ln -s "$STARTDIR/$oldpkg" "$TEMPDIR/$oldpkg" 65 | else 66 | curl -fsLC - --retry 3 --retry-delay 3 -o "$TEMPDIR/$oldpkg" "$pkgurl" 67 | fi 68 | 69 | bsdtar tf "$TEMPDIR/$oldpkg" | sort > "$TEMPDIR/filelist-$_pkgname-old" 70 | bsdtar tf "$pkgfile" | sort > "$TEMPDIR/filelist-$_pkgname" 71 | 72 | sdiff -s "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname" 73 | 74 | find-libprovides "$TEMPDIR/$oldpkg" 2>/dev/null | sort > "$TEMPDIR/libraries-$_pkgname-old" 75 | find-libprovides "$pkgfile" 2>/dev/null | sort > "$TEMPDIR/libraries-$_pkgname" 76 | if ! diff_output="$(sdiff -s "$TEMPDIR/libraries-$_pkgname-old" "$TEMPDIR/libraries-$_pkgname")"; then 77 | msg "Sonames differ in %s!" "$_pkgname" 78 | echo "$diff_output" 79 | else 80 | msg "No soname differences for %s" "$_pkgname." 81 | fi 82 | done 83 | -------------------------------------------------------------------------------- /bin/chroot-run.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | chroot_version=@chroot_version@ 15 | 16 | LIBDIR='@libdir@' 17 | 18 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 19 | import ${LIBDIR}/util.sh 20 | import ${LIBDIR}/util-chroot.sh 21 | import ${LIBDIR}/util-mount.sh 22 | 23 | working_dir='' 24 | files=() 25 | keep_mirrors=false 26 | nosetarch=false 27 | 28 | usage() { 29 | echo "Usage: ${0##*/} [options] working-dir [run arguments]" 30 | echo "A wrapper around chroot. Provides support for pacman." 31 | echo 32 | echo ' options:' 33 | echo ' -C Location of a pacman config file' 34 | echo ' -M Location of a makepkg config file' 35 | echo ' -c Set pacman cache' 36 | echo ' -f Copy file from the host to the chroot' 37 | echo ' -s Do not run setarch' 38 | echo ' -r Bind mountargs ro' 39 | echo ' -w Bind mountargs rw' 40 | echo ' List format [src1:target1 ... srcN:targetN]' 41 | echo ' -h This message' 42 | exit 1 43 | } 44 | 45 | orig_argv=("$0" "$@") 46 | 47 | opts='hC:M:c:r:w:f:s' 48 | 49 | while getopts ${opts} arg; do 50 | case "${arg}" in 51 | C) pacman_conf="$OPTARG" ;; 52 | M) makepkg_conf="$OPTARG" ;; 53 | c) cache_dir="$OPTARG" ;; 54 | f) files+=("$OPTARG") ;; 55 | s) nosetarch=true ;; 56 | r) bindmounts_ro=("$OPTARG") ;; 57 | w) bindmounts_rw=("$OPTARG") ;; 58 | h|?) usage ;; 59 | *) error "invalid argument '$arg'"; usage ;; 60 | esac 61 | done 62 | shift $(($OPTIND - 1)) 63 | 64 | (( $# < 1 )) && die 'You must specify a directory.' 65 | 66 | check_root 67 | 68 | working_dir=$(readlink -f "$1") 69 | shift 1 70 | 71 | [[ -z $working_dir ]] && die 'Please specify a working directory.' 72 | 73 | if [[ -z $cache_dir ]]; then 74 | cache_dirs=($(pacman -v 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g')) 75 | else 76 | cache_dirs=("$cache_dir") 77 | fi 78 | 79 | copy_hostconf () { 80 | cp -a /etc/pacman.d/gnupg "$1/etc/pacman.d" 81 | 82 | [[ -n $pacman_conf ]] && cp $pacman_conf "$1/etc/pacman.conf" 83 | 84 | [[ -n $makepkg_conf ]] && cp $makepkg_conf "$1/etc/makepkg.conf" 85 | 86 | local file 87 | for file in "${files[@]}"; do 88 | mkdir -p "$(dirname "$working_dir$file")" 89 | cp -T "$file" "$working_dir$file" 90 | done 91 | 92 | sed -r "s|^#?\\s*CacheDir.+|CacheDir = ${cache_dirs[*]}|g" -i "$1/etc/pacman.conf" 93 | } 94 | 95 | chroot_extra_mount() { 96 | chroot_add_resolv_conf "$1" 97 | chroot_mount "/etc/hosts" "$1/etc/hosts" -B 98 | # chroot_mount_conditional "[[ -e $1/etc/machine-id ]]" "/etc/machine-id" "$1/etc/machine-id" -B 99 | chroot_mount "${cache_dirs[0]}" "$1${cache_dirs[0]}" -B 100 | 101 | for cache_dir in ${cache_dirs[@]:1}; do 102 | chroot_mount "$cache_dir" "$1${cache_dir}" -Br 103 | done 104 | 105 | for m in ${bindmounts_ro[@]}; do 106 | chroot_mount "${m%%:*}" "$1${m##*:}" -Br 107 | done 108 | 109 | for m in ${bindmounts_rw[@]}; do 110 | chroot_mount "${m%%:*}" "$1${m##*:}" -B 111 | done 112 | } 113 | 114 | umask 0022 115 | 116 | # Sanity check 117 | if [[ ! -f "$working_dir/.artools" ]]; then 118 | die "'%s' does not appear to be an artix chroot." "$working_dir" 119 | elif [[ $(cat "$working_dir/.artools") != $chroot_version ]]; then 120 | die "chroot '%s' is not at version %s. Please rebuild." "$working_dir" "$chroot_version" 121 | fi 122 | 123 | chroot_api_mount "${working_dir}" || die "failed to setup API filesystems in chroot %s" "${working_dir}" 124 | 125 | chroot_extra_mount "${working_dir}" 126 | 127 | copy_hostconf "${working_dir}" 128 | 129 | eval $(grep '^CARCH=' "$working_dir/etc/makepkg.conf") 130 | 131 | ${nosetarch} && unset CARCH 132 | 133 | ${CARCH:+setarch "$CARCH"} chroot "${working_dir}" "$@" 134 | 135 | ret=$? 136 | 137 | kill_chroot_process "${working_dir}" 138 | 139 | exit $ret 140 | -------------------------------------------------------------------------------- /bin/commitpkg.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | SYSCONFDIR='@sysconfdir@' 16 | DATADIR='@datadir@' 17 | 18 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 19 | import ${LIBDIR}/util.sh 20 | import ${LIBDIR}/util-pkg.sh 21 | 22 | commit_pkg(){ 23 | local git_tree=$(find_tree "${tree_dir_artix}" "${package}") 24 | if [[ -n ${git_tree} ]];then 25 | cd ${tree_dir_artix}/${git_tree}/${package} 26 | 27 | source trunk/PKGBUILD 28 | [[ $arch == 'any' ]] && CARCH=any 29 | local ver=$(get_full_version "${package}") 30 | 31 | if ${remove};then 32 | local action='remove' 33 | if [[ "${source_repo}" == 'trunk' ]];then 34 | local pkg=${package} 35 | git rm -r trunk 36 | else 37 | local pkg="${package}-$ver" 38 | git rm -r repos/"${source_repo}-$CARCH" 39 | fi 40 | msg "Action: [%s] '%s' %s" "${source_repo}" "$pkg" "${action}" 41 | git commit -m "[${source_repo}] '$pkg' ${action}" 42 | else 43 | local action='modify' 44 | msg "Action: [%s] '%s' %s" "${source_repo}" "${package}-$ver" "${action}" 45 | git add . 46 | git commit -m "[${source_repo}] '${package}-$ver' ${action}" 47 | fi 48 | 49 | if ${push};then 50 | msg "Checking (%s)" "${git_tree}" 51 | git pull origin master 52 | git push origin master 53 | fi 54 | else 55 | error "Package '%s' does not exist!" "${package}" 56 | fi 57 | } 58 | 59 | symlink_commit_pkg(){ 60 | local git_tree=$(find_tree "${tree_dir_artix}" "${package}") 61 | if [[ -n ${git_tree} ]];then 62 | cd ${tree_dir_artix}/${git_tree}/${package} 63 | 64 | source trunk/PKGBUILD 65 | [[ $arch == 'any' ]] && CARCH=any 66 | local ver=$(get_full_version "${package}") 67 | 68 | if [[ ${source_repo} == 'trunk' ]];then 69 | local action='add' 70 | local dest="${target_repo}-$CARCH" 71 | 72 | [[ -d repos/$dest ]] && git rm -r repos/$dest 73 | [[ ! -d repos ]] && mkdir repos 74 | [[ ! -d repos/$dest ]] && mkdir repos/$dest 75 | 76 | cp trunk/* repos/$dest/ 77 | else 78 | local action='move' 79 | local src="${source_repo}-$CARCH" dest="${target_repo}-$CARCH" 80 | 81 | [[ -d repos/$dest ]] && git rm -r repos/$dest 82 | [[ ! -d repos ]] && mkdir repos 83 | [[ ! -d repos/$dest ]] && mkdir repos/$dest 84 | 85 | cp repos/$src/* repos/$dest/ 86 | git rm -r repos/$src 87 | fi 88 | 89 | msg "Action: [%s] -> [%s] '%s' %s" "${source_repo}" "${target_repo}" "${package}-$ver" "${action}" 90 | git add . 91 | git commit -m "[${source_repo}] -> [${target_repo}] '${package}-$ver' ${action}" 92 | 93 | if ${push};then 94 | msg "Checking (%s)" "${git_tree}" 95 | git pull origin master 96 | git push origin master 97 | fi 98 | else 99 | error "Package '%s' does not exist!" "${package}" 100 | fi 101 | } 102 | 103 | display_settings(){ 104 | show_version 105 | show_config 106 | 107 | msg "OPTIONS:" 108 | msg2 "source_repo: %s" "${source_repo}" 109 | msg2 "target_repo: %s" "${target_repo}" 110 | msg2 "package: %s" "${package}" 111 | 112 | msg "ARGS:" 113 | msg2 "remove: %s" "${remove}" 114 | msg2 "push: %s" "${push}" 115 | } 116 | 117 | load_user_info 118 | 119 | load_config "${AT_USERCONFDIR}/artools.conf" || load_config "${SYSCONFDIR}/artools.conf" 120 | load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf" 121 | load_vars /etc/makepkg.conf 122 | 123 | source_repo='trunk' 124 | package='' 125 | remove=false 126 | push=false 127 | pretend=false 128 | 129 | cmd=${0##*/} 130 | target_repo=${cmd%pkg} 131 | 132 | usage() { 133 | echo "Usage: ${0##*/} [options]" 134 | echo " -s Source repository [default:${source_repo}]" 135 | echo ' -p Package name' 136 | echo ' -r Delete from repo (commitpkg only)' 137 | echo ' -u Push' 138 | echo ' -q Query settings and pretend' 139 | echo ' -h This help' 140 | echo '' 141 | echo '' 142 | exit $1 143 | } 144 | 145 | orig_argv=("$0" "$@") 146 | 147 | opts='p:s:urqh' 148 | 149 | while getopts "${opts}" arg; do 150 | case "${arg}" in 151 | s) source_repo="$OPTARG" ;; 152 | p) package="$OPTARG" ;; 153 | r) remove=true ;; 154 | u) push=true ;; 155 | q) pretend=true ;; 156 | h|?) usage 0 ;; 157 | *) echo "invalid argument '${arg}'"; usage 1 ;; 158 | esac 159 | done 160 | 161 | shift $(($OPTIND - 1)) 162 | 163 | ${pretend} && display_settings && exit 1 164 | 165 | if $(is_valid_repo "${source_repo}");then 166 | if [[ "${cmd}" == 'commitpkg' ]];then 167 | commit_pkg 168 | else 169 | symlink_commit_pkg 170 | fi 171 | else 172 | error "source repository '%s' is not valid!" "${source_repo}" 173 | fi 174 | -------------------------------------------------------------------------------- /bin/deployiso.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | SYSCONFDIR='@sysconfdir@' 16 | 17 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 18 | import ${LIBDIR}/util.sh 19 | import ${LIBDIR}/util-iso-publish.sh 20 | 21 | display_settings(){ 22 | show_version 23 | show_config 24 | 25 | msg "OPTIONS:" 26 | msg2 "profile: %s" "${profile}" 27 | msg2 "uplimit: %s kB/s" "${uplimit}" 28 | 29 | msg "ARGS:" 30 | msg2 "update: %s" "${update}" 31 | msg2 "verbose: %s" "${verbose}" 32 | msg2 "torrent: %s" "${torrent}" 33 | 34 | if ${torrent};then 35 | msg2 "tracker_url: %s" "${tracker_url}" 36 | msg2 "piece_size: %s" "${piece_size}" 37 | msg2 "host_mirrors: %s" "${host_mirrors[*]}" 38 | msg2 "torrent_meta: %s" "${torrent_meta}" 39 | fi 40 | 41 | msg "REMOTE:" 42 | msg2 "account: %s" "${account}" 43 | msg2 "file_host: %s" "${file_host}" 44 | msg2 "project: %s" "${project}" 45 | 46 | msg "UPLOAD:" 47 | msg2 "src_dir: ${src_dir}" 48 | msg2 "target_dir: ${target_dir}" 49 | } 50 | 51 | load_user_info 52 | 53 | load_config "${AT_USERCONFDIR}/artools.conf" || load_config "${SYSCONFDIR}/artools.conf" 54 | 55 | pretend=false 56 | update=false 57 | verbose=false 58 | torrent=false 59 | 60 | rsync_args=(-aP --progress -e ssh) 61 | 62 | usage() { 63 | echo "Usage: ${0##*/} [options]" 64 | echo " -p Source folder to upload [default: ${profile}]" 65 | echo " -l Limit bandwidth in kB/s [default:${uplimit}]" 66 | echo ' -u Update remote directory' 67 | echo ' -t Create iso torrent' 68 | echo ' -q Query settings and pretend upload' 69 | echo ' -v Verbose output' 70 | echo ' -h This help' 71 | echo '' 72 | echo '' 73 | exit $1 74 | } 75 | 76 | opts='p:l:uvtqh' 77 | 78 | while getopts "${opts}" arg; do 79 | case "${arg}" in 80 | p) profile="$OPTARG" ;; 81 | l) uplimit="$OPTARG" ;; 82 | u) update=true; rsync_args+=(-u) ;; 83 | t) torrent=true ;; 84 | v) verbose=true; rsync_args+=(-v --stats) ;; 85 | q) pretend=true; rsync_args+=(-n) ;; 86 | h|?) usage 0 ;; 87 | *) echo "invalid argument '${arg}'"; usage 1 ;; 88 | esac 89 | done 90 | 91 | shift $(($OPTIND - 1)) 92 | 93 | timer_start=$(get_timer) 94 | 95 | rsync_args+=(--bwlimit=${uplimit}) 96 | 97 | prepare_transfer 98 | 99 | ${pretend} && display_settings #&& exit 1 100 | 101 | sync_dir 102 | -------------------------------------------------------------------------------- /bin/deploypkg.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | SYSCONFDIR='@sysconfdir@' 16 | 17 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 18 | import ${LIBDIR}/util.sh 19 | import ${LIBDIR}/util-pkg.sh 20 | 21 | update_repo(){ 22 | local repo="$1" pkgfile ver ext=db.tar.xz 23 | local repo_path=${repos_root}/$repo/os/${target_arch} packages=() 24 | source PKGBUILD 25 | for name in ${pkgname[@]};do 26 | [[ $arch == any ]] && CARCH=any 27 | ver=$(get_full_version "$name") 28 | if pkgfile=$(find_cached_package "$name" "$ver" "$CARCH");then 29 | local pkg=${pkgfile##*/} 30 | info "Found: %s" "$pkg" 31 | if ${add_pkg};then 32 | local action='add' 33 | packages+=("$pkg") 34 | # checkpkg $pkg 35 | if ${sign_pkg};then 36 | [[ -e ${pkgfile}.sig ]] && rm ${pkgfile}.sig 37 | signfile ${pkgfile} 38 | fi 39 | ln -sf ${pkgfile}{,.sig} $repo_path/ 40 | elif ${del_pkg};then 41 | local action='remove' 42 | packages+=("$name") 43 | [[ -e $repo_path/$pkg ]] && rm $repo_path/$pkg 44 | [[ -e $repo_path/$pkg.sig ]] && rm $repo_path/$pkg.sig 45 | fi 46 | fi 47 | done 48 | cd $repo_path 49 | [[ -n $action ]] && repo-$action -R $repo.$ext ${packages[@]} 50 | return 0 51 | } 52 | 53 | display_settings(){ 54 | show_version 55 | show_config 56 | 57 | msg "OPTIONS:" 58 | msg2 "repository: %s" "${repository}" 59 | 60 | msg "ARGS:" 61 | msg2 "add_pkg: %s" "${add_pkg}" 62 | msg2 "del_pkg: %s" "${del_pkg}" 63 | msg2 "sign_pkg: %s" "${sign_pkg}" 64 | } 65 | 66 | load_user_info 67 | 68 | load_config "${AT_USERCONFDIR}/artools.conf" || load_config "${SYSCONFDIR}/artools.conf" 69 | load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf" 70 | load_vars /etc/makepkg.conf 71 | 72 | pretend=false 73 | add_pkg=false 74 | del_pkg=false 75 | repository= 76 | sign_pkg=false 77 | 78 | usage() { 79 | echo "Usage: ${0##*/} [options]" 80 | echo " -d Destination repository [default:${repository}]" 81 | echo ' -a Add package(s) to repository' 82 | echo ' -r Remove package(s) from repository' 83 | echo ' -s Sign package(s)' 84 | echo ' -q Query settings and pretend upload' 85 | echo ' -h This help' 86 | echo '' 87 | echo '' 88 | exit $1 89 | } 90 | 91 | orig_argv=("$0" "$@") 92 | 93 | opts='d:arsqh' 94 | 95 | while getopts "${opts}" arg; do 96 | case "${arg}" in 97 | d) repository="$OPTARG" ;; 98 | a) add_pkg=true; del_pkg=false ;; 99 | r) del_pkg=true; add_pkg=false ;; 100 | s) sign_pkg=true ;; 101 | q) pretend=true ;; 102 | h|?) usage 0 ;; 103 | *) echo "invalid argument '${arg}'"; usage 1 ;; 104 | esac 105 | done 106 | 107 | shift $(($OPTIND - 1)) 108 | 109 | prepare_dir "${repos_root}" 110 | 111 | ${pretend} && display_settings && exit 1 112 | 113 | update_repo "${repository}" 114 | -------------------------------------------------------------------------------- /bin/find-libdeps.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | 16 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 17 | import ${LIBDIR}/util-pkg.sh 18 | 19 | set -e 20 | shopt -s extglob 21 | 22 | IGNORE_INTERNAL=0 23 | 24 | if [[ $1 = "--ignore-internal" ]]; then 25 | IGNORE_INTERNAL=1 26 | shift 27 | fi 28 | 29 | script_mode=${0##*/find-lib} 30 | 31 | case $script_mode in 32 | deps|provides) true;; 33 | *) die "Unknown mode %s" "$script_mode" ;; 34 | esac 35 | 36 | if [[ -z $1 ]]; then 37 | echo "${0##*/} [options] " 38 | echo "Options:" 39 | echo " --ignore-internal ignore internal libraries" 40 | exit 1 41 | fi 42 | 43 | if [[ -d $1 ]]; then 44 | pushd $1 >/dev/null 45 | else 46 | WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX") 47 | 48 | case ${script_mode} in 49 | deps) bsdtar -C "$WORKDIR" -xf "$1";; 50 | provides) bsdtar -C "$WORKDIR" -xf "$1" --include="*.so*";; 51 | esac 52 | 53 | pushd "$WORKDIR" >/dev/null 54 | fi 55 | 56 | case $script_mode in 57 | deps) find_args=(-perm -u+x);; 58 | provides) find_args=(-name *.so*);; 59 | esac 60 | 61 | find $PWD -type f "${find_args[@]}" | while read filename; do 62 | if [[ $script_mode = "provides" ]]; then 63 | # ignore if we don't have a shared object 64 | if ! LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then 65 | continue 66 | fi 67 | fi 68 | 69 | # get architecture of the file; if soarch is empty it's not an ELF binary 70 | soarch=$(LC_ALL=C readelf -h "$filename" 2>/dev/null | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p') 71 | [[ -n $soarch ]] || continue 72 | 73 | if [[ $script_mode = "provides" ]]; then 74 | # get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1 75 | sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p') 76 | [[ -z $sofile ]] && sofile="${filename##*/}" 77 | process_sofile "${sofile}" "${soarch}" 78 | elif [[ $script_mode = "deps" ]]; then 79 | # process all libraries needed by the binary 80 | for sofile in $(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p'); do 81 | process_sofile "${sofile}" "${soarch}" 82 | done 83 | fi 84 | done 85 | 86 | popd >/dev/null 87 | -------------------------------------------------------------------------------- /bin/finddeps.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | 16 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 17 | match=$1 18 | 19 | if [[ -z $match ]]; then 20 | echo 'Usage: finddeps ' 21 | echo '' 22 | echo 'Find packages that depend on a given depname.' 23 | echo 'Run this script from the top-level directory of your ABS tree.' 24 | echo '' 25 | exit 1 26 | fi 27 | 28 | find $PWD -type d | while read d; do 29 | if [[ -f "$d/PKGBUILD" ]]; then 30 | unset pkgname depends makedepends optdepends 31 | . "$d/PKGBUILD" 32 | for dep in "${depends[@]}"; do 33 | # lose the version comparator, if any 34 | depname=${dep%%[<>=]*} 35 | [[ $depname = $match ]] && msg "$d (depends)" 36 | done 37 | for dep in "${makedepends[@]}"; do 38 | # lose the version comparator, if any 39 | depname=${dep%%[<>=]*} 40 | [[ $depname = $match ]] && msg "$d (makedepends)" 41 | done 42 | for dep in "${optdepends[@]/:*}"; do 43 | # lose the version comaparator, if any 44 | depname=${dep%%[<>=]*} 45 | [[ $depname = $match ]] && msg "$d (optdepends)" 46 | done 47 | fi 48 | done 49 | -------------------------------------------------------------------------------- /bin/fstabgen.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | shopt -s extglob 15 | 16 | LIBDIR='@libdir@' 17 | 18 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 19 | import ${LIBDIR}/util-fstab.sh 20 | 21 | write_source() { 22 | local src=$1 spec= label= uuid= comment=() 23 | 24 | label=$(lsblk -rno LABEL "$1" 2>/dev/null) 25 | uuid=$(lsblk -rno UUID "$1" 2>/dev/null) 26 | 27 | # bind mounts do not have a UUID! 28 | 29 | case $bytag in 30 | '') 31 | [[ $uuid ]] && comment=("UUID=$uuid") 32 | [[ $label ]] && comment+=("LABEL=$(mangle "$label")") 33 | ;; 34 | LABEL) 35 | spec=$label 36 | [[ $uuid ]] && comment=("$src" "UUID=$uuid") 37 | ;; 38 | UUID) 39 | spec=$uuid 40 | comment=("$src") 41 | [[ $label ]] && comment+=("LABEL=$(mangle "$label")") 42 | ;; 43 | *) 44 | [[ $uuid ]] && comment=("$1" "UUID=$uuid") 45 | [[ $label ]] && comment+=("LABEL=$(mangle "$label")") 46 | [[ $bytag ]] && spec=$(lsblk -rno "$bytag" "$1" 2>/dev/null) 47 | ;; 48 | esac 49 | 50 | [[ $comment ]] && printf '# %s\n' "${comment[*]}" 51 | 52 | if [[ $spec ]]; then 53 | printf '%-20s' "$bytag=$(mangle "$spec")" 54 | else 55 | printf '%-20s' "$(mangle "$src")" 56 | fi 57 | } 58 | 59 | optstring_apply_quirks() { 60 | local varname=$1 fstype=$2 61 | 62 | # SELinux displays a 'seclabel' option in /proc/self/mountinfo. We can't know 63 | # if the system we're generating the fstab for has any support for SELinux (as 64 | # one might install Arch from a Fedora environment), so let's remove it. 65 | optstring_remove_option "$varname" seclabel 66 | 67 | # Prune 'relatime' option for any pseudofs. This seems to be a rampant 68 | # default which the kernel often exports even if the underlying filesystem 69 | # doesn't support it. Example: https://bugs.archlinux.org/task/54554. 70 | if awk -v fstype="$fstype" '$1 == fstype { exit 1 }' /proc/filesystems; then 71 | optstring_remove_option "$varname" relatime 72 | fi 73 | 74 | case $fstype in 75 | f2fs) 76 | # These are Kconfig options for f2fs. Kernels supporting the options will 77 | # only provide the negative versions of these (e.g. noacl), and vice versa 78 | # for kernels without support. 79 | optstring_remove_option "$varname" noacl,acl,nouser_xattr,user_xattr 80 | ;; 81 | vfat) 82 | # Before Linux v3.8, "cp" is prepended to the value of the codepage. 83 | if optstring_get_option "$varname" codepage && [[ $codepage = cp* ]]; then 84 | optstring_remove_option "$varname" codepage 85 | optstring_append_option "$varname" "codepage=${codepage#cp}" 86 | fi 87 | ;; 88 | esac 89 | } 90 | 91 | usage() { 92 | cat </dev/null; then 154 | # this is root. we can't possibly have more than one... 155 | pass=1 foundroot=1 156 | fi 157 | 158 | # if there's no fsck tool available, then only pass=0 makes sense. 159 | if ! fstype_has_fsck "$fstype"; then 160 | pass=0 161 | fi 162 | 163 | if [[ $fsroot != / ]]; then 164 | if [[ $fstype = btrfs ]]; then 165 | opts+=,subvol=${fsroot#/} 166 | else 167 | # it's a bind mount 168 | src=$(findmnt -funcevo TARGET "$src")$fsroot 169 | if [[ $src -ef $target ]]; then 170 | # hrmm, this is weird. we're probably looking at a file or directory 171 | # that was bound into a chroot from the host machine. Ignore it, 172 | # because this won't actually be a valid mount. Worst case, the user 173 | # just re-adds it. 174 | continue 175 | fi 176 | fstype=none 177 | opts+=,bind 178 | pass=0 179 | fi 180 | fi 181 | 182 | # filesystem quirks 183 | case $fstype in 184 | fuseblk) 185 | # well-behaved FUSE filesystems will report themselves as fuse.$fstype. 186 | # this is probably NTFS-3g, but let's just make sure. 187 | if ! newtype=$(lsblk -no FSTYPE "$src") || [[ -z $newtype ]]; then 188 | # avoid blanking out fstype, leading to an invalid fstab 189 | error 'Failed to derive real filesystem type for FUSE device on %s' "$target" 190 | else 191 | fstype=$newtype 192 | fi 193 | ;; 194 | esac 195 | 196 | optstring_apply_quirks "opts" "$fstype" 197 | 198 | # write one line 199 | write_source "$src" 200 | printf '\t%-10s' "/$(mangle "${target#/}")" "$fstype" "$opts" 201 | printf '\t%s %s' "$dump" "$pass" 202 | printf '\n\n' 203 | done 204 | 205 | # handle swaps devices 206 | { 207 | # ignore header 208 | read 209 | 210 | while read -r device type _ _ prio; do 211 | options=defaults 212 | if [[ $prio != -1 ]]; then 213 | options+=,pri=$prio 214 | fi 215 | 216 | # skip files marked deleted by the kernel 217 | [[ $device = *'\040(deleted)' ]] && continue 218 | 219 | if [[ $type = file ]]; then 220 | printf '%-20s' "$device" 221 | elif [[ $device = /dev/dm-+([0-9]) ]]; then 222 | # device mapper doesn't allow characters we need to worry 223 | # about being mangled, and it does the escaping of dashes 224 | # for us in sysfs. 225 | write_source "$(dm_name_for_devnode "$device")" 226 | else 227 | write_source "$(unmangle "$device")" 228 | fi 229 | 230 | printf '\t%-10s\t%-10s\t%-10s\t0 0\n\n' 'none' 'swap' "$options" 231 | done 232 | } /dev/null | grep -c 'not found') != 0 )); then 43 | # Missing lib. 44 | echo "$i:" >> "$TEMPDIR/raw.txt" 45 | ldd "$i" 2>/dev/null | grep 'not found' >> "$TEMPDIR/raw.txt" 46 | fi 47 | fi 48 | done 49 | done 50 | grep '^/' "$TEMPDIR/raw.txt" | sed -e 's/://g' >> "$TEMPDIR/affected-files.txt" 51 | # invoke pacman 52 | while read -r i; do 53 | pacman -Qo "$i" | awk '{print $4,$5}' >> "$TEMPDIR/pacman.txt" 54 | done < "$TEMPDIR/affected-files.txt" 55 | # clean list 56 | sort -u "$TEMPDIR/pacman.txt" >> "$TEMPDIR/possible-rebuilds.txt" 57 | 58 | msg "Files saved to %s" "$TEMPDIR" 59 | -------------------------------------------------------------------------------- /bin/mkchroot.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | chroot_version=@chroot_version@ 15 | 16 | LIBDIR='@libdir@' 17 | 18 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 19 | import ${LIBDIR}/util.sh 20 | import ${LIBDIR}/util-chroot.sh 21 | 22 | working_dir='' 23 | files=() 24 | 25 | nosetarch=false 26 | 27 | usage() { 28 | echo "Usage: ${0##*/} [options] working-dir package-list..." 29 | echo ' options:' 30 | echo ' -C Location of a pacman config file' 31 | echo ' -M Location of a makepkg config file' 32 | echo ' -U Set a specific mirror' 33 | echo ' -c Set pacman cache' 34 | echo ' -f Copy file from the host to the chroot' 35 | echo ' -s Do not run setarch' 36 | echo ' -h This message' 37 | exit 1 38 | } 39 | 40 | orig_argv=("$0" "$@") 41 | 42 | opts='hC:M:U:c:f:s' 43 | 44 | while getopts ${opts} arg; do 45 | case "${arg}" in 46 | C) pacman_conf="$OPTARG" ;; 47 | M) makepkg_conf="$OPTARG" ;; 48 | U) mirror="$OPTARG" ;; 49 | c) cache_dir="$OPTARG" ;; 50 | f) files+=("$OPTARG") ;; 51 | s) nosetarch=true ;; 52 | h|?) usage ;; 53 | *) error "invalid argument '%s'" "$arg"; usage ;; 54 | esac 55 | done 56 | shift $(($OPTIND - 1)) 57 | 58 | (( $# < 2 )) && die 'You must specify a directory and one or more packages.' 59 | 60 | check_root 61 | 62 | working_dir="$(readlink -f $1)" 63 | shift 1 64 | 65 | [[ -z $working_dir ]] && die 'Please specify a working directory.' 66 | 67 | if [[ -z $cache_dir ]]; then 68 | cache_dirs=($(pacman -v $cache_conf 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g')) 69 | else 70 | cache_dirs=(${cache_dir}) 71 | fi 72 | 73 | umask 0022 74 | 75 | #[[ -e $working_dir ]] && die "Working directory '%s' already exists" "$working_dir" 76 | 77 | #mkdir -p "$working_dir" 78 | 79 | [[ ! -d $working_dir ]] && mkdir -p "$working_dir" 80 | 81 | lock 9 "${working_dir}.lock" "Locking chroot" 82 | 83 | if is_btrfs "$working_dir"; then 84 | rmdir "$working_dir" 85 | if ! btrfs subvolume create "$working_dir"; then 86 | die "Couldn't create subvolume for '%s'" "$working_dir" 87 | fi 88 | chmod 0755 "$working_dir" 89 | fi 90 | 91 | for f in "${files[@]}"; do 92 | mkdir -p "$(dirname "$working_dir$f")" 93 | cp "$f" "$working_dir$f" 94 | done 95 | 96 | _env=() 97 | while read -r varname; do 98 | _env+=("$varname=${!varname}") 99 | done < <(declare -x | sed -r 's/^declare -x ([^=]*)=.*/\1/' | grep -i '_proxy$') 100 | env -i "${_env[@]}" \ 101 | basestrap -Gc ${pacman_conf:+-C "$pacman_conf"} "$working_dir" ${cache_dirs[@]/#/--cachedir=} "$@" || die 'Failed to install all packages' 102 | 103 | echo "$chroot_version" > "$working_dir/.artools" 104 | 105 | if [[ ! -f "$working_dir/etc/locale.gen.orig" ]];then 106 | mv "$working_dir/etc/locale.gen" "$working_dir/etc/locale.gen.orig" 107 | fi 108 | printf '%s.UTF-8 UTF-8\n' en_US de_DE > "$working_dir/etc/locale.gen" 109 | echo 'LANG=en_US.UTF-8' > "$working_dir/etc/locale.conf" 110 | 111 | dbus-uuidgen --ensure="$working_dir"/etc/machine-id 112 | 113 | chroot_args=(${pacman_conf:+-C "$pacman_conf"} ${makepkg_conf:+-M "$makepkg_conf"} ${cache_dir:+-c "$cache_dir"}) 114 | ${nosetarch} && chroot_args+=(${nosetarch:+-s}) 115 | 116 | exec chroot-run \ 117 | "${chroot_args[@]}" \ 118 | "$working_dir" locale-gen 119 | -------------------------------------------------------------------------------- /bin/mkchrootpkg.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | 16 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 17 | import ${LIBDIR}/util.sh 18 | import ${LIBDIR}/util-chroot.sh 19 | 20 | shopt -s nullglob 21 | 22 | usage() { 23 | echo "Usage: ${0##*/} [options] -r [--] [makepkg args]" 24 | echo ' Run this script in a PKGBUILD dir to build a package inside a' 25 | echo ' clean chroot. Arguments passed to this script after the' 26 | echo ' end-of-options marker (--) will be passed to makepkg.' 27 | echo '' 28 | echo ' The chroot dir consists of the following directories:' 29 | echo ' /{root, copy} but only "root" is required' 30 | echo ' by default. The working copy will be created as needed' 31 | echo '' 32 | echo 'The chroot "root" directory must be created via the following' 33 | echo 'command:' 34 | echo ' mkchroot /root base-devel' 35 | echo '' 36 | echo 'This script reads {SRC,SRCPKG,PKG,LOG}DEST, MAKEFLAGS and PACKAGER' 37 | echo 'from makepkg.conf(5), if those variables are not part of the' 38 | echo 'environment.' 39 | echo '' 40 | echo "Default makepkg args: ${default_makepkg_args[*]}" 41 | echo '' 42 | echo 'Flags:' 43 | echo '-h This help' 44 | echo '-c Clean the chroot before building' 45 | echo '-d Bind directory into build chroot as read-write' 46 | echo '-D Bind directory into build chroot as read-only' 47 | echo '-u Update the working copy of the chroot before building' 48 | echo ' This is useful for rebuilds without dirtying the pristine' 49 | echo ' chroot' 50 | echo '-r The chroot dir to use' 51 | echo '-I Install a package into the working copy of the chroot' 52 | echo '-l The directory to use as the working copy of the chroot' 53 | echo ' Useful for maintaining multiple copies' 54 | echo " Default: $copy" 55 | echo '-n Run namcap on the package' 56 | echo '-T Build in a temporary directory' 57 | echo '-U Run makepkg as a specified user' 58 | exit 1 59 | } 60 | 61 | sync_chroot() { 62 | local chrootdir=$1 63 | local copy=$2 64 | local copydir='' 65 | if [[ ${copy:0:1} = / ]]; then 66 | copydir=$copy 67 | else 68 | copydir="$chrootdir/$copy" 69 | fi 70 | 71 | if [[ "$chrootdir/root" -ef "$copydir" ]]; then 72 | error 'Cannot sync copy with itself: %s' "$copydir" 73 | return 1 74 | fi 75 | 76 | # Get a read lock on the root chroot to make 77 | # sure we don't clone a half-updated chroot 78 | slock 8 "$chrootdir/root.lock" \ 79 | "Locking clean chroot [%s]" "$chrootdir/root" 80 | 81 | stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copydir" 82 | if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then 83 | subvolume_delete_recursive "$copydir" || 84 | die "Unable to delete subvolume %s" "$copydir" 85 | btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null || 86 | die "Unable to create subvolume %s" "$copydir" 87 | else 88 | mkdir -p "$copydir" 89 | rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir" 90 | fi 91 | stat_done 92 | 93 | # Drop the read lock again 94 | lock_close 8 95 | 96 | # Update mtime 97 | touch "$copydir" 98 | } 99 | 100 | # Usage: delete_chroot $copydir [$copy] 101 | delete_chroot() { 102 | local copydir=$1 103 | local copy=${1:-$2} 104 | 105 | stat_busy "Removing chroot copy [%s]" "$copy" 106 | if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then 107 | subvolume_delete_recursive "$copydir" || 108 | die "Unable to delete subvolume %s" "$copydir" 109 | else 110 | # avoid change of filesystem in case of an umount failure 111 | rm --recursive --force --one-file-system "$copydir" || 112 | die "Unable to delete %s" "$copydir" 113 | fi 114 | 115 | # remove lock file 116 | rm -f "$copydir.lock" 117 | stat_done 118 | } 119 | 120 | # Usage: install_packages $copydir $pkgs... 121 | install_packages() { 122 | local copydir=$1 123 | local install_pkgs=("${@:2}") 124 | 125 | local -a pkgnames 126 | local ret 127 | 128 | pkgnames=("${install_pkgs[@]##*/}") 129 | 130 | cp -- "${install_pkgs[@]}" "$copydir/root/" 131 | chroot-run -r "${bindmounts_ro[*]}" -w "${bindmounts_rw[*]}" "$copydir" \ 132 | pacman -U --noconfirm -- "${pkgnames[@]/#//root/}" 133 | ret=$? 134 | rm -- "${pkgnames[@]/#/$copydir/root/}" 135 | 136 | return $ret 137 | } 138 | 139 | # Usage: prepare_chroot $copydir $HOME $keepbuilddir $run_namcap 140 | # Globals: 141 | # - MAKEFLAGS 142 | # - PACKAGER 143 | prepare_chroot() { 144 | local copydir=$1 145 | local USER_HOME=$2 146 | local keepbuilddir=$3 147 | local run_namcap=$4 148 | 149 | [[ $keepbuilddir = true ]] || rm -rf "$copydir/build" 150 | 151 | local builduser_uid="${SUDO_UID:-$UID}" 152 | local builduser_gid="$(id -g "$builduser_uid")" 153 | local install="install -o $builduser_uid -g $builduser_gid" 154 | local x 155 | 156 | # We can't use useradd without chrooting, otherwise it invokes PAM modules 157 | # which we might not be able to load (i.e. when building i686 packages on 158 | # an x86_64 host). 159 | sed -e '/^builduser:/d' -i "$copydir"/etc/{passwd,shadow,group} 160 | printf >>"$copydir/etc/group" 'builduser:x:%d:\n' $builduser_gid 161 | printf >>"$copydir/etc/passwd" 'builduser:x:%d:%d:builduser:/build:/bin/bash\n' $builduser_uid $builduser_gid 162 | printf >>"$copydir/etc/shadow" 'builduser:!!:%d::::::\n' "$(( $(date -u +%s) / 86400 ))" 163 | 164 | $install -d "$copydir"/{build,build/.gnupg,startdir,{pkg,srcpkg,src,log}dest} 165 | 166 | # for x in .gnupg/pubring.{kbx,gpg}; do 167 | # [[ -r $USER_HOME/$x ]] || continue 168 | # $install -m 644 "$USER_HOME/$x" "$copydir/build/$x" 169 | # done 170 | 171 | sed -e '/^MAKEFLAGS=/d' -e '/^PACKAGER=/d' -i "$copydir/etc/makepkg.conf" 172 | for x in BUILDDIR=/build PKGDEST=/pkgdest SRCPKGDEST=/srcpkgdest SRCDEST=/srcdest LOGDEST=/logdest \ 173 | "MAKEFLAGS='${MAKEFLAGS:-}'" "PACKAGER='${PACKAGER:-}'" 174 | do 175 | grep -q "^$x" "$copydir/etc/makepkg.conf" && continue 176 | echo "$x" >>"$copydir/etc/makepkg.conf" 177 | done 178 | 179 | cat > "$copydir/etc/sudoers.d/builduser-pacman" </dev/null || true 190 | printf '_chrootbuild "$@" || exit\n' 191 | 192 | if [[ $run_namcap = true ]]; then 193 | declare -f _chrootnamcap 194 | printf '_chrootnamcap || exit\n' 195 | fi 196 | } >"$copydir/chrootbuild" 197 | chmod +x "$copydir/chrootbuild" 198 | } 199 | 200 | # These functions aren't run in makechrootpkg, 201 | # so no global variables 202 | _chrootbuild() { 203 | # No coredumps 204 | ulimit -c 0 205 | 206 | # Work around chroot-run not giving a ctty 207 | #exec /dev/null 216 | 217 | sudo --preserve-env=SOURCE_DATE_EPOCH -iu builduser bash -c 'cd /startdir; makepkg "$@"' -bash "$@" 218 | 219 | ret=$? 220 | case $ret in 221 | 0|14) return 0;; 222 | *) return $ret;; 223 | esac 224 | } 225 | 226 | _chrootnamcap() { 227 | pacman -S --needed --noconfirm namcap 228 | for pkgfile in /startdir/PKGBUILD /pkgdest/*; do 229 | echo "Checking ${pkgfile##*/}" 230 | sudo -u builduser namcap "$pkgfile" 2>&1 | tee "/logdest/${pkgfile##*/}-namcap.log" 231 | done 232 | } 233 | 234 | # Usage: download_sources $copydir $src_owner 235 | # Globals: 236 | # - SRCDEST 237 | # - USER 238 | download_sources() { 239 | local copydir=$1 240 | local makepkg_user=$2 241 | 242 | local builddir 243 | builddir="$(mktemp -d)" 244 | # chmod 1777 "$builddir" 245 | chown "$makepkg_user:" "$builddir" 246 | 247 | # Ensure sources are downloaded 248 | sudo -u "$makepkg_user" --preserve-env=GNUPGHOME \ 249 | env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ 250 | makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o || 251 | die "Could not download sources." 252 | 253 | # Clean up garbage from verifysource 254 | rm -rf "$builddir" 255 | } 256 | 257 | # Usage: move_products $copydir $owner 258 | # Globals: 259 | # - PKGDEST 260 | # - LOGDEST 261 | move_products() { 262 | local copydir=$1 263 | local src_owner=$2 264 | 265 | local pkgfile 266 | for pkgfile in "$copydir"/pkgdest/*; do 267 | chown "$src_owner" "$pkgfile" 268 | mv "$pkgfile" "$PKGDEST" 269 | 270 | # Fix broken symlink because of temporary chroot PKGDEST /pkgdest 271 | if [[ "$PWD" != "$PKGDEST" && -L "$PWD/${pkgfile##*/}" ]]; then 272 | ln -sf "$PKGDEST/${pkgfile##*/}" 273 | fi 274 | done 275 | 276 | local l 277 | for l in "$copydir"/logdest/*; do 278 | [[ $l == */logpipe.* ]] && continue 279 | chown "$src_owner" "$l" 280 | mv "$l" "$LOGDEST" 281 | done 282 | 283 | for s in "$copydir"/srcpkgdest/*; do 284 | chown "$src_owner" "$s" 285 | mv "$s" "$SRCPKGDEST" 286 | 287 | # Fix broken symlink because of temporary chroot SRCPKGDEST /srcpkgdest 288 | if [[ "$PWD" != "$SRCPKGDEST" && -L "$PWD/${s##*/}" ]]; then 289 | ln -sf "$SRCPKGDEST/${s##*/}" 290 | fi 291 | done 292 | } 293 | # }}} 294 | 295 | orig_argv=("$0" "$@") 296 | 297 | main() { 298 | default_makepkg_args=(--syncdeps --noconfirm --log --holdver --skipinteg) 299 | makepkg_args=("${default_makepkg_args[@]}") 300 | keepbuilddir=false 301 | update_first=false 302 | clean_first=false 303 | run_namcap=false 304 | temp_chroot=false 305 | chrootdir= 306 | passeddir= 307 | makepkg_user= 308 | declare -ga install_pkgs 309 | declare -gi ret=0 310 | 311 | bindmounts_ro=() 312 | bindmounts_rw=() 313 | 314 | copy=$USER 315 | [[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER 316 | [[ -z "$copy" || $copy = root ]] && copy=copy 317 | src_owner=${SUDO_USER:-$USER} 318 | 319 | local opts='hcur:I:l:nTD:d:U:' 320 | 321 | while getopts ${opts} arg; do 322 | case "$arg" in 323 | c) clean_first=true ;; 324 | D) bindmounts_ro+=("$OPTARG") ;; 325 | d) bindmounts_rw+=("$OPTARG") ;; 326 | u) update_first=true ;; 327 | r) passeddir="$OPTARG" ;; 328 | I) install_pkgs+=("$OPTARG") ;; 329 | l) copy="$OPTARG" ;; 330 | n) run_namcap=true; makepkg_args+=(--install) ;; 331 | T) temp_chroot=true; copy+="-$$" ;; 332 | U) makepkg_user="$OPTARG" ;; 333 | h|*) usage ;; 334 | esac 335 | done 336 | 337 | [[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.' 338 | [[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.' 339 | makepkg_user=${makepkg_user:-${SUDO_USER:-$USER}} 340 | 341 | check_root SOURCE_DATE_EPOCH,GNUPGHOME 342 | 343 | # Canonicalize chrootdir, getting rid of trailing / 344 | chrootdir=$(readlink -e "$passeddir") 345 | [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" 346 | [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkchroot %s/root base-devel" "$chrootdir" 347 | 348 | if [[ ${copy:0:1} = / ]]; then 349 | copydir=$copy 350 | else 351 | copydir="$chrootdir/$copy" 352 | fi 353 | 354 | # Pass all arguments after -- right to makepkg 355 | makepkg_args+=("${@:$OPTIND}") 356 | 357 | # See if -R or -e was passed to makepkg 358 | for arg in "${makepkg_args[@]}"; do 359 | case ${arg%%=*} in 360 | --repackage|--noextract) keepbuilddir=true; break ;; 361 | --repackage|--noextract) keepbuilddir=true; break ;; 362 | --*) ;; 363 | -*R*|-*e*) keepbuilddir=true; break ;; 364 | esac 365 | done 366 | 367 | load_user_info 368 | 369 | umask 0022 370 | 371 | load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf" 372 | load_vars /etc/makepkg.conf 373 | 374 | # Use PKGBUILD directory if these don't exist 375 | [[ -d $PKGDEST ]] || PKGDEST=$PWD 376 | [[ -d $SRCDEST ]] || SRCDEST=$PWD 377 | [[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD 378 | [[ -d $LOGDEST ]] || LOGDEST=$PWD 379 | 380 | # Lock the chroot we want to use. We'll keep this lock until we exit. 381 | lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy" 382 | 383 | if [[ ! -d $copydir ]] || $clean_first; then 384 | sync_chroot "$chrootdir" "$copy" 385 | fi 386 | 387 | $update_first && chroot-run -r "${bindmounts_ro[*]}" -w "${bindmounts_rw[*]}" "$copydir" \ 388 | pacman -Syu --noconfirm 389 | 390 | if [[ -n ${install_pkgs[*]:-} ]]; then 391 | install_packages "$copydir" "${install_pkgs[@]}" 392 | ret=$? 393 | # If there is no PKGBUILD we have done 394 | [[ -f PKGBUILD ]] || return $ret 395 | fi 396 | 397 | if [[ "$(id -u "$makepkg_user")" == 0 ]]; then 398 | error "Running makepkg as root is not allowed." 399 | exit 1 400 | fi 401 | 402 | download_sources "$copydir" "$src_owner" 403 | 404 | prepare_chroot "$copydir" "$USER_HOME" "$keepbuilddir" "$run_namcap" 405 | 406 | bindmounts_rw+=("${PWD}:/startdir" "${SRCDEST}:/srcdest") 407 | 408 | if chroot-run -r "${bindmounts_ro[*]}" -w "${bindmounts_rw[*]}" "$copydir" \ 409 | /chrootbuild "${makepkg_args[@]}"; then 410 | move_products "$copydir" "$src_owner" 411 | else 412 | (( ret += 1 )) 413 | fi 414 | 415 | $temp_chroot && delete_chroot "$copydir" "$copy" 416 | 417 | if (( ret != 0 )); then 418 | if $temp_chroot; then 419 | die "Build failed" 420 | else 421 | die "Build failed, check %s/build" "$copydir" 422 | fi 423 | else 424 | true 425 | fi 426 | } 427 | 428 | main "$@" 429 | -------------------------------------------------------------------------------- /bin/mkpkgclean.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | SYSCONFDIR='@sysconfdir@' 16 | 17 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 18 | import ${LIBDIR}/util.sh 19 | 20 | prepare_clean(){ 21 | if [[ -n ${repository} ]];then 22 | storage_dir=${repos_root}/${repository}/os/${target_arch} 23 | paccache_args+=(-c "${storage_dir}" -k 1) 24 | else 25 | if [[ -n ${PKGDEST} ]];then 26 | storage_dir=${PKGDEST} 27 | paccache_args+=(-c "${storage_dir}" -k 4) 28 | else 29 | die "PKGDEST not set in makepkg.conf!" 30 | fi 31 | fi 32 | } 33 | 34 | display_settings(){ 35 | show_version 36 | show_config 37 | 38 | msg "OPTIONS:" 39 | msg2 "repository: %s" "${repository}" 40 | 41 | msg "PATH:" 42 | msg2 "storage_dir: %s" "${storage_dir}" 43 | 44 | msg "ARGS:" 45 | msg2 "paccache_args: %s" "${paccache_args[*]}" 46 | 47 | paccache "${paccache_args[@]}" 48 | } 49 | 50 | load_user_info 51 | 52 | load_config "${AT_USERCONFDIR}/artools.conf" || load_config "${SYSCONFDIR}/artools.conf" 53 | load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf" 54 | load_vars /etc/makepkg.conf 55 | 56 | clean=false 57 | pretend=false 58 | repository='' 59 | storage_dir='' 60 | paccache_args=(-v) 61 | 62 | usage() { 63 | echo "Usage: ${0##*/} [options]" 64 | echo " -d Directory [default:${repository}]" 65 | echo ' -c Clean up' 66 | echo ' -q Query settings and pretend cleaning' 67 | echo ' -h This help' 68 | echo '' 69 | echo '' 70 | exit $1 71 | } 72 | 73 | orig_argv=("$0" "$@") 74 | 75 | opts='d:cqh' 76 | 77 | while getopts "${opts}" arg; do 78 | case "${arg}" in 79 | d) repository="$OPTARG" ;; 80 | c) clean=true ; paccache_args+=(-r) ;; 81 | q) pretend=true; paccache_args+=(-d) ;; 82 | h|?) usage 0 ;; 83 | *) echo "invalid argument '${arg}'"; usage 1 ;; 84 | esac 85 | done 86 | 87 | shift $(($OPTIND - 1)) 88 | 89 | prepare_clean 90 | 91 | ${pretend} && display_settings && exit 1 92 | 93 | ${clean} && paccache "${paccache_args[@]}" 94 | -------------------------------------------------------------------------------- /bin/signfile.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | version=@version@ 13 | 14 | LIBDIR='@libdir@' 15 | 16 | [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh 17 | import ${LIBDIR}/util.sh 18 | 19 | load_user_info 20 | 21 | load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf" 22 | load_vars /etc/makepkg.conf 23 | 24 | file_to_sign="$1" 25 | 26 | if [ ! -e "$1" ]; then 27 | error "%s does not exist!" "$file_to_sign" 28 | exit 1 29 | fi 30 | 31 | msg2 "Signing [%s] with key %s" "${file_to_sign##*/}" "${GPGKEY}..." 32 | if [[ -n "${BUILDBOT_GPGP}" ]]; then 33 | gpg --batch --passphrase "${BUILDBOT_GPGP}" --detach-sign "$file_to_sign" 34 | else 35 | gpg --detach-sign --use-agent -u "${GPGKEY}" "$file_to_sign" 36 | fi 37 | -------------------------------------------------------------------------------- /data/artools.conf: -------------------------------------------------------------------------------- 1 | ############################################# 2 | ################ artools-base ############### 3 | ############################################# 4 | 5 | # build dir where buildpkg or buildiso chroots are created 6 | # chroots_dir=/var/lib/artools 7 | 8 | # the workspace directory 9 | # workspace_dir="/home/${OWNER}/artools-workspace" 10 | 11 | ############################################# 12 | ################ artools-pkg ################ 13 | ############################################# 14 | 15 | # host_tree_artix='https://github.com/artix-linux' 16 | 17 | # host_tree_arch=git://projects.archlinux.org/svntogit 18 | 19 | # default repos root 20 | # repos_root=${workspace_dir}/repos 21 | 22 | ############################################# 23 | ################ artools-iso ################ 24 | ############################################# 25 | 26 | # the iso storage directory 27 | # iso_pool="${workspace_dir}/iso" 28 | 29 | # the dist release; default: auto 30 | # iso_version=$(date +%Y%m%d) 31 | 32 | # possible values: openrc, (s6, runit) not yet supported 33 | # initsys="openrc" 34 | 35 | # unset defaults to given value 36 | # kernel="linux" 37 | 38 | # gpg key; leave empty or commented to skip sfs signing 39 | # gpgkey="" 40 | 41 | # set upload bandwidth limit in kB/s 42 | # uplimit=100 43 | 44 | # the torrent tracker urls, comma separated 45 | # tracker_url='udp://mirror.strits.dk:6969' 46 | 47 | # file_host="sourceforge.net" 48 | 49 | # the server user 50 | # account=[SetUser] 51 | 52 | # the server project 53 | # project="artix-linux" 54 | 55 | # host mirrors 56 | # host_mirrors=('netcologne' 'freefr' 'netix' 'kent' '10gbps-io') 57 | 58 | # Piece size, 2^n 59 | # piece_size=21 60 | -------------------------------------------------------------------------------- /data/makepkg.conf: -------------------------------------------------------------------------------- 1 | #!/hint/bash 2 | # 3 | # /etc/makepkg.conf 4 | # 5 | 6 | ######################################################################### 7 | # SOURCE ACQUISITION 8 | ######################################################################### 9 | # 10 | #-- The download utilities that makepkg should use to acquire sources 11 | # Format: 'protocol::agent' 12 | DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u' 13 | 'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u' 14 | 'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u' 15 | 'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u' 16 | 'rsync::/usr/bin/rsync --no-motd -z %u %o' 17 | 'scp::/usr/bin/scp -C %u %o') 18 | 19 | # Other common tools: 20 | # /usr/bin/snarf 21 | # /usr/bin/lftpget -c 22 | # /usr/bin/wget 23 | 24 | #-- The package required by makepkg to download VCS sources 25 | # Format: 'protocol::package' 26 | VCSCLIENTS=('bzr::bzr' 27 | 'git::git' 28 | 'hg::mercurial' 29 | 'svn::subversion') 30 | 31 | ######################################################################### 32 | # ARCHITECTURE, COMPILE FLAGS 33 | ######################################################################### 34 | # 35 | CARCH="x86_64" 36 | CHOST="x86_64-pc-linux-gnu" 37 | 38 | #-- Compiler and Linker Flags 39 | CPPFLAGS="-D_FORTIFY_SOURCE=2" 40 | CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt" 41 | CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt" 42 | LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now" 43 | #-- Make Flags: change this for DistCC/SMP systems 44 | #MAKEFLAGS="-j2" 45 | #-- Debugging flags 46 | DEBUG_CFLAGS="-g -fvar-tracking-assignments" 47 | DEBUG_CXXFLAGS="-g -fvar-tracking-assignments" 48 | 49 | ######################################################################### 50 | # BUILD ENVIRONMENT 51 | ######################################################################### 52 | # 53 | # Defaults: BUILDENV=(!distcc !color !ccache check !sign) 54 | # A negated environment option will do the opposite of the comments below. 55 | # 56 | #-- distcc: Use the Distributed C/C++/ObjC compiler 57 | #-- color: Colorize output messages 58 | #-- ccache: Use ccache to cache compilation 59 | #-- check: Run the check() function if present in the PKGBUILD 60 | #-- sign: Generate PGP signature file 61 | # 62 | BUILDENV=(!distcc color !ccache check !sign) 63 | # 64 | #-- If using DistCC, your MAKEFLAGS will also need modification. In addition, 65 | #-- specify a space-delimited list of hosts running in the DistCC cluster. 66 | #DISTCC_HOSTS="" 67 | # 68 | #-- Specify a directory for package building. 69 | #BUILDDIR=/tmp/makepkg 70 | 71 | ######################################################################### 72 | # GLOBAL PACKAGE OPTIONS 73 | # These are default values for the options=() settings 74 | ######################################################################### 75 | # 76 | # Default: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug) 77 | # A negated option will do the opposite of the comments below. 78 | # 79 | #-- strip: Strip symbols from binaries/libraries 80 | #-- docs: Save doc directories specified by DOC_DIRS 81 | #-- libtool: Leave libtool (.la) files in packages 82 | #-- staticlibs: Leave static library (.a) files in packages 83 | #-- emptydirs: Leave empty directories in packages 84 | #-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip 85 | #-- purge: Remove files specified by PURGE_TARGETS 86 | #-- debug: Add debugging flags as specified in DEBUG_* variables 87 | # 88 | OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug) 89 | 90 | #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 91 | INTEGRITY_CHECK=(md5) 92 | #-- Options to be used when stripping binaries. See `man strip' for details. 93 | STRIP_BINARIES="--strip-all" 94 | #-- Options to be used when stripping shared libraries. See `man strip' for details. 95 | STRIP_SHARED="--strip-unneeded" 96 | #-- Options to be used when stripping static libraries. See `man strip' for details. 97 | STRIP_STATIC="--strip-debug" 98 | #-- Manual (man and info) directories to compress (if zipman is specified) 99 | MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info}) 100 | #-- Doc directories to remove (if !docs is specified) 101 | DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc}) 102 | #-- Files to be removed from all packages (if purge is specified) 103 | PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) 104 | #-- Directory to store source code in for debug packages 105 | DBGSRCDIR="/usr/src/debug" 106 | 107 | ######################################################################### 108 | # PACKAGE OUTPUT 109 | ######################################################################### 110 | # 111 | # Default: put built package and cached source in build directory 112 | # 113 | #-- Destination: specify a fixed directory where all packages will be placed 114 | #PKGDEST=/home/packages 115 | #-- Source cache: specify a fixed directory where source files will be cached 116 | #SRCDEST=/home/sources 117 | #-- Source packages: specify a fixed directory where all src packages will be placed 118 | #SRCPKGDEST=/home/srcpackages 119 | #-- Log files: specify a fixed directory where all log files will be placed 120 | #LOGDEST=/home/makepkglogs 121 | #-- Packager: name/email of the person or organization building packages 122 | #PACKAGER="John Doe " 123 | #-- Specify a key to use for package signing 124 | #GPGKEY="" 125 | 126 | ######################################################################### 127 | # COMPRESSION DEFAULTS 128 | ######################################################################### 129 | # 130 | COMPRESSGZ=(gzip -c -f -n) 131 | COMPRESSBZ2=(bzip2 -c -f) 132 | COMPRESSXZ=(xz -c -z -) 133 | COMPRESSLRZ=(lrzip -q) 134 | COMPRESSLZO=(lzop -q) 135 | COMPRESSZ=(compress -c -f) 136 | 137 | ######################################################################### 138 | # EXTENSION DEFAULTS 139 | ######################################################################### 140 | # 141 | # WARNING: Do NOT modify these variables unless you know what you are 142 | # doing. 143 | # 144 | PKGEXT='.pkg.tar.xz' 145 | SRCEXT='.src.tar.gz' 146 | -------------------------------------------------------------------------------- /data/mkinitcpio.conf: -------------------------------------------------------------------------------- 1 | MODULES=(loop dm-snapshot) 2 | 3 | HOOKS=(base udev artix_shutdown artix artix_loop_mnt artix_pxe_common artix_pxe_http artix_pxe_nbd artix_pxe_nfs artix_kms modconf block filesystems keyboard keymap) 4 | 5 | COMPRESSION="xz" 6 | -------------------------------------------------------------------------------- /data/pacman-default.conf: -------------------------------------------------------------------------------- 1 | # 2 | # /etc/pacman.conf 3 | # 4 | # See the pacman.conf(5) manpage for option and repository directives 5 | 6 | # 7 | # GENERAL OPTIONS 8 | # 9 | [options] 10 | # The following paths are commented out with their default values listed. 11 | # If you wish to use different paths, uncomment and update the paths. 12 | #RootDir = / 13 | #DBPath = /var/lib/pacman/ 14 | #CacheDir = /var/cache/pacman/pkg/ 15 | #LogFile = /var/log/pacman.log 16 | #GPGDir = /etc/pacman.d/gnupg/ 17 | #HookDir = /etc/pacman.d/hooks/ 18 | HoldPkg = pacman glibc 19 | #XferCommand = /usr/bin/curl -C - -f %u > %o 20 | #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u 21 | #CleanMethod = KeepInstalled 22 | #UseDelta = 0.7 23 | Architecture = auto 24 | 25 | # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup 26 | #IgnorePkg = 27 | #IgnoreGroup = 28 | 29 | #NoUpgrade = 30 | #NoExtract = 31 | 32 | # Misc options 33 | #UseSyslog 34 | #Color 35 | #TotalDownload 36 | CheckSpace 37 | VerbosePkgLists 38 | 39 | # By default, pacman accepts packages signed by keys that its local keyring 40 | # trusts (see pacman-key and its man page), as well as unsigned packages. 41 | SigLevel = Required DatabaseOptional 42 | LocalFileSigLevel = Optional 43 | #RemoteFileSigLevel = Required 44 | 45 | # NOTE: You must run `pacman-key --init` before first using pacman; the local 46 | # keyring can then be populated with the keys of all official Artix Linux 47 | # packagers with `pacman-key --populate archlinux artix`. 48 | 49 | # 50 | # REPOSITORIES 51 | # - can be defined here or included from another file 52 | # - pacman will search repositories in the order defined here 53 | # - local/custom mirrors can be added here or in separate files 54 | # - repositories listed first will take precedence when packages 55 | # have identical names, regardless of version number 56 | # - URLs will have $repo replaced by the name of the current repo 57 | # - URLs will have $arch replaced by the name of the architecture 58 | # 59 | # Repository entries are of the format: 60 | # [repo-name] 61 | # Server = ServerName 62 | # Include = IncludePath 63 | # 64 | # The header [repo-name] is crucial - it must be present and 65 | # uncommented to enable the repo. 66 | # 67 | 68 | # The gremlins repositories are disabled by default. To enable, uncomment the 69 | # repo name header and Include lines. You can add preferred servers immediately 70 | # after the header, and they will be used before the default mirrors. 71 | 72 | #[gremlins] 73 | #Include = /etc/pacman.d/mirrorlist 74 | 75 | [system] 76 | Include = /etc/pacman.d/mirrorlist 77 | 78 | [world] 79 | Include = /etc/pacman.d/mirrorlist 80 | 81 | #[galaxy-gremlins] 82 | #Include = /etc/pacman.d/mirrorlist 83 | 84 | [galaxy] 85 | Include = /etc/pacman.d/mirrorlist 86 | 87 | # If you want to run 32 bit applications on your x86_64 system, 88 | # enable the lib32 repositories as required here. 89 | 90 | #[lib32-gremlins] 91 | #Include = /etc/pacman.d/mirrorlist 92 | 93 | #[lib32] 94 | #Include = /etc/pacman.d/mirrorlist 95 | 96 | # An example of a custom package repository. See the pacman manpage for 97 | # tips on creating your own repositories. 98 | #[custom] 99 | #SigLevel = Optional TrustAll 100 | #Server = file:///home/custompkgs 101 | 102 | # 103 | # ARCHLINUX 104 | # 105 | 106 | #[testing] 107 | #Include = /etc/pacman.d/mirrorlist-arch 108 | 109 | [extra] 110 | Include = /etc/pacman.d/mirrorlist-arch 111 | 112 | #[community-testing] 113 | #Include = /etc/pacman.d/mirrorlist-arch 114 | 115 | [community] 116 | Include = /etc/pacman.d/mirrorlist-arch 117 | 118 | #[multilib-testing] 119 | #Include = /etc/pacman.d/mirrorlist-arch 120 | 121 | #[multilib] 122 | #Include = /etc/pacman.d/mirrorlist-arch 123 | -------------------------------------------------------------------------------- /data/pacman-goblins.conf: -------------------------------------------------------------------------------- 1 | # 2 | # /etc/pacman.conf 3 | # 4 | # See the pacman.conf(5) manpage for option and repository directives 5 | 6 | # 7 | # GENERAL OPTIONS 8 | # 9 | [options] 10 | # The following paths are commented out with their default values listed. 11 | # If you wish to use different paths, uncomment and update the paths. 12 | #RootDir = / 13 | #DBPath = /var/lib/pacman/ 14 | #CacheDir = /var/cache/pacman/pkg/ 15 | #LogFile = /var/log/pacman.log 16 | #GPGDir = /etc/pacman.d/gnupg/ 17 | #HookDir = /etc/pacman.d/hooks/ 18 | HoldPkg = pacman glibc 19 | #XferCommand = /usr/bin/curl -C - -f %u > %o 20 | #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u 21 | #CleanMethod = KeepInstalled 22 | #UseDelta = 0.7 23 | Architecture = auto 24 | 25 | # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup 26 | #IgnorePkg = 27 | #IgnoreGroup = 28 | 29 | #NoUpgrade = 30 | #NoExtract = 31 | 32 | # Misc options 33 | #UseSyslog 34 | #Color 35 | #TotalDownload 36 | CheckSpace 37 | VerbosePkgLists 38 | 39 | # By default, pacman accepts packages signed by keys that its local keyring 40 | # trusts (see pacman-key and its man page), as well as unsigned packages. 41 | SigLevel = Required DatabaseOptional 42 | LocalFileSigLevel = Optional 43 | #RemoteFileSigLevel = Required 44 | 45 | # NOTE: You must run `pacman-key --init` before first using pacman; the local 46 | # keyring can then be populated with the keys of all official Artix Linux 47 | # packagers with `pacman-key --populate archlinux artix`. 48 | 49 | # 50 | # REPOSITORIES 51 | # - can be defined here or included from another file 52 | # - pacman will search repositories in the order defined here 53 | # - local/custom mirrors can be added here or in separate files 54 | # - repositories listed first will take precedence when packages 55 | # have identical names, regardless of version number 56 | # - URLs will have $repo replaced by the name of the current repo 57 | # - URLs will have $arch replaced by the name of the architecture 58 | # 59 | # Repository entries are of the format: 60 | # [repo-name] 61 | # Server = ServerName 62 | # Include = IncludePath 63 | # 64 | # The header [repo-name] is crucial - it must be present and 65 | # uncommented to enable the repo. 66 | # 67 | 68 | # The gremlins repositories are disabled by default. To enable, uncomment the 69 | # repo name header and Include lines. You can add preferred servers immediately 70 | # after the header, and they will be used before the default mirrors. 71 | 72 | [goblins] 73 | Include = /etc/pacman.d/mirrorlist 74 | 75 | [gremlins] 76 | Include = /etc/pacman.d/mirrorlist 77 | 78 | [system] 79 | Include = /etc/pacman.d/mirrorlist 80 | 81 | [world] 82 | Include = /etc/pacman.d/mirrorlist 83 | 84 | [galaxy-goblins] 85 | Include = /etc/pacman.d/mirrorlist 86 | 87 | [galaxy-gremlins] 88 | Include = /etc/pacman.d/mirrorlist 89 | 90 | [galaxy] 91 | Include = /etc/pacman.d/mirrorlist 92 | 93 | # If you want to run 32 bit applications on your x86_64 system, 94 | # enable the lib32 repositories as required here. 95 | 96 | #[lib32-goblins] 97 | #Include = /etc/pacman.d/mirrorlist 98 | 99 | #[lib32-gremlins] 100 | #Include = /etc/pacman.d/mirrorlist 101 | 102 | #[lib32] 103 | #Include = /etc/pacman.d/mirrorlist 104 | 105 | # An example of a custom package repository. See the pacman manpage for 106 | # tips on creating your own repositories. 107 | #[custom] 108 | #SigLevel = Optional TrustAll 109 | #Server = file:///home/custompkgs 110 | 111 | # 112 | # ARCHLINUX 113 | # 114 | 115 | [staging] 116 | Include = /etc/pacman.d/mirrorlist-arch 117 | 118 | [testing] 119 | Include = /etc/pacman.d/mirrorlist-arch 120 | 121 | [extra] 122 | Include = /etc/pacman.d/mirrorlist-arch 123 | 124 | [community-staging] 125 | Include = /etc/pacman.d/mirrorlist-arch 126 | 127 | [community-testing] 128 | Include = /etc/pacman.d/mirrorlist-arch 129 | 130 | [community] 131 | Include = /etc/pacman.d/mirrorlist-arch 132 | 133 | #[multilib-staging] 134 | #Include = /etc/pacman.d/mirrorlist-arch 135 | 136 | #[multilib-testing] 137 | #Include = /etc/pacman.d/mirrorlist-arch 138 | 139 | #[multilib] 140 | #Include = /etc/pacman.d/mirrorlist-arch 141 | -------------------------------------------------------------------------------- /data/pacman-gremlins.conf: -------------------------------------------------------------------------------- 1 | # 2 | # /etc/pacman.conf 3 | # 4 | # See the pacman.conf(5) manpage for option and repository directives 5 | 6 | # 7 | # GENERAL OPTIONS 8 | # 9 | [options] 10 | # The following paths are commented out with their default values listed. 11 | # If you wish to use different paths, uncomment and update the paths. 12 | #RootDir = / 13 | #DBPath = /var/lib/pacman/ 14 | #CacheDir = /var/cache/pacman/pkg/ 15 | #LogFile = /var/log/pacman.log 16 | #GPGDir = /etc/pacman.d/gnupg/ 17 | #HookDir = /etc/pacman.d/hooks/ 18 | HoldPkg = pacman glibc 19 | #XferCommand = /usr/bin/curl -C - -f %u > %o 20 | #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u 21 | #CleanMethod = KeepInstalled 22 | #UseDelta = 0.7 23 | Architecture = auto 24 | 25 | # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup 26 | #IgnorePkg = 27 | #IgnoreGroup = 28 | 29 | #NoUpgrade = 30 | #NoExtract = 31 | 32 | # Misc options 33 | #UseSyslog 34 | #Color 35 | #TotalDownload 36 | CheckSpace 37 | VerbosePkgLists 38 | 39 | # By default, pacman accepts packages signed by keys that its local keyring 40 | # trusts (see pacman-key and its man page), as well as unsigned packages. 41 | SigLevel = Required DatabaseOptional 42 | LocalFileSigLevel = Optional 43 | #RemoteFileSigLevel = Required 44 | 45 | # NOTE: You must run `pacman-key --init` before first using pacman; the local 46 | # keyring can then be populated with the keys of all official Artix Linux 47 | # packagers with `pacman-key --populate archlinux artix`. 48 | 49 | # 50 | # REPOSITORIES 51 | # - can be defined here or included from another file 52 | # - pacman will search repositories in the order defined here 53 | # - local/custom mirrors can be added here or in separate files 54 | # - repositories listed first will take precedence when packages 55 | # have identical names, regardless of version number 56 | # - URLs will have $repo replaced by the name of the current repo 57 | # - URLs will have $arch replaced by the name of the architecture 58 | # 59 | # Repository entries are of the format: 60 | # [repo-name] 61 | # Server = ServerName 62 | # Include = IncludePath 63 | # 64 | # The header [repo-name] is crucial - it must be present and 65 | # uncommented to enable the repo. 66 | # 67 | 68 | # The gremlins repositories are disabled by default. To enable, uncomment the 69 | # repo name header and Include lines. You can add preferred servers immediately 70 | # after the header, and they will be used before the default mirrors. 71 | 72 | [gremlins] 73 | Include = /etc/pacman.d/mirrorlist 74 | 75 | [system] 76 | Include = /etc/pacman.d/mirrorlist 77 | 78 | [world] 79 | Include = /etc/pacman.d/mirrorlist 80 | 81 | [galaxy-gremlins] 82 | Include = /etc/pacman.d/mirrorlist 83 | 84 | [galaxy] 85 | Include = /etc/pacman.d/mirrorlist 86 | 87 | # If you want to run 32 bit applications on your x86_64 system, 88 | # enable the lib32 repositories as required here. 89 | 90 | #[lib32-gremlins] 91 | #Include = /etc/pacman.d/mirrorlist 92 | 93 | #[lib32] 94 | #Include = /etc/pacman.d/mirrorlist 95 | 96 | # An example of a custom package repository. See the pacman manpage for 97 | # tips on creating your own repositories. 98 | #[custom] 99 | #SigLevel = Optional TrustAll 100 | #Server = file:///home/custompkgs 101 | 102 | # 103 | # ARCHLINUX 104 | # 105 | 106 | [testing] 107 | Include = /etc/pacman.d/mirrorlist-arch 108 | 109 | [extra] 110 | Include = /etc/pacman.d/mirrorlist-arch 111 | 112 | [community-testing] 113 | Include = /etc/pacman.d/mirrorlist-arch 114 | 115 | [community] 116 | Include = /etc/pacman.d/mirrorlist-arch 117 | 118 | #[multilib-testing] 119 | #Include = /etc/pacman.d/mirrorlist-arch 120 | 121 | #[multilib] 122 | #Include = /etc/pacman.d/mirrorlist-arch 123 | -------------------------------------------------------------------------------- /data/pacman-lib32-goblins.conf: -------------------------------------------------------------------------------- 1 | # 2 | # /etc/pacman.conf 3 | # 4 | # See the pacman.conf(5) manpage for option and repository directives 5 | 6 | # 7 | # GENERAL OPTIONS 8 | # 9 | [options] 10 | # The following paths are commented out with their default values listed. 11 | # If you wish to use different paths, uncomment and update the paths. 12 | #RootDir = / 13 | #DBPath = /var/lib/pacman/ 14 | #CacheDir = /var/cache/pacman/pkg/ 15 | #LogFile = /var/log/pacman.log 16 | #GPGDir = /etc/pacman.d/gnupg/ 17 | #HookDir = /etc/pacman.d/hooks/ 18 | HoldPkg = pacman glibc 19 | #XferCommand = /usr/bin/curl -C - -f %u > %o 20 | #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u 21 | #CleanMethod = KeepInstalled 22 | #UseDelta = 0.7 23 | Architecture = auto 24 | 25 | # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup 26 | #IgnorePkg = 27 | #IgnoreGroup = 28 | 29 | #NoUpgrade = 30 | #NoExtract = 31 | 32 | # Misc options 33 | #UseSyslog 34 | #Color 35 | #TotalDownload 36 | CheckSpace 37 | VerbosePkgLists 38 | 39 | # By default, pacman accepts packages signed by keys that its local keyring 40 | # trusts (see pacman-key and its man page), as well as unsigned packages. 41 | SigLevel = Required DatabaseOptional 42 | LocalFileSigLevel = Optional 43 | #RemoteFileSigLevel = Required 44 | 45 | # NOTE: You must run `pacman-key --init` before first using pacman; the local 46 | # keyring can then be populated with the keys of all official Artix Linux 47 | # packagers with `pacman-key --populate archlinux artix`. 48 | 49 | # 50 | # REPOSITORIES 51 | # - can be defined here or included from another file 52 | # - pacman will search repositories in the order defined here 53 | # - local/custom mirrors can be added here or in separate files 54 | # - repositories listed first will take precedence when packages 55 | # have identical names, regardless of version number 56 | # - URLs will have $repo replaced by the name of the current repo 57 | # - URLs will have $arch replaced by the name of the architecture 58 | # 59 | # Repository entries are of the format: 60 | # [repo-name] 61 | # Server = ServerName 62 | # Include = IncludePath 63 | # 64 | # The header [repo-name] is crucial - it must be present and 65 | # uncommented to enable the repo. 66 | # 67 | 68 | # The gremlins repositories are disabled by default. To enable, uncomment the 69 | # repo name header and Include lines. You can add preferred servers immediately 70 | # after the header, and they will be used before the default mirrors. 71 | 72 | [goblins] 73 | Include = /etc/pacman.d/mirrorlist 74 | 75 | [gremlins] 76 | Include = /etc/pacman.d/mirrorlist 77 | 78 | [system] 79 | Include = /etc/pacman.d/mirrorlist 80 | 81 | [world] 82 | Include = /etc/pacman.d/mirrorlist 83 | 84 | [galaxy-goblins] 85 | Include = /etc/pacman.d/mirrorlist 86 | 87 | [galaxy-gremlins] 88 | Include = /etc/pacman.d/mirrorlist 89 | 90 | [galaxy] 91 | Include = /etc/pacman.d/mirrorlist 92 | 93 | # If you want to run 32 bit applications on your x86_64 system, 94 | # enable the lib32 repositories as required here. 95 | 96 | [lib32-goblins] 97 | Include = /etc/pacman.d/mirrorlist 98 | 99 | [lib32-gremlins] 100 | Include = /etc/pacman.d/mirrorlist 101 | 102 | [lib32] 103 | Include = /etc/pacman.d/mirrorlist 104 | 105 | # An example of a custom package repository. See the pacman manpage for 106 | # tips on creating your own repositories. 107 | #[custom] 108 | #SigLevel = Optional TrustAll 109 | #Server = file:///home/custompkgs 110 | 111 | # 112 | # ARCHLINUX 113 | # 114 | 115 | [staging] 116 | Include = /etc/pacman.d/mirrorlist-arch 117 | 118 | [testing] 119 | Include = /etc/pacman.d/mirrorlist-arch 120 | 121 | [extra] 122 | Include = /etc/pacman.d/mirrorlist-arch 123 | 124 | [community-staging] 125 | Include = /etc/pacman.d/mirrorlist-arch 126 | 127 | [community-testing] 128 | Include = /etc/pacman.d/mirrorlist-arch 129 | 130 | [community] 131 | Include = /etc/pacman.d/mirrorlist-arch 132 | 133 | [multilib-staging] 134 | Include = /etc/pacman.d/mirrorlist-arch 135 | 136 | [multilib-testing] 137 | Include = /etc/pacman.d/mirrorlist-arch 138 | 139 | [multilib] 140 | Include = /etc/pacman.d/mirrorlist-arch 141 | -------------------------------------------------------------------------------- /data/pacman-lib32-gremlins.conf: -------------------------------------------------------------------------------- 1 | # 2 | # /etc/pacman.conf 3 | # 4 | # See the pacman.conf(5) manpage for option and repository directives 5 | 6 | # 7 | # GENERAL OPTIONS 8 | # 9 | [options] 10 | # The following paths are commented out with their default values listed. 11 | # If you wish to use different paths, uncomment and update the paths. 12 | #RootDir = / 13 | #DBPath = /var/lib/pacman/ 14 | #CacheDir = /var/cache/pacman/pkg/ 15 | #LogFile = /var/log/pacman.log 16 | #GPGDir = /etc/pacman.d/gnupg/ 17 | #HookDir = /etc/pacman.d/hooks/ 18 | HoldPkg = pacman glibc 19 | #XferCommand = /usr/bin/curl -C - -f %u > %o 20 | #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u 21 | #CleanMethod = KeepInstalled 22 | #UseDelta = 0.7 23 | Architecture = auto 24 | 25 | # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup 26 | #IgnorePkg = 27 | #IgnoreGroup = 28 | 29 | #NoUpgrade = 30 | #NoExtract = 31 | 32 | # Misc options 33 | #UseSyslog 34 | #Color 35 | #TotalDownload 36 | CheckSpace 37 | VerbosePkgLists 38 | 39 | # By default, pacman accepts packages signed by keys that its local keyring 40 | # trusts (see pacman-key and its man page), as well as unsigned packages. 41 | SigLevel = Required DatabaseOptional 42 | LocalFileSigLevel = Optional 43 | #RemoteFileSigLevel = Required 44 | 45 | # NOTE: You must run `pacman-key --init` before first using pacman; the local 46 | # keyring can then be populated with the keys of all official Artix Linux 47 | # packagers with `pacman-key --populate archlinux artix`. 48 | 49 | # 50 | # REPOSITORIES 51 | # - can be defined here or included from another file 52 | # - pacman will search repositories in the order defined here 53 | # - local/custom mirrors can be added here or in separate files 54 | # - repositories listed first will take precedence when packages 55 | # have identical names, regardless of version number 56 | # - URLs will have $repo replaced by the name of the current repo 57 | # - URLs will have $arch replaced by the name of the architecture 58 | # 59 | # Repository entries are of the format: 60 | # [repo-name] 61 | # Server = ServerName 62 | # Include = IncludePath 63 | # 64 | # The header [repo-name] is crucial - it must be present and 65 | # uncommented to enable the repo. 66 | # 67 | 68 | # The gremlins repositories are disabled by default. To enable, uncomment the 69 | # repo name header and Include lines. You can add preferred servers immediately 70 | # after the header, and they will be used before the default mirrors. 71 | 72 | [gremlins] 73 | Include = /etc/pacman.d/mirrorlist 74 | 75 | [system] 76 | Include = /etc/pacman.d/mirrorlist 77 | 78 | [world] 79 | Include = /etc/pacman.d/mirrorlist 80 | 81 | [galaxy-gremlins] 82 | Include = /etc/pacman.d/mirrorlist 83 | 84 | [galaxy] 85 | Include = /etc/pacman.d/mirrorlist 86 | 87 | # If you want to run 32 bit applications on your x86_64 system, 88 | # enable the lib32 repositories as required here. 89 | 90 | [lib32-gremlins] 91 | Include = /etc/pacman.d/mirrorlist 92 | 93 | [lib32] 94 | Include = /etc/pacman.d/mirrorlist 95 | 96 | # An example of a custom package repository. See the pacman manpage for 97 | # tips on creating your own repositories. 98 | #[custom] 99 | #SigLevel = Optional TrustAll 100 | #Server = file:///home/custompkgs 101 | 102 | # 103 | # ARCHLINUX 104 | # 105 | 106 | [testing] 107 | Include = /etc/pacman.d/mirrorlist-arch 108 | 109 | [extra] 110 | Include = /etc/pacman.d/mirrorlist-arch 111 | 112 | [community-testing] 113 | Include = /etc/pacman.d/mirrorlist-arch 114 | 115 | [community] 116 | Include = /etc/pacman.d/mirrorlist-arch 117 | 118 | [multilib-testing] 119 | Include = /etc/pacman.d/mirrorlist-arch 120 | 121 | [multilib] 122 | Include = /etc/pacman.d/mirrorlist-arch 123 | -------------------------------------------------------------------------------- /data/pacman-lib32.conf: -------------------------------------------------------------------------------- 1 | # 2 | # /etc/pacman.conf 3 | # 4 | # See the pacman.conf(5) manpage for option and repository directives 5 | 6 | # 7 | # GENERAL OPTIONS 8 | # 9 | [options] 10 | # The following paths are commented out with their default values listed. 11 | # If you wish to use different paths, uncomment and update the paths. 12 | #RootDir = / 13 | #DBPath = /var/lib/pacman/ 14 | #CacheDir = /var/cache/pacman/pkg/ 15 | #LogFile = /var/log/pacman.log 16 | #GPGDir = /etc/pacman.d/gnupg/ 17 | #HookDir = /etc/pacman.d/hooks/ 18 | HoldPkg = pacman glibc 19 | #XferCommand = /usr/bin/curl -C - -f %u > %o 20 | #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u 21 | #CleanMethod = KeepInstalled 22 | #UseDelta = 0.7 23 | Architecture = auto 24 | 25 | # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup 26 | #IgnorePkg = 27 | #IgnoreGroup = 28 | 29 | #NoUpgrade = 30 | #NoExtract = 31 | 32 | # Misc options 33 | #UseSyslog 34 | #Color 35 | #TotalDownload 36 | CheckSpace 37 | VerbosePkgLists 38 | 39 | # By default, pacman accepts packages signed by keys that its local keyring 40 | # trusts (see pacman-key and its man page), as well as unsigned packages. 41 | SigLevel = Required DatabaseOptional 42 | LocalFileSigLevel = Optional 43 | #RemoteFileSigLevel = Required 44 | 45 | # NOTE: You must run `pacman-key --init` before first using pacman; the local 46 | # keyring can then be populated with the keys of all official Artix Linux 47 | # packagers with `pacman-key --populate archlinux artix`. 48 | 49 | # 50 | # REPOSITORIES 51 | # - can be defined here or included from another file 52 | # - pacman will search repositories in the order defined here 53 | # - local/custom mirrors can be added here or in separate files 54 | # - repositories listed first will take precedence when packages 55 | # have identical names, regardless of version number 56 | # - URLs will have $repo replaced by the name of the current repo 57 | # - URLs will have $arch replaced by the name of the architecture 58 | # 59 | # Repository entries are of the format: 60 | # [repo-name] 61 | # Server = ServerName 62 | # Include = IncludePath 63 | # 64 | # The header [repo-name] is crucial - it must be present and 65 | # uncommented to enable the repo. 66 | # 67 | 68 | # The gremlins repositories are disabled by default. To enable, uncomment the 69 | # repo name header and Include lines. You can add preferred servers immediately 70 | # after the header, and they will be used before the default mirrors. 71 | 72 | #[gremlins] 73 | #Include = /etc/pacman.d/mirrorlist 74 | 75 | [system] 76 | Include = /etc/pacman.d/mirrorlist 77 | 78 | [world] 79 | Include = /etc/pacman.d/mirrorlist 80 | 81 | #[galaxy-gremlins] 82 | #Include = /etc/pacman.d/mirrorlist 83 | 84 | [galaxy] 85 | Include = /etc/pacman.d/mirrorlist 86 | 87 | # If you want to run 32 bit applications on your x86_64 system, 88 | # enable the lib32 repositories as required here. 89 | 90 | #[lib32-gremlins] 91 | #Include = /etc/pacman.d/mirrorlist 92 | 93 | [lib32] 94 | Include = /etc/pacman.d/mirrorlist 95 | 96 | # An example of a custom package repository. See the pacman manpage for 97 | # tips on creating your own repositories. 98 | #[custom] 99 | #SigLevel = Optional TrustAll 100 | #Server = file:///home/custompkgs 101 | 102 | # 103 | # ARCHLINUX 104 | # 105 | 106 | #[testing] 107 | #Include = /etc/pacman.d/mirrorlist-arch 108 | 109 | [extra] 110 | Include = /etc/pacman.d/mirrorlist-arch 111 | 112 | #[community-testing] 113 | #Include = /etc/pacman.d/mirrorlist-arch 114 | 115 | [community] 116 | Include = /etc/pacman.d/mirrorlist-arch 117 | 118 | #[multilib-testing] 119 | #Include = /etc/pacman.d/mirrorlist-arch 120 | 121 | [multilib] 122 | Include = /etc/pacman.d/mirrorlist-arch 123 | -------------------------------------------------------------------------------- /data/patches/artix-bash.patch: -------------------------------------------------------------------------------- 1 | --- /dev/null 2 | +++ b/artix.bashrc 3 | @@ -0,0 +1,46 @@ 4 | +use_color=true 5 | + 6 | +# Set colorful PS1 only on colorful terminals. 7 | +# dircolors --print-database uses its own built-in database 8 | +# instead of using /etc/DIR_COLORS. Try to use the external file 9 | +# first to take advantage of user additions. Use internal bash 10 | +# globbing instead of external grep binary. 11 | +safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM 12 | +match_lhs="" 13 | +[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)" 14 | +[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(/dev/null \ 17 | + && match_lhs=$(dircolors --print-database) 18 | +[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true 19 | + 20 | +if ${use_color} ; then 21 | + # Enable colors for ls, etc. Prefer ~/.dir_colors #64489 22 | + if type -P dircolors >/dev/null ; then 23 | + if [[ -f ~/.dir_colors ]] ; then 24 | + eval $(dircolors -b ~/.dir_colors) 25 | + elif [[ -f /etc/DIR_COLORS ]] ; then 26 | + eval $(dircolors -b /etc/DIR_COLORS) 27 | + fi 28 | + fi 29 | + 30 | + if [[ ${EUID} == 0 ]] ; then 31 | + PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] ' 32 | + else 33 | + PS1='\[\033[01;36m\][\u@\h\[\033[01;37m\] \W\[\033[01;36m\]]\$\[\033[00m\] ' 34 | + fi 35 | + 36 | + alias ls='ls --color=auto' 37 | + alias grep='grep --colour=auto' 38 | + alias egrep='egrep --colour=auto' 39 | + alias fgrep='fgrep --colour=auto' 40 | +else 41 | + if [[ ${EUID} == 0 ]] ; then 42 | + # show root@ when we don't have colors 43 | + PS1='\u@\h \W \$ ' 44 | + else 45 | + PS1='\u@\h \w \$ ' 46 | + fi 47 | +fi 48 | + 49 | +unset use_color safe_term match_lhs sh 50 | --- a/dot.bashrc 51 | +++ b/dot.bashrc 52 | @@ -5,5 +5,5 @@ 53 | # If not running interactively, don't do anything 54 | [[ $- != *i* ]] && return 55 | 56 | -alias ls='ls --color=auto' 57 | -PS1='[\u@\h \W]\$ ' 58 | +# alias ls='ls --color=auto' 59 | +# PS1='[\u@\h \W]\$ ' 60 | 61 | --- a/system.bashrc 62 | +++ a/system.bashrc 63 | @@ -1,5 +1,5 @@ 64 | # 65 | -# /etc/bash.bashrc 66 | +# /etc/bash/bashrc 67 | # 68 | 69 | # If not running interactively, don't do anything 70 | @@ -19,4 +19,8 @@ 71 | ;; 72 | esac 73 | 74 | +for sh in /etc/bash/bashrc.d/*.bashrc ; do 75 | + [[ -r ${sh} ]] && source "${sh}" 76 | +done 77 | + 78 | [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion 79 | 80 | --- a/system.bash_logout 81 | +++ a/system.bash_logout 82 | @@ -1,3 +1,3 @@ 83 | # 84 | -# /etc/bash.bash_logout 85 | +# /etc/bash/bash_logout 86 | # 87 | 88 | -------------------------------------------------------------------------------- /initcpio/Makefile: -------------------------------------------------------------------------------- 1 | DIRMODE = -dm0755 2 | MODE = -m0755 3 | RM = rm -f 4 | 5 | CPIOHOOKS = \ 6 | $(wildcard hooks/*) 7 | 8 | CPIOINST = \ 9 | $(wildcard install/*) 10 | 11 | SCRIPT = \ 12 | $(wildcard script/*) 13 | 14 | install_initcpio: 15 | install $(DIRMODE) $(DESTDIR)$(CPIODIR)/hooks 16 | install $(MODE) $(CPIOHOOKS) $(DESTDIR)$(CPIODIR)/hooks 17 | 18 | install $(DIRMODE) $(DESTDIR)$(CPIODIR)/install 19 | install $(MODE) $(CPIOINST) $(DESTDIR)$(CPIODIR)/install 20 | install $(MODE) $(SCRIPT) $(DESTDIR)$(CPIODIR) 21 | 22 | uninstall_initcpio: 23 | for f in $(notdir $(CPIOHOOKS)); do $(RM) $(DESTDIR)$(CPIODIR)/hooks/$$f; done 24 | for f in $(notdir $(CPIOINST)); do $(RM) $(DESTDIR)$(CPIODIR)/install/$$f; done 25 | for f in $(notdir $(SCRIPT)); do $(RM) $(DESTDIR)$(CPIODIR)/$$f; done 26 | 27 | install: install_initcpio 28 | 29 | uninstall: uninstall_initcpio 30 | 31 | .PHONY: install uninstall 32 | -------------------------------------------------------------------------------- /initcpio/hooks/artix: -------------------------------------------------------------------------------- 1 | # args: source, newroot, mountpoint 2 | _mnt_dmsnapshot() { 3 | local img="${1}" 4 | local mnt="${2}" 5 | local img_fullname="${img##*/}"; 6 | local img_name="${img_fullname%%.*}" 7 | local dm_snap_name="${dm_snap_prefix}_${img_name}" 8 | local ro_dev ro_dev_size rw_dev 9 | 10 | ro_dev=$(losetup --find --show --read-only "${img}") 11 | echo ${ro_dev} >> /run/artix/used_block_devices 12 | ro_dev_size=$(blockdev --getsz ${ro_dev}) 13 | 14 | if [[ "${cow_persistent}" == "P" ]]; then 15 | if [[ -f "/run/artix/cowspace/${cow_directory}/${img_name}.cow" ]]; then 16 | msg ":: Found '/run/artix/cowspace/${cow_directory}/${img_name}.cow', using as persistent." 17 | else 18 | msg ":: Creating '/run/artix/cowspace/${cow_directory}/${img_name}.cow' as persistent." 19 | truncate -s "${cow_spacesize}" "/run/artix/cowspace/${cow_directory}/${img_name}.cow" 20 | fi 21 | else 22 | if [[ -f "/run/artix/cowspace/${cow_directory}/${img_name}.cow" ]]; then 23 | msg ":: Found '/run/artix/cowspace/${cow_directory}/${img_name}.cow' but non-persistent requested, removing." 24 | rm -f "/run/artix/cowspace/${cow_directory}/${img_name}.cow" 25 | fi 26 | msg ":: Creating '/run/artix/cowspace/${cow_directory}/${img_name}.cow' as non-persistent." 27 | truncate -s "${cow_spacesize}" "/run/artix/cowspace/${cow_directory}/${img_name}.cow" 28 | fi 29 | 30 | rw_dev=$(losetup --find --show "/run/artix/cowspace/${cow_directory}/${img_name}.cow") 31 | echo ${rw_dev} >> /run/artix/used_block_devices 32 | 33 | dmsetup create ${dm_snap_name} --table "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} ${cow_chunksize}" 34 | 35 | if [[ "${cow_persistent}" != "P" ]]; then 36 | rm -f "/run/artix/cowspace/${cow_directory}/${img_name}.cow" 37 | fi 38 | 39 | _mnt_dev "/dev/mapper/${dm_snap_name}" "${mnt}" "-w" "defaults" 40 | echo $(readlink -f /dev/mapper/${dm_snap_name}) >> /run/artix/used_block_devices 41 | } 42 | 43 | # args: source, newroot, mountpoint 44 | _mnt_overlayfs() { 45 | local src="${1}" 46 | local newroot="${2}" 47 | local mnt="${3}" 48 | local work_dir="/run/artix/overlay_root/work" 49 | local upper_dir="/run/artix/overlay_root/upper" 50 | 51 | mkdir -p "${upper_dir}" "${work_dir}" 52 | 53 | mount -t overlay overlay -o lowerdir="${src}",upperdir="${upper_dir}",workdir="${work_dir}" "${newroot}${mnt}" 54 | } 55 | 56 | # args: /path/to/image_file, mountpoint 57 | _mnt_sfs() { 58 | local img="${1}" 59 | local mnt="${2}" 60 | local img_fullname="${img##*/}" 61 | local sfs_dev 62 | local oper=$( [[ -n "${ip}" && -n "${miso_http_srv}" ]] && echo "mv" || echo "cp" ) 63 | 64 | if [[ "${copytoram}" == "y" ]]; then 65 | msg -n ":: Copying squashfs image to RAM..." 66 | if ! "${oper}" "${img}" "/run/artix/copytoram/${img_fullname}" ; then 67 | echo "ERROR: while copy '${img}' to '/run/artix/copytoram/${img_fullname}'" 68 | launch_interactive_shell 69 | fi 70 | img="/run/artix/copytoram/${img_fullname}" 71 | msg "done." 72 | fi 73 | sfs_dev=$(losetup --find --show --read-only "${img}") 74 | echo ${sfs_dev} >> /run/artix/used_block_devices 75 | _mnt_dev "${sfs_dev}" "${mnt}" "-r" "defaults" 76 | } 77 | 78 | # args: device, mountpoint, flags, opts 79 | _mnt_dev() { 80 | local dev="${1}" 81 | local mnt="${2}" 82 | local flg="${3}" 83 | local opts="${4}" 84 | 85 | mkdir -p "${mnt}" 86 | 87 | msg ":: Mounting '${dev}' to '${mnt}'" 88 | 89 | while ! poll_device "${dev}" 30; do 90 | echo "ERROR: '${dev}' device did not show up after 30 seconds..." 91 | echo " Falling back to interactive prompt" 92 | echo " You can try to fix the problem manually, log out when you are finished" 93 | launch_interactive_shell 94 | done 95 | 96 | if mount -o "${opts}" "${flg}" "${dev}" "${mnt}"; then 97 | msg ":: Device '${dev}' mounted successfully." 98 | else 99 | echo "ERROR; Failed to mount '${dev}'" 100 | echo " Falling back to interactive prompt" 101 | echo " You can try to fix the problem manually, log out when you are finished" 102 | launch_interactive_shell 103 | fi 104 | } 105 | 106 | _verify_checksum() { 107 | local _status 108 | cd "/run/artix/bootmnt/${artixbasedir}/${arch}" 109 | sha512sum -c $1.sha512 > /tmp/checksum.log 2>&1 110 | _status=$? 111 | cd "${OLDPWD}" 112 | return ${_status} 113 | } 114 | 115 | _verify_signature() { 116 | local _status 117 | cd "/run/artix/bootmnt/${artixbasedir}/${arch}" 118 | gpg --homedir /gpg --status-fd 1 --verify $1.sfs.sig 2>/dev/null | grep -qE '^\[GNUPG:\] GOODSIG' 119 | _status=$? 120 | cd "${OLDPWD}" 121 | return ${_status} 122 | } 123 | 124 | run_hook() { 125 | [[ -z "${arch}" ]] && arch="$(uname -m)" 126 | [[ -z "${copytoram_size}" ]] && copytoram_size="75%" 127 | [[ -z "${artixbasedir}" ]] && artixbasedir="artix" 128 | 129 | [[ -z "${dm_snap_prefix}" ]] && dm_snap_prefix="arch" 130 | [[ -z "${artixdevice}" ]] && artixdevice="/dev/disk/by-label/${artixlabel}" 131 | [[ -z "${cow_spacesize}" ]] && cow_spacesize="256M" 132 | [[ -z "${overlay_root_size}" ]] && overlay_root_size="75%" 133 | 134 | if [[ -n "${cow_label}" ]]; then 135 | cow_device="/dev/disk/by-label/${cow_label}" 136 | [[ -z "${cow_persistent}" ]] && cow_persistent="P" 137 | elif [[ -n "${cow_device}" ]]; then 138 | [[ -z "${cow_persistent}" ]] && cow_persistent="P" 139 | else 140 | cow_persistent="N" 141 | fi 142 | 143 | [[ -z "${cow_flags}" ]] && cow_flags="defaults" 144 | [[ -z "${cow_directory}" ]] && cow_directory="persistent_${artixlabel}/${arch}" 145 | [[ -z "${cow_chunksize}" ]] && cow_chunksize="8" 146 | 147 | # set mount handler for artix 148 | mount_handler="artix_mount_handler" 149 | } 150 | 151 | # This function is called normally from init script, but it can be called 152 | # as chain from other mount handlers. 153 | # args: /path/to/newroot 154 | artix_mount_handler() { 155 | local newroot="${1}" 156 | 157 | if ! mountpoint -q "/run/artix/bootmnt"; then 158 | _mnt_dev "${artixdevice}" "/run/artix/bootmnt" "-r" "defaults" 159 | if [[ "${copytoram}" != "y" ]]; then 160 | echo $(readlink -f ${artixdevice}) >> /run/artix/used_block_devices 161 | fi 162 | fi 163 | 164 | if [[ "${checksum}" == "y" ]]; then 165 | for fs in rootfs desktopfs livefs;do 166 | if [[ -f "/run/artix/bootmnt/${artixbasedir}/${arch}/${fs}.sfs" ]]; then 167 | if [[ -f "/run/artix/bootmnt/${artixbasedir}/${arch}/${fs}.sha512" ]]; then 168 | msg -n ":: Self-test requested, please wait..." 169 | if _verify_checksum "${fs}"; then 170 | msg "done. Checksum is OK, continue booting." 171 | else 172 | echo "ERROR: one or more files are corrupted" 173 | echo "see /tmp/checksum.log for details" 174 | launch_interactive_shell 175 | fi 176 | else 177 | echo "ERROR: checksum=y option specified but ${artixbasedir}/${arch}/${fs}.sha512 not found" 178 | launch_interactive_shell 179 | fi 180 | fi 181 | done 182 | fi 183 | 184 | if [[ "${verify}" == "y" ]]; then 185 | for fs in rootfs desktopfs livefs;do 186 | if [[ -f "/run/artix/bootmnt/${artixbasedir}/${arch}/${fs}.sfs" ]]; then 187 | if [[ -f "/run/artix/bootmnt/${artixbasedir}/${arch}/${fs}.sfs.sig" ]]; then 188 | msg -n ":: Signature verification requested, please wait..." 189 | if _verify_signature "${fs}"; then 190 | msg "done. Signature is OK, continue booting." 191 | else 192 | echo "ERROR: one or more files are corrupted" 193 | launch_interactive_shell 194 | fi 195 | else 196 | echo "ERROR: verify=y option specified but ${artixbasedir}/${arch}/${fs}.sfs.sig not found" 197 | launch_interactive_shell 198 | fi 199 | fi 200 | done 201 | fi 202 | 203 | if [[ "${copytoram}" == "y" ]]; then 204 | msg ":: Mounting /run/artix/copytoram (tmpfs) filesystem, size=${copytoram_size}" 205 | mkdir -p /run/artix/copytoram 206 | mount -t tmpfs -o "size=${copytoram_size}",mode=0755 copytoram /run/artix/copytoram 207 | fi 208 | 209 | if [[ -n "${cow_device}" ]]; then 210 | _mnt_dev "${cow_device}" "/run/artix/cowspace" "-r" "${cow_flags}" 211 | echo $(readlink -f ${cow_device}) >> /run/artix/used_block_devices 212 | mount -o remount,rw "/run/artix/cowspace" 213 | else 214 | msg ":: Mounting /run/artix/cowspace (tmpfs) filesystem, size=${cow_spacesize}..." 215 | mkdir -p /run/artix/cowspace 216 | mount -t tmpfs -o "size=${cow_spacesize}",mode=0755 cowspace /run/artix/cowspace 217 | fi 218 | mkdir -p -m 0700 "/run/artix/cowspace/${cow_directory}" 219 | 220 | msg -n ":: Mounting overlay root (tmpfs) filesystem, size=${overlay_root_size}..." 221 | mkdir -p /run/artix/overlay_root 222 | mount -t tmpfs -o "size=${overlay_root_size}",mode=0755 overlay_root /run/artix/overlay_root 223 | 224 | local src="/run/artix/bootmnt/${artixbasedir}/${arch}" 225 | local dest_sfs="/run/artix/sfs" dest_img="/run/artix/img" 226 | local lower_dir 227 | 228 | for sfs in livefs desktopfs rootfs;do 229 | if [[ -f "${src}/${sfs}.sfs" ]]; then 230 | _mnt_sfs "${src}/${sfs}.sfs" "${dest_sfs}/${sfs}" 231 | if [[ -f "${dest_sfs}/${sfs}/${sfs}.img" ]]; then 232 | mkdir -p ${dest_img} 233 | lower_dir=${lower_dir:-}${lower_dir:+:}"${dest_img}/${sfs}" 234 | _mnt_dmsnapshot "${dest_sfs}/${sfs}/${sfs}.img" "${dest_img}/${sfs}" 235 | else 236 | lower_dir=${lower_dir:-}${lower_dir:+:}"${dest_sfs}/${sfs}" 237 | fi 238 | fi 239 | done 240 | 241 | _mnt_overlayfs "${lower_dir}" "${newroot}" "/" 242 | 243 | if [[ "${copytoram}" == "y" ]]; then 244 | umount -d /run/artix/bootmnt 245 | mkdir -p /run/artix/bootmnt/${artixbasedir}/${arch} 246 | mount -o bind /run/artix/copytoram /run/artix/bootmnt/${artixbasedir}/${arch} 247 | fi 248 | } 249 | 250 | # vim:ft=sh:ts=4:sw=4:et: 251 | -------------------------------------------------------------------------------- /initcpio/hooks/artix_loop_mnt: -------------------------------------------------------------------------------- 1 | # vim: set ft=sh: 2 | 3 | run_hook () { 4 | [[ -n "${img_label}" ]] && img_dev="/dev/disk/by-label/${img_label}" 5 | [[ -z "${img_flags}" ]] && img_flags="defaults" 6 | if [[ -n "${img_dev}" && -n "${img_loop}" ]]; then 7 | mount_handler="artix_loop_mount_handler" 8 | fi 9 | } 10 | 11 | artix_loop_mount_handler () { 12 | newroot="${1}" 13 | 14 | local _dev_loop 15 | 16 | msg ":: Setup a loop device from ${img_loop} located at device ${img_dev}" 17 | _mnt_dev "${img_dev}" "/run/artix/img_dev" "-r" "${img_flags}" 18 | if [[ "${copytoram}" != "y" ]]; then 19 | echo $(readlink -f ${img_dev}) >> /run/artix/used_block_devices 20 | fi 21 | 22 | if _dev_loop=$(losetup --find --show --read-only "/run/artix/img_dev/${img_loop}"); then 23 | artixdevice="${_dev_loop}" 24 | else 25 | echo "ERROR: Setting loopback device for file '/run/artix/img_dev/${img_loop}'" 26 | launch_interactive_shell 27 | fi 28 | 29 | artix_mount_handler ${newroot} 30 | 31 | if [[ "${copytoram}" == "y" ]]; then 32 | losetup -d ${_dev_loop} 2>/dev/null 33 | umount /run/artix/img_dev 34 | fi 35 | } 36 | -------------------------------------------------------------------------------- /initcpio/hooks/artix_pxe_common: -------------------------------------------------------------------------------- 1 | # vim: set ft=sh: 2 | 3 | run_hook () { 4 | # Do *not* declare 'bootif_dev' local! We need it in run_latehook(). 5 | local i net_mac bootif_mac 6 | # These variables will be parsed from /tmp/net-*.conf generated by ipconfig 7 | local DEVICE 8 | local IPV4ADDR IPV4BROADCAST IPV4NETMASK IPV4GATEWAY IPV4DNS0 IPV4DNS1 9 | local HOSTNAME DNSDOMAIN NISDOMAIN ROOTSERVER ROOTPATH 10 | local filename 11 | # /tmp/net-*.conf 12 | 13 | if [[ -n "${ip}" ]]; then 14 | if [[ -n "${BOOTIF}" ]]; then 15 | bootif_mac=${BOOTIF#01-} 16 | bootif_mac=${bootif_mac//-/:} 17 | for i in /sys/class/net/*/address; do 18 | read net_mac < ${i} 19 | if [[ "${bootif_mac}" == "${net_mac}" ]]; then 20 | bootif_dev=${i#/sys/class/net/} 21 | bootif_dev=${bootif_dev%/address} 22 | break 23 | fi 24 | done 25 | if [[ "${ip}" == "dhcp" ]]; then 26 | ip=":::::${bootif_dev}:dhcp" 27 | else 28 | ip="${ip}::${bootif_dev}" 29 | fi 30 | fi 31 | 32 | # setup network and save some values 33 | if ! ipconfig -t 20 "ip=${ip}"; then 34 | echo "ERROR; Failed to configure network" 35 | echo " Falling back to interactive prompt" 36 | echo " You can try to fix the problem manually, log out when you are finished" 37 | launch_interactive_shell 38 | fi 39 | 40 | . /tmp/net-*.conf 41 | 42 | pxeserver=${ROOTSERVER} 43 | 44 | # setup DNS resolver 45 | if [[ "${IPV4DNS0}" != "0.0.0.0" ]]; then 46 | echo "# added by artix_pxe_common hook" > /etc/resolv.conf 47 | echo "nameserver ${IPV4DNS0}" >> /etc/resolv.conf 48 | fi 49 | if [[ "${IPV4DNS1}" != "0.0.0.0" ]]; then 50 | echo "nameserver ${IPV4DNS1}" >> /etc/resolv.conf 51 | fi 52 | if [[ -n "${DNSDOMAIN}" ]]; then 53 | echo "search ${DNSDOMAIN}" >> /etc/resolv.conf 54 | echo "domain ${DNSDOMAIN}" >> /etc/resolv.conf 55 | fi 56 | fi 57 | } 58 | 59 | run_latehook () { 60 | if [[ -n "${ip}" ]]; then 61 | [[ -z "${copy_resolvconf}" ]] && copy_resolvconf="y" 62 | 63 | if [[ "${copytoram}" == "y" ]]; then 64 | if [[ -n "${bootif_dev}" ]]; then 65 | ip addr flush dev "${bootif_dev}" 66 | ip link set "${bootif_dev}" down 67 | fi 68 | elif [[ "${copy_resolvconf}" != "n" && -f /etc/resolv.conf ]]; then 69 | cp /etc/resolv.conf /new_root/etc/resolv.conf 70 | fi 71 | fi 72 | } 73 | -------------------------------------------------------------------------------- /initcpio/hooks/artix_pxe_http: -------------------------------------------------------------------------------- 1 | # vim: set ft=sh: 2 | 3 | run_hook() { 4 | if [[ -n "${ip}" && -n "${artix_http_srv}" ]]; then 5 | 6 | # booting with http is always copy-to-ram, so set here to make sure 7 | # addresses are flushed and interface is set down 8 | copytoram="y" 9 | 10 | artix_http_srv=$(eval echo ${artix_http_srv}) 11 | [[ -z "${artix_http_spc}" ]] && artix_http_spc="75%" 12 | 13 | mount_handler="artix_pxe_http_mount_handler" 14 | fi 15 | } 16 | 17 | # Fetch a file with CURL 18 | # 19 | # $1 URL 20 | # $2 Destination directory inside httpspace/${artixbasedir} 21 | _curl_get() { 22 | local _url="${1}" 23 | local _dst="${2}" 24 | 25 | msg ":: Downloading '${_url}'" 26 | if ! curl -L -f -o "/run/artix/httpspace/${artixbasedir}${_dst}/${_url##*/}" --create-dirs "${_url}"; then 27 | echo "ERROR: Downloading '${_url}'" 28 | echo " Falling back to interactive prompt" 29 | echo " You can try to fix the problem manually, log out when you are finished" 30 | launch_interactive_shell 31 | fi 32 | } 33 | 34 | artix_pxe_http_mount_handler () { 35 | newroot="${1}" 36 | 37 | msg ":: Mounting /run/artix/httpspace (tmpfs) filesystem, size='${artix_http_spc}'" 38 | mkdir -p "/run/artix/httpspace" 39 | mount -t tmpfs -o size="${artix_http_spc}",mode=0755 httpspace "/run/artix/httpspace" 40 | 41 | local _src=${artix_http_srv}${artixbasedir}/${arch} 42 | 43 | for sfs in livefs desktopfs rootfs;do 44 | if [[ ! -z "$( curl -s --head "${_src}/${sfs}.sfs" | grep "OK" )" ]]; then 45 | _curl_get "${_src}/${sfs}.sfs" "/${arch}" 46 | 47 | if [[ "${checksum}" == "y" ]]; then 48 | _curl_get "${_src}/${sfs}.md5" "/${arch}" 49 | fi 50 | if [[ "${verify}" == "y" ]]; then 51 | _curl_get "${_src}/${sfs}.sfs.sig" "/${arch}" 52 | fi 53 | fi 54 | done 55 | mkdir -p "/run/artix/bootmnt" 56 | mount -o bind /run/artix/httpspace /run/artix/bootmnt 57 | 58 | artix_mount_handler ${newroot} 59 | } 60 | -------------------------------------------------------------------------------- /initcpio/hooks/artix_pxe_nbd: -------------------------------------------------------------------------------- 1 | # vim: set ft=sh: 2 | 3 | run_earlyhook() { 4 | if [[ -n "${ip}" && -n "${artix_nbd_srv}" ]]; then 5 | # Module autoloading like with loop devices does not work, doing manually... 6 | modprobe nbd 2> /dev/null 7 | fi 8 | } 9 | 10 | run_hook() { 11 | if [[ -n "${ip}" && -n "${artix_nbd_srv}" ]]; then 12 | 13 | artix_nbd_srv=$(eval echo ${artix_nbd_srv}) 14 | [[ -z "${artix_nbd_name}" ]] && artix_nbd_name="artix" 15 | 16 | mount_handler="artix_pxe_nbd_mount_handler" 17 | fi 18 | } 19 | 20 | artix_pxe_nbd_mount_handler () { 21 | newroot="${1}" 22 | 23 | msg ":: Waiting for boot device..." 24 | while ! poll_device /dev/nbd0 30; do 25 | echo "ERROR: boot device didn't show up after 30 seconds..." 26 | echo " Falling back to interactive prompt" 27 | echo " You can try to fix the problem manually, log out when you are finished" 28 | launch_interactive_shell 29 | done 30 | 31 | msg ":: Setup NBD from ${artix_nbd_srv} at /dev/nbd0" 32 | if [[ "${copytoram}" != "n" ]]; then 33 | nbd-client ${artix_nbd_srv} -N ${artix_nbd_name} /dev/nbd0 34 | copytoram="y" 35 | else 36 | nbd-client ${artix_nbd_srv} -N ${artix_nbd_name} -persist /dev/nbd0 37 | fi 38 | 39 | artixdevice=/dev/nbd0 40 | 41 | artix_mount_handler ${newroot} 42 | 43 | if [[ "${copytoram}" == "y" ]]; then 44 | msg ":: Disconnect NBD from ${artix_nbd_srv} at /dev/nbd0" 45 | nbd-client -d /dev/nbd0 46 | fi 47 | } 48 | -------------------------------------------------------------------------------- /initcpio/hooks/artix_pxe_nfs: -------------------------------------------------------------------------------- 1 | # vim: set ft=sh: 2 | 3 | run_hook() { 4 | if [[ -n "${ip}" && -n "${artix_nfs_srv}" ]]; then 5 | 6 | artix_nfs_srv=$(eval echo ${artix_nfs_srv}) 7 | [[ -n "${artix_nfs_opt}" ]] && artix_nfs_opt="-o ${artix_nfs_opt}" 8 | 9 | mount_handler="artix_nfs_mount_handler" 10 | fi 11 | } 12 | 13 | artix_nfs_mount_handler() { 14 | newroot="${1}" 15 | mkdir -p "/run/artix/bootmnt" 16 | msg ":: Mounting '${artix_nfs_srv}'" 17 | # Do not put "${artix_nfs_opt}" nfsmount fails! 18 | if ! nfsmount ${artix_nfs_opt} "${artix_nfs_srv}" "/run/artix/bootmnt"; then 19 | echo "ERROR: Mounting '${artix_nfs_srv}'" 20 | echo " Falling back to interactive prompt" 21 | echo " You can try to fix the problem manually, log out when you are finished" 22 | launch_interactive_shell 23 | fi 24 | 25 | if [[ "${copytoram}" != "n" ]]; then 26 | copytoram="y" 27 | fi 28 | 29 | artix_mount_handler ${newroot} 30 | } 31 | -------------------------------------------------------------------------------- /initcpio/hooks/artix_shutdown: -------------------------------------------------------------------------------- 1 | run_cleanuphook() { 2 | rm -rf /usr/lib/modules 3 | cp -ax / /run/initramfs 4 | } 5 | 6 | # vim: set ft=sh ts=4 sw=4 et: 7 | -------------------------------------------------------------------------------- /initcpio/install/artix: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | build() { 4 | add_module "cdrom" 5 | add_module "loop" 6 | add_module "dm-snapshot" 7 | add_module "overlay" 8 | 9 | add_runscript 10 | 11 | add_binary /usr/lib/udev/cdrom_id 12 | add_binary blockdev 13 | add_binary dmsetup 14 | add_binary losetup 15 | add_binary mountpoint 16 | add_binary truncate 17 | add_binary gpg 18 | add_binary grep 19 | 20 | add_file /usr/lib/udev/rules.d/60-cdrom_id.rules 21 | add_file /usr/lib/udev/rules.d/10-dm.rules 22 | add_file /usr/lib/udev/rules.d/95-dm-notify.rules 23 | add_file /usr/lib/initcpio/udev/11-dm-initramfs.rules /usr/lib/udev/rules.d/11-dm-initramfs.rules 24 | if [[ $ARTIX_GNUPG_FD ]]; then 25 | mkdir -p "$BUILDROOT$dest"/gpg 26 | gpg --homedir "$BUILDROOT$dest"/gpg --import <&$ARTIX_GNUPG_FD 27 | fi 28 | } 29 | 30 | # vim: set ft=sh ts=4 sw=4 et: 31 | -------------------------------------------------------------------------------- /initcpio/install/artix_kms: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | build() { 4 | add_module "radeon" 5 | add_module "nouveau" 6 | add_module "i915" 7 | add_module "via-agp" 8 | add_module "sis-agp" 9 | add_module "intel-agp" 10 | } 11 | 12 | help() { 13 | cat << HELPEOF 14 | Adds all common KMS drivers to the initramfs image. 15 | HELPEOF 16 | } 17 | -------------------------------------------------------------------------------- /initcpio/install/artix_loop_mnt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | build() { 4 | add_runscript 5 | } 6 | 7 | help() { 8 | cat< $BUILDROOT/etc/nsswitch.conf 18 | } 19 | 20 | help() { 21 | cat< /dev/null; then 17 | umount -d ${_lup} 18 | fi 19 | done 20 | 21 | # Unmount the space used to store *.cow. 22 | umount /oldrun/artix/cowspace 23 | 24 | # Unmount boot device if needed (no copytoram=y used) 25 | if [[ ! -d /oldrun/artix/copytoram ]]; then 26 | if [[ -d /oldrun/artix/img_dev ]]; then 27 | umount /oldrun/artix/img_dev 28 | else 29 | umount /oldrun/artix/bootmnt 30 | fi 31 | fi 32 | 33 | # reboot / poweroff / halt, depending on the argument passed by init 34 | # if something invalid is passed, we halt 35 | case "$1" in 36 | reboot|poweroff|halt) "$1" -f ;; 37 | *) halt -f;; 38 | esac 39 | -------------------------------------------------------------------------------- /lib/util-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This program is free software; you can redistribute it and/or modify 3 | # it under the terms of the GNU General Public License as published by 4 | # the Free Software Foundation; version 2 of the License. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | 11 | is_btrfs() { 12 | [[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]] 13 | } 14 | 15 | subvolume_delete_recursive() { 16 | local subvol 17 | 18 | is_btrfs "$1" || return 0 19 | 20 | while IFS= read -d $'\0' -r subvol; do 21 | if ! btrfs subvolume delete "$subvol" &>/dev/null; then 22 | error "Unable to delete subvolume %s" "$subvol" 23 | return 1 24 | fi 25 | done < <(find "$1" -xdev -depth -inum 256 -print0) 26 | 27 | return 0 28 | } 29 | 30 | # $1: chroot 31 | kill_chroot_process(){ 32 | local prefix="$1" flink pid name 33 | for root_dir in /proc/*/root; do 34 | flink=$(readlink $root_dir) 35 | if [ "x$flink" != "x" ]; then 36 | if [ "x${flink:0:${#prefix}}" = "x$prefix" ]; then 37 | # this process is in the chroot... 38 | pid=$(basename $(dirname "$root_dir")) 39 | name=$(ps -p $pid -o comm=) 40 | info "Killing chroot process: %s (%s)" "$name" "$pid" 41 | kill -9 "$pid" 42 | fi 43 | fi 44 | done 45 | } 46 | -------------------------------------------------------------------------------- /lib/util-fstab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This program is free software; you can redistribute it and/or modify 3 | # it under the terms of the GNU General Public License as published by 4 | # the Free Software Foundation; version 2 of the License. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | 11 | declare -A pseudofs_types=([anon_inodefs]=1 12 | [autofs]=1 13 | [bdev]=1 14 | [binfmt_misc]=1 15 | [cgroup]=1 16 | [cgroup2]=1 17 | [configfs]=1 18 | [cpuset]=1 19 | [debugfs]=1 20 | [devfs]=1 21 | [devpts]=1 22 | [devtmpfs]=1 23 | [dlmfs]=1 24 | [fuse.gvfs-fuse-daemon]=1 25 | [fusectl]=1 26 | [hugetlbfs]=1 27 | [mqueue]=1 28 | [nfsd]=1 29 | [none]=1 30 | [pipefs]=1 31 | [proc]=1 32 | [pstore]=1 33 | [ramfs]=1 34 | [rootfs]=1 35 | [rpc_pipefs]=1 36 | [securityfs]=1 37 | [sockfs]=1 38 | [spufs]=1 39 | [sysfs]=1 40 | [tmpfs]=1) 41 | 42 | declare -A fsck_types=([cramfs]=1 43 | [exfat]=1 44 | [ext2]=1 45 | [ext3]=1 46 | [ext4]=1 47 | [ext4dev]=1 48 | [jfs]=1 49 | [minix]=1 50 | [msdos]=1 51 | [reiserfs]=1 52 | [vfat]=1 53 | [xfs]=1) 54 | 55 | fstype_is_pseudofs() { 56 | (( pseudofs_types["$1"] )) 57 | } 58 | 59 | fstype_has_fsck() { 60 | (( fsck_types["$1"] )) 61 | } 62 | 63 | valid_number_of_base() { 64 | local base=$1 len=${#2} i= 65 | 66 | for (( i = 0; i < len; i++ )); do 67 | { _=$(( $base#${2:i:1} )) || return 1; } 2>/dev/null 68 | done 69 | 70 | return 0 71 | } 72 | 73 | mangle() { 74 | local i= chr= out= 75 | 76 | local {a..f}= {A..F}= 77 | 78 | for (( i = 0; i < ${#1}; i++ )); do 79 | chr=${1:i:1} 80 | case $chr in 81 | [[:space:]\\]) 82 | printf -v chr '%03o' "'$chr" 83 | out+=\\ 84 | ;; 85 | esac 86 | out+=$chr 87 | done 88 | 89 | printf '%s' "$out" 90 | } 91 | 92 | unmangle() { 93 | local i= chr= out= len=$(( ${#1} - 4 )) 94 | 95 | local {a..f}= {A..F}= 96 | 97 | for (( i = 0; i < len; i++ )); do 98 | chr=${1:i:1} 99 | case $chr in 100 | \\) 101 | if valid_number_of_base 8 "${1:i+1:3}" || 102 | valid_number_of_base 16 "${1:i+1:3}"; then 103 | printf -v chr '%b' "${1:i:4}" 104 | (( i += 3 )) 105 | fi 106 | ;; 107 | esac 108 | out+=$chr 109 | done 110 | 111 | printf '%s' "$out${1:i}" 112 | } 113 | 114 | dm_name_for_devnode() { 115 | read dm_name <"/sys/class/block/${1#/dev/}/dm/name" 116 | if [[ $dm_name ]]; then 117 | printf '/dev/mapper/%s' "$dm_name" 118 | else 119 | # don't leave the caller hanging, just print the original name 120 | # along with the failure. 121 | print '%s' "$1" 122 | error 'Failed to resolve device mapper name for: %s' "$1" 123 | fi 124 | } 125 | 126 | optstring_match_option() { 127 | local candidate pat patterns 128 | 129 | IFS=, read -ra patterns <<<"$1" 130 | for pat in "${patterns[@]}"; do 131 | if [[ $pat = *=* ]]; then 132 | # "key=val" will only ever match "key=val" 133 | candidate=$2 134 | else 135 | # "key" will match "key", but also "key=anyval" 136 | candidate=${2%%=*} 137 | fi 138 | 139 | [[ $pat = "$candidate" ]] && return 0 140 | done 141 | 142 | return 1 143 | } 144 | 145 | optstring_remove_option() { 146 | local o options_ remove=$2 IFS=, 147 | 148 | read -ra options_ <<<"${!1}" 149 | 150 | for o in "${!options_[@]}"; do 151 | optstring_match_option "$remove" "${options_[o]}" && unset 'options_[o]' 152 | done 153 | 154 | declare -g "$1=${options_[*]}" 155 | } 156 | 157 | optstring_normalize() { 158 | local o options_ norm IFS=, 159 | 160 | read -ra options_ <<<"${!1}" 161 | 162 | # remove empty fields 163 | for o in "${options_[@]}"; do 164 | [[ $o ]] && norm+=("$o") 165 | done 166 | 167 | # avoid empty strings, reset to "defaults" 168 | declare -g "$1=${norm[*]:-defaults}" 169 | } 170 | 171 | optstring_append_option() { 172 | if ! optstring_has_option "$1" "$2"; then 173 | declare -g "$1=${!1},$2" 174 | fi 175 | 176 | optstring_normalize "$1" 177 | } 178 | 179 | optstring_prepend_option() { 180 | local options_=$1 181 | 182 | if ! optstring_has_option "$1" "$2"; then 183 | declare -g "$1=$2,${!1}" 184 | fi 185 | 186 | optstring_normalize "$1" 187 | } 188 | 189 | optstring_get_option() { 190 | local opts o 191 | 192 | IFS=, read -ra opts <<<"${!1}" 193 | for o in "${opts[@]}"; do 194 | if optstring_match_option "$2" "$o"; then 195 | declare -g "$o" 196 | return 0 197 | fi 198 | done 199 | 200 | return 1 201 | } 202 | 203 | optstring_has_option() { 204 | local "${2%%=*}" 205 | 206 | optstring_get_option "$1" "$2" 207 | } 208 | -------------------------------------------------------------------------------- /lib/util-iso-grub.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | prepare_initcpio(){ 13 | msg2 "Copying initcpio ..." 14 | local dest="$1" 15 | cp /etc/initcpio/hooks/artix* $dest/etc/initcpio/hooks 16 | cp /etc/initcpio/install/artix* $dest/etc/initcpio/install 17 | cp /etc/initcpio/artix_shutdown $dest/etc/initcpio 18 | } 19 | 20 | prepare_initramfs(){ 21 | local mnt="$1" 22 | cp ${DATADIR}/mkinitcpio.conf $mnt/etc/mkinitcpio-artix.conf 23 | if [[ -n ${gpgkey} ]]; then 24 | user_run "gpg --export ${gpgkey} >${AT_USERCONFDIR}/gpgkey" 25 | exec 17<>${AT_USERCONFDIR}/gpgkey 26 | fi 27 | local _kernel=$(cat $mnt/usr/lib/modules/*/version) 28 | ARTIX_GNUPG_FD=${gpgkey:+17} chroot-run $mnt \ 29 | /usr/bin/mkinitcpio -k ${_kernel} \ 30 | -c /etc/mkinitcpio-artix.conf \ 31 | -g /boot/initramfs.img 32 | 33 | if [[ -n ${gpgkey} ]]; then 34 | exec 17<&- 35 | fi 36 | if [[ -f ${AT_USERCONFDIR}/gpgkey ]]; then 37 | rm ${AT_USERCONFDIR}/gpgkey 38 | fi 39 | } 40 | 41 | prepare_boot_extras(){ 42 | local src="$1" dest="$2" 43 | # cp $src/boot/intel-ucode.img $dest/intel_ucode.img 44 | # cp $src/usr/share/licenses/intel-ucode/LICENSE $dest/intel_ucode.LICENSE 45 | cp $src/boot/memtest86+/memtest.bin $dest/memtest 46 | cp $src/usr/share/licenses/common/GPL2/license.txt $dest/memtest.COPYING 47 | } 48 | 49 | configure_grub(){ 50 | local conf="$1/boot/grub/kernels.cfg" 51 | sed -e "s|@iso_label@|${iso_label}|" -i $conf 52 | } 53 | 54 | prepare_grub(){ 55 | local platform=i386-pc img='core.img' grub=$3/boot/grub efi=$3/efi/boot \ 56 | lib=$1/usr/lib/grub prefix=/boot/grub theme=$2/usr/share/grub 57 | 58 | prepare_dir ${grub}/${platform} 59 | 60 | cp ${theme}/cfg/*.cfg ${grub} 61 | 62 | cp ${lib}/${platform}/* ${grub}/${platform} 63 | 64 | msg2 "Building %s ..." "${img}" 65 | 66 | grub-mkimage -d ${grub}/${platform} -o ${grub}/${platform}/${img} -O ${platform} -p ${prefix} biosdisk iso9660 67 | 68 | cat ${grub}/${platform}/cdboot.img ${grub}/${platform}/${img} > ${grub}/${platform}/eltorito.img 69 | 70 | platform=x86_64-efi 71 | img=bootx64.efi 72 | 73 | prepare_dir ${efi} 74 | prepare_dir ${grub}/${platform} 75 | 76 | cp ${lib}/${platform}/* ${grub}/${platform} 77 | 78 | msg2 "Building %s ..." "${img}" 79 | 80 | grub-mkimage -d ${grub}/${platform} -o ${efi}/${img} -O ${platform} -p ${prefix} iso9660 81 | 82 | prepare_dir ${grub}/themes 83 | cp -r ${theme}/themes/artix ${grub}/themes/ 84 | cp -r ${theme}/{locales,tz} ${grub} 85 | 86 | msg2 "Creating %s ..." "unicode.pf2" 87 | grub-mkfont -o ${grub}/unicode.pf2 /usr/share/fonts/misc/unifont.bdf 88 | 89 | local size=4M mnt="${mnt_dir}/efiboot" efi_img="$3/efi.img" 90 | msg2 "Creating fat image of %s ..." "${size}" 91 | truncate -s ${size} "${efi_img}" 92 | mkfs.fat -n ARTIX_EFI "${efi_img}" &>/dev/null 93 | prepare_dir "${mnt}" 94 | mount_img "${efi_img}" "${mnt}" 95 | prepare_dir ${mnt}/efi/boot 96 | msg2 "Building %s ..." "${img}" 97 | grub-mkimage -d ${grub}/${platform} -o ${mnt}/efi/boot/${img} -O ${platform} -p ${prefix} iso9660 98 | umount_img "${mnt}" 99 | } 100 | -------------------------------------------------------------------------------- /lib/util-iso-profile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This program is free software; you can redistribute it and/or modify 3 | # it under the terms of the GNU General Public License as published by 4 | # the Free Software Foundation; version 2 of the License. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | 11 | init_profile(){ 12 | local profdir="$1" prof="$2" 13 | 14 | root_list="$profdir/base/Packages-Root" 15 | root_overlay="$profdir/base/root-overlay" 16 | live_list="$profdir/base/Packages-Live" 17 | live_overlay="$profdir/base/live-overlay" 18 | 19 | [[ -f "$profdir/$prof/Packages-Root" ]] && root_list="$profdir/$prof/Packages-Root" 20 | [[ -d "$profdir/$prof/root-overlay" ]] && root_overlay="$profdir/$prof/root-overlay" 21 | 22 | [[ -f "$profdir/$prof/Packages-Desktop" ]] && desktop_list="$profdir/$prof/Packages-Desktop" 23 | [[ -d "$profdir/$prof/desktop-overlay" ]] && desktop_overlay="$profdir/$prof/desktop-overlay" 24 | 25 | [[ -f "$profdir/$prof/Packages-Live" ]] && live_list="$profdir/$prof/Packages-Live" 26 | [[ -d "$profdir/$prof/live-overlay" ]] && live_overlay="$profdir/$prof/live-overlay" 27 | } 28 | 29 | load_profile(){ 30 | local prof="$1" 31 | local profdir="${DATADIR}/iso-profiles" 32 | [[ -d ${workspace_dir}/iso-profiles ]] && profdir=${workspace_dir}/iso-profiles 33 | 34 | init_profile "$profdir" "$prof" 35 | 36 | [[ -f $profdir/$prof/profile.conf ]] || return 1 37 | 38 | [[ -r $profdir/$prof/profile.conf ]] && source $profdir/$prof/profile.conf 39 | 40 | [[ -z ${displaymanager} ]] && displaymanager="none" 41 | 42 | [[ -z ${autologin} ]] && autologin="true" 43 | [[ ${displaymanager} == 'none' ]] && autologin="false" 44 | 45 | [[ -z ${hostname} ]] && hostname="artix" 46 | 47 | [[ -z ${username} ]] && username="artix" 48 | 49 | [[ -z ${password} ]] && password="artix" 50 | 51 | if [[ -z ${addgroups} ]];then 52 | addgroups="video,power,storage,optical,network,lp,scanner,wheel,users,log" 53 | fi 54 | 55 | if [[ -z ${services[@]} ]];then 56 | services=('acpid' 'bluetooth' 'cronie' 'cupsd' 'syslog-ng' 'NetworkManager') 57 | fi 58 | 59 | if [[ ${displaymanager} != "none" ]];then 60 | case "${initsys}" in 61 | 'openrc') services+=('xdm') ;; 62 | 'runit') services+=("${displaymanager}") ;; 63 | esac 64 | fi 65 | 66 | if [[ -z ${services_live[@]} ]];then 67 | services_live=('artix-live' 'pacman-init') 68 | fi 69 | 70 | return 0 71 | } 72 | 73 | write_live_session_conf(){ 74 | local path=$1${SYSCONFDIR} 75 | [[ ! -d $path ]] && mkdir -p "$path" 76 | local conf=$path/live.conf 77 | msg2 "Writing %s" "${conf##*/}" 78 | echo '# live session configuration' > ${conf} 79 | echo '' >> ${conf} 80 | echo '# autologin' >> ${conf} 81 | echo "autologin=${autologin}" >> ${conf} 82 | echo '' >> ${conf} 83 | echo '# live username' >> ${conf} 84 | echo "username=${username}" >> ${conf} 85 | echo '' >> ${conf} 86 | echo '# live password' >> ${conf} 87 | echo "password=${password}" >> ${conf} 88 | echo '' >> ${conf} 89 | echo '# live group membership' >> ${conf} 90 | echo "addgroups='${addgroups}'" >> ${conf} 91 | } 92 | 93 | load_pkgs(){ 94 | local pkglist="$1" init="$2" 95 | info "Loading Packages: [%s] ..." "${pkglist##*/}" 96 | 97 | local _init="s|>$init||g" 98 | case "$init" in 99 | 'openrc') _init_rm1="s|>runit.*||g"; _init_rm2="s|>s6*||g" ;; 100 | 's6') _init_rm1="s|>runit.*||g"; _init_rm2="s|>openrc.*||g" ;; 101 | 'runit') _init_rm1="s|>s6.*||g"; _init_rm2="s|>openrc.*||g" ;; 102 | esac 103 | 104 | local _blacklist="s|>blacklist.*||g" \ 105 | _space="s| ||g" \ 106 | _clean=':a;N;$!ba;s/\n/ /g' \ 107 | _com_rm="s|#.*||g" 108 | 109 | packages=($(sed "$_com_rm" "$pkglist" \ 110 | | sed "$_space" \ 111 | | sed "$_blacklist" \ 112 | | sed "$_purge" \ 113 | | sed "$_init" \ 114 | | sed "$_init_rm1" \ 115 | | sed "$_init_rm2" \ 116 | | sed "$_clean")) 117 | } 118 | -------------------------------------------------------------------------------- /lib/util-iso-publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | connect(){ 13 | local home="/home/frs/project/${project}" 14 | echo "${account},${project}@frs.${file_host}:${home}" 15 | } 16 | 17 | gen_webseed(){ 18 | local webseed seed="$1" 19 | for mirror in ${host_mirrors[@]};do 20 | webseed=${webseed:-}${webseed:+,}"https://${mirror}.dl.${seed}" 21 | done 22 | echo ${webseed} 23 | } 24 | 25 | make_torrent(){ 26 | find ${src_dir} -type f -name "*.torrent" -delete 27 | 28 | if [[ -n $(find ${src_dir} -type f -name "*.iso") ]]; then 29 | for iso in $(ls ${src_dir}/*.iso);do 30 | local seed=${file_host}/project/${project}${target_dir}${iso##*/} 31 | local mktorrent_args=(-c "${torrent_meta}" -p -l ${piece_size} -a ${tracker_url} -w $(gen_webseed ${seed})) 32 | ${verbose} && mktorrent_args+=(-v) 33 | info "mktorrent_args: %s" "${mktorrent_args[@]}" 34 | msg2 "Creating (%s) ..." "${iso##*/}.torrent" 35 | mktorrent ${mktorrent_args[*]} -o ${iso}.torrent ${iso} 36 | done 37 | fi 38 | } 39 | 40 | prepare_transfer(){ 41 | target_dir="/iso/${profile}/" 42 | src_dir="${iso_pool}/${profile}/" 43 | ${torrent} && make_torrent 44 | } 45 | 46 | sync_dir(){ 47 | msg "Start upload [%s] ..." "${profile}" 48 | rsync "${rsync_args[@]}" ${src_dir} $(connect)${target_dir} 49 | msg "Done upload [%s]" "${profile}" 50 | show_elapsed_time "${FUNCNAME}" "${timer_start}" 51 | } 52 | -------------------------------------------------------------------------------- /lib/util-iso-yaml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | write_users_conf(){ 13 | local conf="$1/users.conf" 14 | msg2 "Writing %s ..." "${conf##*/}" 15 | echo "---" > "$conf" 16 | echo "defaultGroups:" >> "$conf" 17 | local IFS=',' 18 | for g in ${addgroups[@]};do 19 | echo " - $g" >> "$conf" 20 | done 21 | unset IFS 22 | echo "autologinGroup: autologin" >> "$conf" 23 | echo "doAutologin: false" >> "$conf" 24 | echo "sudoersGroup: wheel" >> "$conf" 25 | echo "setRootPassword: true" >> "$conf" 26 | # echo "doReusePassword: false" >> "$conf" # only used in old 'users' module 27 | echo "availableShells: /bin/bash, /bin/zsh" >> "$conf" # only used in new 'users' module 28 | echo "avatarFilePath: ~/.face" >> "$conf" 29 | } 30 | 31 | write_servicescfg_conf(){ 32 | local init="$2" 33 | local conf="$1"/"$init"cfg.conf state='add' 34 | msg2 "Writing %s ..." "${conf##*/}" 35 | echo '---' > "$conf" 36 | if [[ "$init" == 'runit' ]];then 37 | state='enabled' 38 | echo 'svdir: /etc/runit/sv' >> "$conf" 39 | echo '' >> "$conf" 40 | echo 'runsvdir: /etc/runit/runsvdir' >> "$conf" 41 | fi 42 | echo '' >> "$conf" 43 | echo 'services:' >> "$conf" 44 | echo " $state:" >> "$conf" 45 | for svc in ${services[@]};do 46 | echo " - name: $svc" >> "$conf" 47 | echo ' runlevel: default' >> "$conf" 48 | done 49 | } 50 | 51 | write_postcfg_conf(){ 52 | local conf="$1/postcfg.conf" init="$2" 53 | sed -e "s|openrc|$init|" -i "$conf" 54 | } 55 | 56 | write_netinstall_conf(){ 57 | local conf="$1/netinstall.conf" init="$2" 58 | sed -e "s|netgroups-openrc.yaml|netgroups-$init.yaml|" -i "$conf" 59 | } 60 | 61 | configure_calamares(){ 62 | local mods="$1/etc/calamares/modules" init="$2" 63 | if [[ -d "$mods" ]];then 64 | info "Configuring [Calamares]" 65 | write_netinstall_conf "$mods" "$init" 66 | write_users_conf "$mods" 67 | write_servicescfg_conf "$mods" "$init" 68 | write_postcfg_conf "$mods" "$init" 69 | local name="$init"cfg 70 | sed -e "s|openrccfg|$name|" -i "$1"/etc/calamares/settings.conf 71 | info "Done configuring [Calamares]" 72 | fi 73 | } 74 | -------------------------------------------------------------------------------- /lib/util-iso.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | import ${LIBDIR}/util-chroot.sh 13 | import ${LIBDIR}/util-iso-grub.sh 14 | import ${LIBDIR}/util-iso-yaml.sh 15 | import ${LIBDIR}/util-iso-profile.sh 16 | 17 | track_img() { 18 | info "mount: [%s]" "$2" 19 | mount "$@" && IMG_ACTIVE_MOUNTS=("$2" "${IMG_ACTIVE_MOUNTS[@]}") 20 | } 21 | 22 | mount_img() { 23 | IMG_ACTIVE_MOUNTS=() 24 | mkdir -p "$2" 25 | track_img "$1" "$2" 26 | } 27 | 28 | umount_img() { 29 | if [[ -n ${IMG_ACTIVE_MOUNTS[@]} ]];then 30 | info "umount: [%s]" "${IMG_ACTIVE_MOUNTS[@]}" 31 | umount "${IMG_ACTIVE_MOUNTS[@]}" 32 | unset IMG_ACTIVE_MOUNTS 33 | rm -r "$1" 34 | fi 35 | } 36 | 37 | track_fs() { 38 | info "overlayfs mount: [%s]" "$5" 39 | mount "$@" && FS_ACTIVE_MOUNTS=("$5" "${FS_ACTIVE_MOUNTS[@]}") 40 | } 41 | 42 | mount_overlay(){ 43 | FS_ACTIVE_MOUNTS=() 44 | local lower= upper="$1" work="$2" pkglist="$3" 45 | local fs=${upper##*/} 46 | local rootfs="$work/rootfs" desktopfs="$work/desktopfs" livefs="$work/livefs" 47 | mkdir -p "${mnt_dir}/work" 48 | mkdir -p "$upper" 49 | case $fs in 50 | desktopfs) lower="$rootfs" ;; 51 | livefs) 52 | lower="$rootfs" 53 | [[ -f $pkglist ]] && lower="$desktopfs":"$rootfs" 54 | ;; 55 | bootfs) 56 | lower="$livefs":"$rootfs" 57 | [[ -f $pkglist ]] && lower="$livefs":"$desktopfs":"$rootfs" 58 | ;; 59 | esac 60 | track_fs -t overlay overlay -olowerdir="$lower",upperdir="$upper",workdir="${mnt_dir}/work" "$upper" 61 | } 62 | 63 | umount_overlay(){ 64 | if [[ -n ${FS_ACTIVE_MOUNTS[@]} ]];then 65 | info "overlayfs umount: [%s]" "${FS_ACTIVE_MOUNTS[@]}" 66 | umount "${FS_ACTIVE_MOUNTS[@]}" 67 | unset FS_ACTIVE_MOUNTS 68 | rm -rf "${mnt_dir}/work" 69 | fi 70 | } 71 | 72 | error_function() { 73 | if [[ -p $logpipe ]]; then 74 | rm "$logpipe" 75 | fi 76 | local func="$1" 77 | # first exit all subshells, then print the error 78 | if (( ! BASH_SUBSHELL )); then 79 | error "A failure occurred in %s()." "$func" 80 | plain "Aborting..." 81 | fi 82 | umount_overlay 83 | umount_img 84 | exit 2 85 | } 86 | 87 | # $1: function 88 | run_log(){ 89 | local func="$1" log_dir='/var/log/artools' 90 | local logfile=${log_dir}/$(gen_iso_fn).$func.log 91 | logpipe=$(mktemp -u "/tmp/$func.pipe.XXXXXXXX") 92 | mkfifo "$logpipe" 93 | tee "$logfile" < "$logpipe" & 94 | local teepid=$! 95 | $func &> "$logpipe" 96 | wait $teepid 97 | rm "$logpipe" 98 | } 99 | 100 | run_safe() { 101 | local restoretrap func="$1" 102 | set -e 103 | set -E 104 | restoretrap=$(trap -p ERR) 105 | trap 'error_function $func' ERR 106 | 107 | if ${verbose};then 108 | run_log "$func" 109 | else 110 | "$func" 111 | fi 112 | 113 | eval $restoretrap 114 | set +E 115 | set +e 116 | } 117 | 118 | trap_exit() { 119 | local sig=$1; shift 120 | error "$@" 121 | umount_overlay 122 | trap -- "$sig" 123 | kill "-$sig" "$$" 124 | } 125 | 126 | prepare_traps(){ 127 | for sig in TERM HUP QUIT; do 128 | trap "trap_exit $sig \"$(gettext "%s signal caught. Exiting...")\" \"$sig\"" "$sig" 129 | done 130 | trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT 131 | # trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR 132 | } 133 | 134 | add_svc_rc(){ 135 | local mnt="$1" name="$2" rlvl="$3" 136 | if [[ -f $mnt/etc/init.d/$name ]];then 137 | msg2 "Setting %s ..." "$name" 138 | chroot $mnt rc-update add $name $rlvl &>/dev/null 139 | fi 140 | } 141 | 142 | add_svc_runit(){ 143 | local mnt="$1" name="$2" 144 | if [[ -d $mnt/etc/runit/sv/$name ]]; then 145 | msg2 "Setting %s ..." "$name" 146 | chroot $mnt ln -s /etc/runit/sv/$name /etc/runit/runsvdir/default &>/dev/null 147 | fi 148 | } 149 | 150 | set_xdm(){ 151 | if [[ -f $1/etc/conf.d/xdm ]];then 152 | local conf='DISPLAYMANAGER="'${displaymanager}'"' 153 | sed -i -e "s|^.*DISPLAYMANAGER=.*|${conf}|" $1/etc/conf.d/xdm 154 | fi 155 | } 156 | 157 | configure_hosts(){ 158 | sed -e "s|localhost.localdomain|localhost.localdomain ${hostname}|" -i $1/etc/hosts 159 | } 160 | 161 | configure_logind(){ 162 | local conf=$1/etc/$2/logind.conf 163 | if [[ -e $conf ]];then 164 | msg2 "Configuring logind ..." 165 | sed -i 's/#\(HandleSuspendKey=\)suspend/\1ignore/' "$conf" 166 | sed -i 's/#\(HandleLidSwitch=\)suspend/\1ignore/' "$conf" 167 | sed -i 's/#\(HandleHibernateKey=\)hibernate/\1ignore/' "$conf" 168 | fi 169 | } 170 | 171 | configure_services(){ 172 | local mnt="$1" 173 | info "Configuring [%s]" "${initsys}" 174 | case ${initsys} in 175 | 'openrc') 176 | for svc in ${services[@]}; do 177 | [[ $svc == "xdm" ]] && set_xdm "$mnt" 178 | add_svc_rc "$mnt" "$svc" "default" 179 | done 180 | for svc in ${services_live[@]}; do 181 | add_svc_rc "$mnt" "$svc" "default" 182 | done 183 | ;; 184 | 'runit') 185 | for svc in ${services[@]}; do 186 | add_svc_runit "$mnt" "$svc" 187 | done 188 | for svc in ${services_live[@]}; do 189 | add_svc_runit "$mnt" "$svc" 190 | done 191 | ;; 192 | esac 193 | info "Done configuring [%s]" "${initsys}" 194 | } 195 | 196 | configure_system(){ 197 | local mnt="$1" 198 | case ${initsys} in 199 | 'openrc' | 'runit') 200 | configure_logind "$mnt" "elogind" 201 | ;; 202 | esac 203 | echo ${hostname} > $mnt/etc/hostname 204 | } 205 | 206 | clean_iso_root(){ 207 | local dest="$1" 208 | msg "Deleting isoroot [%s] ..." "${dest##*/}" 209 | rm -rf --one-file-system "$dest" 210 | } 211 | 212 | clean_up_image(){ 213 | local path mnt="$1" 214 | msg2 "Cleaning [%s]" "${mnt##*/}" 215 | 216 | if [[ -f "$mnt/etc/locale.gen.orig" ]];then 217 | mv "$mnt/etc/locale.gen.orig" "$mnt/etc/locale.gen" 218 | rm "$mnt/etc/locale.conf" 219 | fi 220 | path=$mnt/boot 221 | if [[ -d "$path" ]]; then 222 | find "$path" -name 'initramfs*.img' -delete &> /dev/null 223 | fi 224 | path=$mnt/var/lib/pacman/sync 225 | if [[ -d $path ]];then 226 | find "$path" -type f -delete &> /dev/null 227 | fi 228 | path=$mnt/var/cache/pacman/pkg 229 | if [[ -d $path ]]; then 230 | find "$path" -type f -delete &> /dev/null 231 | fi 232 | path=$mnt/var/log 233 | if [[ -d $path ]]; then 234 | find "$path" -type f -delete &> /dev/null 235 | fi 236 | path=$mnt/var/tmp 237 | if [[ -d $path ]];then 238 | find "$path" -mindepth 1 -delete &> /dev/null 239 | fi 240 | path=$mnt/tmp 241 | if [[ -d $path ]];then 242 | find "$path" -mindepth 1 -delete &> /dev/null 243 | fi 244 | 245 | if [[ ${mnt##*/} == 'livefs' ]];then 246 | rm -rf "$mnt/etc/pacman.d/gnupg" 247 | fi 248 | 249 | find "$mnt" -name *.pacnew -name *.pacsave -name *.pacorig -delete 250 | if [[ -f "$mnt/boot/grub/grub.cfg" ]]; then 251 | rm $mnt/boot/grub/grub.cfg 252 | fi 253 | if [[ -f "$mnt/etc/machine-id" ]]; then 254 | rm $mnt/etc/machine-id 255 | fi 256 | } 257 | 258 | configure_live_image(){ 259 | local fs="$1" 260 | msg "Configuring [livefs]" 261 | configure_hosts "$fs" 262 | configure_system "$fs" 263 | configure_services "$fs" 264 | configure_calamares "$fs" "${initsys}" 265 | write_live_session_conf "$fs" 266 | msg "Done configuring [livefs]" 267 | } 268 | 269 | make_sig () { 270 | local idir="$1" file="$2" 271 | msg2 "Creating signature file..." 272 | cd "$idir" 273 | user_own "$idir" 274 | user_run "gpg --detach-sign --default-key ${gpgkey} $file.sfs" 275 | chown -R root "$idir" 276 | cd ${OLDPWD} 277 | } 278 | 279 | make_checksum(){ 280 | local idir="$1" file="$2" 281 | msg2 "Creating sha512sum ..." 282 | cd $idir 283 | sha512sum $file.sfs > $file.sha512 284 | cd ${OLDPWD} 285 | } 286 | 287 | # $1: image path 288 | make_sfs() { 289 | local src="$1" 290 | if [[ ! -e "${src}" ]]; then 291 | error "The path %s does not exist" "${src}" 292 | retrun 1 293 | fi 294 | local timer=$(get_timer) dest=${iso_root}/artix/${target_arch} 295 | local name=${1##*/} 296 | local sfs="${dest}/${name}.sfs" 297 | mkdir -p ${dest} 298 | msg "Generating SquashFS image for %s" "${src}" 299 | if [[ -f "${sfs}" ]]; then 300 | local has_changed_dir=$(find ${src} -newer ${sfs}) 301 | msg2 "Possible changes for %s ..." "${src}" >> /tmp/buildiso.debug 302 | msg2 "%s" "${has_changed_dir}" >> /tmp/buildiso.debug 303 | if [[ -n "${has_changed_dir}" ]]; then 304 | msg2 "SquashFS image %s is not up to date, rebuilding..." "${sfs}" 305 | rm "${sfs}" 306 | else 307 | msg2 "SquashFS image %s is up to date, skipping." "${sfs}" 308 | return 309 | fi 310 | fi 311 | 312 | if ${persist};then 313 | local size=32G 314 | local mnt="${mnt_dir}/${name}" 315 | msg2 "Creating ext4 image of %s ..." "${size}" 316 | truncate -s ${size} "${src}.img" 317 | local ext4_args=() 318 | ${verbose} && ext4_args+=(-q) 319 | ext4_args+=(-O ^has_journal,^resize_inode -E lazy_itable_init=0 -m 0) 320 | mkfs.ext4 ${ext4_args[@]} -F "${src}.img" &>/dev/null 321 | tune2fs -c 0 -i 0 "${src}.img" &> /dev/null 322 | mount_img "${work_dir}/${name}.img" "${mnt}" 323 | msg2 "Copying %s ..." "${src}/" 324 | cp -aT "${src}/" "${mnt}/" 325 | umount_img "${mnt}" 326 | 327 | fi 328 | 329 | msg2 "Creating SquashFS image, this may take some time..." 330 | local mksfs_args=() 331 | if ${persist};then 332 | mksfs_args+=(${work_dir}/${name}.img) 333 | else 334 | mksfs_args+=(${src}) 335 | fi 336 | 337 | mksfs_args+=(${sfs} -noappend) 338 | 339 | local highcomp="-b 256K -Xbcj x86" comp='xz' 340 | 341 | mksfs_args+=(-comp ${comp} ${highcomp}) 342 | if ${verbose};then 343 | mksquashfs "${mksfs_args[@]}" >/dev/null 344 | else 345 | mksquashfs "${mksfs_args[@]}" 346 | fi 347 | make_checksum "${dest}" "${name}" 348 | ${persist} && rm "${src}.img" 349 | 350 | if [[ -n ${gpgkey} ]];then 351 | make_sig "${dest}" "${name}" 352 | fi 353 | 354 | show_elapsed_time "${FUNCNAME}" "${timer_start}" 355 | } 356 | 357 | assemble_iso(){ 358 | msg "Creating ISO image..." 359 | local mod_date=$(date -u +%Y-%m-%d-%H-%M-%S-00 | sed -e s/-//g) 360 | 361 | xorriso -as mkisofs \ 362 | --modification-date=${mod_date} \ 363 | --protective-msdos-label \ 364 | -volid "${iso_label}" \ 365 | -appid "$(get_osname) Live/Rescue CD" \ 366 | -publisher "$(get_osname) <$(get_disturl)>" \ 367 | -preparer "Prepared by artools/${0##*/}" \ 368 | -r -graft-points -no-pad \ 369 | --sort-weight 0 / \ 370 | --sort-weight 1 /boot \ 371 | --grub2-mbr ${iso_root}/boot/grub/i386-pc/boot_hybrid.img \ 372 | -partition_offset 16 \ 373 | -b boot/grub/i386-pc/eltorito.img \ 374 | -c boot.catalog \ 375 | -no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info \ 376 | -eltorito-alt-boot \ 377 | -append_partition 2 0xef ${iso_root}/efi.img \ 378 | -e --interval:appended_partition_2:all:: -iso_mbr_part_type 0x00 \ 379 | -no-emul-boot \ 380 | -iso-level 3 \ 381 | -o ${iso_dir}/${iso_file} \ 382 | ${iso_root}/ 383 | } 384 | 385 | # Build ISO 386 | make_iso() { 387 | msg "Start [Build ISO]" 388 | touch "${iso_root}/.artix" 389 | for sfs_dir in $(find "${work_dir}" -maxdepth 1 -type d); do 390 | if [[ "${sfs_dir}" != "${work_dir}" ]]; then 391 | make_sfs "${sfs_dir}" 392 | fi 393 | done 394 | 395 | msg "Making bootable image" 396 | # Sanity checks 397 | [[ ! -d "${iso_root}" ]] && return 1 398 | if [[ -f "${iso_dir}/${iso_file}" ]]; then 399 | msg2 "Removing existing bootable image..." 400 | rm -rf "${iso_dir}/${iso_file}" 401 | fi 402 | assemble_iso 403 | msg "Done [Build ISO]" 404 | } 405 | 406 | gen_iso_fn(){ 407 | local vars=("artix") name 408 | vars+=("${profile}") 409 | [[ ${initsys} == 'runit' ]] && vars+=("${initsys}") 410 | vars+=("${iso_version}") 411 | vars+=("${target_arch}") 412 | for n in ${vars[@]};do 413 | name=${name:-}${name:+-}${n} 414 | done 415 | echo $name 416 | } 417 | 418 | install_packages(){ 419 | local fs="$1" 420 | setarch "${target_arch}" mkchroot \ 421 | "${mkchroot_args[@]}" "${fs}" "${packages[@]}" 422 | } 423 | 424 | copy_overlay(){ 425 | local src="$1" dest="$2" 426 | if [[ -e "$src" ]];then 427 | msg2 "Copying [%s] ..." "${src##*/}" 428 | cp -LR "$src"/* "$dest" 429 | fi 430 | } 431 | 432 | make_rootfs() { 433 | if [[ ! -e ${work_dir}/rootfs.lock ]]; then 434 | msg "Prepare [Base installation] (rootfs)" 435 | local rootfs="${work_dir}/rootfs" 436 | 437 | prepare_dir "${rootfs}" 438 | 439 | install_packages "${rootfs}" 440 | 441 | copy_overlay "${root_overlay}" "${rootfs}" 442 | 443 | clean_up_image "${rootfs}" 444 | 445 | msg "Done [Base installation] (rootfs)" 446 | fi 447 | } 448 | 449 | make_desktopfs() { 450 | if [[ ! -e ${work_dir}/desktopfs.lock ]]; then 451 | msg "Prepare [Desktop installation] (desktopfs)" 452 | local desktopfs="${work_dir}/desktopfs" 453 | 454 | prepare_dir "${desktopfs}" 455 | 456 | mount_overlay "${desktopfs}" "${work_dir}" 457 | 458 | install_packages "${desktopfs}" 459 | 460 | copy_overlay "${desktop_overlay}" "${desktopfs}" 461 | 462 | umount_overlay 463 | clean_up_image "${desktopfs}" 464 | 465 | msg "Done [Desktop installation] (desktopfs)" 466 | fi 467 | } 468 | 469 | make_livefs() { 470 | if [[ ! -e ${work_dir}/livefs.lock ]]; then 471 | msg "Prepare [Live installation] (livefs)" 472 | local livefs="${work_dir}/livefs" 473 | 474 | prepare_dir "${livefs}" 475 | 476 | mount_overlay "${livefs}" "${work_dir}" "${desktop_list}" 477 | 478 | install_packages "${livefs}" 479 | 480 | copy_overlay "${live_overlay}" "${livefs}" 481 | 482 | configure_live_image "${livefs}" 483 | 484 | pacman -Qr "${livefs}" > ${iso_dir}/$(gen_iso_fn)-pkgs.txt 485 | 486 | umount_overlay 487 | 488 | clean_up_image "${livefs}" 489 | 490 | msg "Done [Live installation] (livefs)" 491 | fi 492 | } 493 | 494 | make_bootfs() { 495 | if [[ ! -e ${work_dir}/bootfs.lock ]]; then 496 | msg "Prepare [/iso/boot]" 497 | local boot="${iso_root}/boot" 498 | 499 | prepare_dir "${boot}" 500 | 501 | cp ${work_dir}/rootfs/boot/vmlinuz* ${boot}/vmlinuz-${target_arch} 502 | 503 | local bootfs="${work_dir}/bootfs" 504 | 505 | mount_overlay "${bootfs}" "${work_dir}" "${desktop_list}" 506 | 507 | prepare_initcpio "${bootfs}" 508 | prepare_initramfs "${bootfs}" 509 | 510 | cp ${bootfs}/boot/initramfs.img ${boot}/initramfs-${target_arch}.img 511 | prepare_boot_extras "${bootfs}" "${boot}" 512 | 513 | umount_overlay 514 | 515 | rm -R ${bootfs} 516 | : > ${work_dir}/bootfs.lock 517 | msg "Done [/iso/boot]" 518 | fi 519 | } 520 | 521 | make_grub(){ 522 | if [[ ! -e ${work_dir}/grub.lock ]]; then 523 | msg "Prepare [/iso/boot/grub]" 524 | 525 | prepare_grub "${work_dir}/rootfs" "${work_dir}/livefs" "${iso_root}" 526 | 527 | configure_grub "${iso_root}" 528 | 529 | : > ${work_dir}/grub.lock 530 | msg "Done [/iso/boot/grub]" 531 | fi 532 | } 533 | 534 | compress_images(){ 535 | local timer=$(get_timer) 536 | run_safe "make_iso" 537 | user_own "${iso_dir}" "-R" 538 | show_elapsed_time "${FUNCNAME}" "${timer}" 539 | } 540 | 541 | prepare_images(){ 542 | local timer=$(get_timer) 543 | load_pkgs "${root_list}" "${initsys}" 544 | run_safe "make_rootfs" 545 | if [[ -f "${desktop_list}" ]] ; then 546 | load_pkgs "${desktop_list}" "${initsys}" 547 | run_safe "make_desktopfs" 548 | fi 549 | if [[ -f ${live_list} ]]; then 550 | load_pkgs "${live_list}" "${initsys}" 551 | run_safe "make_livefs" 552 | fi 553 | run_safe "make_bootfs" 554 | run_safe "make_grub" 555 | 556 | show_elapsed_time "${FUNCNAME}" "${timer}" 557 | } 558 | -------------------------------------------------------------------------------- /lib/util-mount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This program is free software; you can redistribute it and/or modify 3 | # it under the terms of the GNU General Public License as published by 4 | # the Free Software Foundation; version 2 of the License. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | 11 | ignore_error() { 12 | "$@" 2>/dev/null 13 | return 0 14 | } 15 | 16 | parse_fstab(){ 17 | echo $(perl -ane 'printf("%s:%s\n", @F[0,1]) if $F[0] =~ m#^UUID=#;' $1/etc/fstab) 18 | # perl -ane 'printf("%s:%s\n", @F[0,1]) if $F[0] =~ m#^/dev#;' $1/etc/fstab 19 | # perl -ane 'printf("%s:%s\n", @F[0,1]) if $F[0] =~ m#^LABEL=#;' $1/etc/fstab 20 | } 21 | 22 | detect(){ 23 | local detected="$(os-prober | tr ' ' '_' | paste -s -d ' ')" 24 | echo ${detected} 25 | } 26 | 27 | # $1: os-prober array 28 | get_os_name(){ 29 | local str=$1 30 | str="${str#*:}" 31 | str="${str#*:}" 32 | str="${str%:*}" 33 | echo "$str" 34 | } 35 | 36 | get_chroot_arch(){ 37 | local elf=$(file $1/usr/bin/file) 38 | elf=${elf//*executable,} 39 | echo ${elf%%,*} 40 | } 41 | 42 | chroot_part_mount() { 43 | info "mount: [%s]" "$2" 44 | mount "$@" && CHROOT_ACTIVE_PART_MOUNTS=("$2" "${CHROOT_ACTIVE_PART_MOUNTS[@]}") 45 | } 46 | 47 | select_os(){ 48 | local os_list=( $(detect) ) count=${#os_list[@]} 49 | if [[ ${count} > 1 ]];then 50 | msg "Detected systems:" 51 | local i=0 52 | for os in ${os_list[@]};do 53 | local last=${os##*:} 54 | case $last in 55 | 'efi') count=$((count-1)) ;; 56 | *) info "$i) $(get_os_name $os)"; i=$((i+1)) ;; 57 | esac 58 | done 59 | i=0 60 | msg "Select system to mount [0-%s] : " "$((count-1))" 61 | read select 62 | else 63 | select=0 64 | fi 65 | local os_str=${os_list[$select]} type 66 | type=$os_str 67 | root=${os_str%%:*} 68 | type=${type##*:} 69 | if [[ "${type##*:}" == 'linux' ]];then 70 | msg "Mounting (%s) [%s]" "$(get_os_name $os_str)" "$root" 71 | mount_os "$1" "$root" 72 | else 73 | die "You can't mount %s!" "$select" 74 | fi 75 | } 76 | 77 | trap_setup(){ 78 | [[ $(trap -p EXIT) ]] && die 'Error! Attempting to overwrite existing EXIT trap' 79 | trap "$1" EXIT 80 | } 81 | 82 | chroot_mount() { 83 | info "mount: [%s]" "$2" 84 | mount "$@" && CHROOT_ACTIVE_MOUNTS=("$2" "${CHROOT_ACTIVE_MOUNTS[@]}") 85 | } 86 | 87 | chroot_add_resolv_conf() { 88 | local chrootdir=$1 resolv_conf=$1/etc/resolv.conf 89 | 90 | [[ -e /etc/resolv.conf ]] || return 0 91 | 92 | # Handle resolv.conf as a symlink to somewhere else. 93 | if [[ -L $chrootdir/etc/resolv.conf ]]; then 94 | # readlink(1) should always give us *something* since we know at this point 95 | # it's a symlink. For simplicity, ignore the case of nested symlinks. 96 | resolv_conf=$(readlink "$chrootdir/etc/resolv.conf") 97 | if [[ $resolv_conf = /* ]]; then 98 | resolv_conf=$chrootdir$resolv_conf 99 | else 100 | resolv_conf=$chrootdir/etc/$resolv_conf 101 | fi 102 | 103 | # ensure file exists to bind mount over 104 | if [[ ! -f $resolv_conf ]]; then 105 | install -Dm644 /dev/null "$resolv_conf" || return 1 106 | fi 107 | elif [[ ! -e $chrootdir/etc/resolv.conf ]]; then 108 | # The chroot might not have a resolv.conf. 109 | return 0 110 | fi 111 | 112 | chroot_mount /etc/resolv.conf "$resolv_conf" --bind 113 | } 114 | 115 | chroot_mount_conditional() { 116 | local cond=$1; shift 117 | if eval "$cond"; then 118 | chroot_mount "$@" 119 | fi 120 | } 121 | 122 | chroot_setup(){ 123 | chroot_mount_conditional "! mountpoint -q '$1'" "$1" "$1" --bind && 124 | chroot_mount proc "$1/proc" -t proc -o nosuid,noexec,nodev && 125 | chroot_mount sys "$1/sys" -t sysfs -o nosuid,noexec,nodev,ro && 126 | ignore_error chroot_mount_conditional "[[ -d '$1/sys/firmware/efi/efivars' ]]" \ 127 | efivarfs "$1/sys/firmware/efi/efivars" -t efivarfs -o nosuid,noexec,nodev && 128 | chroot_mount udev "$1/dev" -t devtmpfs -o mode=0755,nosuid && 129 | chroot_mount devpts "$1/dev/pts" -t devpts -o mode=0620,gid=5,nosuid,noexec && 130 | chroot_mount shm "$1/dev/shm" -t tmpfs -o mode=1777,nosuid,nodev && 131 | chroot_mount run "$1/run" -t tmpfs -o nosuid,nodev,mode=0755 && 132 | chroot_mount tmp "$1/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid 133 | } 134 | 135 | mount_os(){ 136 | CHROOT_ACTIVE_PART_MOUNTS=() 137 | CHROOT_ACTIVE_MOUNTS=() 138 | 139 | trap_setup chroot_part_umount 140 | 141 | chroot_part_mount "$2" "$1" 142 | 143 | local mounts=$(parse_fstab "$1") 144 | 145 | for entry in ${mounts[@]}; do 146 | entry=${entry//UUID=} 147 | local dev=${entry%:*} mp=${entry#*:} 148 | case "${entry#*:}" in 149 | '/'|'swap'|'none') continue ;; 150 | *) chroot_part_mount "/dev/disk/by-uuid/${dev}" "$1${mp}" ;; 151 | esac 152 | done 153 | 154 | local chroot_arch=$(get_chroot_arch $1) 155 | [[ ${chroot_arch} == x86-64 ]] && chroot_arch=${chroot_arch/-/_} 156 | case ${target_arch} in 157 | i686) 158 | if [[ ${chroot_arch} == x86_64 ]];then 159 | die "You can't chroot from %s host into %s!" "${target_arch}" "${chroot_arch}" 160 | fi 161 | ;; 162 | esac 163 | 164 | chroot_setup "$1" 165 | chroot_add_resolv_conf "$1" 166 | } 167 | 168 | chroot_api_mount() { 169 | CHROOT_ACTIVE_MOUNTS=() 170 | trap_setup chroot_api_umount 171 | chroot_setup "$1" 172 | } 173 | 174 | chroot_part_umount() { 175 | info "umount: [%s]" "${CHROOT_ACTIVE_MOUNTS[@]}" 176 | umount "${CHROOT_ACTIVE_MOUNTS[@]}" 177 | info "umount: [%s]" "${CHROOT_ACTIVE_PART_MOUNTS[@]}" 178 | umount "${CHROOT_ACTIVE_PART_MOUNTS[@]}" 179 | unset CHROOT_ACTIVE_PART_MOUNTS CHROOT_ACTIVE_MOUNTS 180 | } 181 | 182 | chroot_api_umount() { 183 | info "umount: [%s]" "${CHROOT_ACTIVE_MOUNTS[@]}" 184 | umount "${CHROOT_ACTIVE_MOUNTS[@]}" 185 | unset CHROOT_ACTIVE_MOUNTS 186 | } 187 | -------------------------------------------------------------------------------- /lib/util-msg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This program is free software; you can redistribute it and/or modify 3 | # it under the terms of the GNU General Public License as published by 4 | # the Free Software Foundation; version 2 of the License. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | 11 | # export LC_MESSAGES=C 12 | export LANG=C 13 | 14 | source /usr/share/makepkg/util.sh 15 | 16 | if [[ -t 2 ]]; then 17 | colorize 18 | else 19 | declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW='' 20 | fi 21 | 22 | info() { 23 | local mesg=$1; shift 24 | printf "${YELLOW} -->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 25 | } 26 | 27 | stat_busy() { 28 | local mesg=$1; shift 29 | printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2 30 | } 31 | 32 | stat_done() { 33 | printf "${BOLD}done${ALL_OFF}\n" >&2 34 | } 35 | 36 | lock_close() { 37 | local fd=$1 38 | exec {fd}>&- 39 | } 40 | 41 | lock() { 42 | if ! [[ "/dev/fd/$1" -ef "$2" ]]; then 43 | mkdir -p -- "$(dirname -- "$2")" 44 | eval "exec $1>"'"$2"' 45 | fi 46 | if ! flock -n $1; then 47 | stat_busy "$3" 48 | flock $1 49 | stat_done 50 | fi 51 | } 52 | 53 | slock() { 54 | if ! [[ "/dev/fd/$1" -ef "$2" ]]; then 55 | mkdir -p -- "$(dirname -- "$2")" 56 | eval "exec $1>"'"$2"' 57 | fi 58 | if ! flock -sn $1; then 59 | stat_busy "$3" 60 | flock -s $1 61 | stat_done 62 | fi 63 | } 64 | 65 | cleanup() { 66 | exit ${1:-0} 67 | } 68 | 69 | abort() { 70 | error 'Aborting...' 71 | cleanup 255 72 | } 73 | 74 | die() { 75 | (( $# )) && error "$@" 76 | cleanup 255 77 | } 78 | 79 | msg_table_header(){ 80 | local mesg=$1; shift 81 | printf "${BLUE} ${mesg} ${ALL_OFF}\n" "$@" >&2 82 | } 83 | 84 | msg_row_downgrade(){ 85 | local mesg=$1; shift 86 | printf "${YELLOW} ${mesg}${ALL_OFF}\n" "$@" >&2 87 | } 88 | 89 | msg_row_notify(){ 90 | local mesg=$1; shift 91 | printf "${GREEN} ${mesg}${ALL_OFF}\n" "$@" >&2 92 | } 93 | 94 | msg_row(){ 95 | local mesg=$1; shift 96 | printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 97 | } 98 | 99 | msg_row_upgrade(){ 100 | local mesg=$1; shift 101 | printf "${RED}${RED} ${mesg} ${ALL_OFF}\n" "$@" >&2 102 | } 103 | 104 | import(){ 105 | if [[ -r "$1" ]];then 106 | source "$1" 107 | else 108 | die 'Could not import %s' "$1" 109 | fi 110 | } 111 | -------------------------------------------------------------------------------- /lib/util-pkg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | 12 | get_local_head(){ 13 | echo $(git log --pretty=%H ...refs/heads/$1^ | head -n 1) 14 | } 15 | 16 | get_remote_head(){ 17 | echo $(git ls-remote origin -h refs/heads/$1 | cut -f1) 18 | } 19 | 20 | is_dirty() { 21 | [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] || return 1 22 | return 0 23 | } 24 | 25 | is_untracked(){ 26 | [[ $(git ls-files --others --exclude-standard) != "" ]] || return 1 27 | return 0 28 | } 29 | 30 | patch_pkg(){ 31 | local pkg="$1" repo="$2" 32 | case $pkg in 33 | 'glibc') 34 | sed -e 's|{locale,systemd/system,tmpfiles.d}|{locale,tmpfiles.d}|' \ 35 | -e '/nscd.service/d' \ 36 | -i $pkg/trunk/PKGBUILD 37 | ;; 38 | 'tp_smapi'|'acpi_call'|'r8168'|'bbswitch'|'broadcom-wl') 39 | sed -e 's|-ARCH|-ARTIX|g' -i $pkg/trunk/PKGBUILD 40 | ;; 41 | 'nvidia') 42 | sed -e 's|-ARCH|-ARTIX|g' -e 's|for Arch kernel|for Artix kernel|g' \ 43 | -e 's|for LTS Arch kernel|for LTS Artix kernel|g' \ 44 | -i $pkg/trunk/PKGBUILD 45 | ;; 46 | 'linux') 47 | sed -e 's|-ARCH|-ARTIX|g' -i $pkg/trunk/PKGBUILD 48 | sed -e 's|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION="-ARTIX"|' \ 49 | -e 's|CONFIG_DEFAULT_HOSTNAME=.*|CONFIG_DEFAULT_HOSTNAME="artixlinux"|' \ 50 | -e 's|CONFIG_CRYPTO_SPECK=.*|CONFIG_CRYPTO_SPECK=n|' \ 51 | -i $pkg/trunk/config 52 | cd $pkg/trunk 53 | updpkgsums 54 | cd ../.. 55 | 56 | ;; 57 | 'licenses') 58 | sed -e 's|https://www.archlinux.org/|https://www.artixlinux.org/|' -i $pkg/trunk/PKGBUILD 59 | ;; 60 | 'bash') 61 | sed -e 's|system.bash_logout)|system.bash_logout artix.bashrc)|' \ 62 | -e "s|etc/bash.|etc/bash/|g" \ 63 | -e 's|"$pkgdir/etc/skel/.bash_logout"|"$pkgdir/etc/skel/.bash_logout"\n install -Dm644 artix.bashrc $pkgdir/etc/bash/bashrc.d/artix.bashrc|' \ 64 | -i $pkg/trunk/PKGBUILD 65 | 66 | 67 | cd $pkg/trunk 68 | patch -Np 1 -i ${DATADIR}/patches/artix-bash.patch 69 | updpkgsums 70 | cd ../.. 71 | ;; 72 | gstreamer|gst-plugins-*) 73 | sed -e 's|https://www.archlinux.org/|https://www.artixlinux.org/|' \ 74 | -e 's|(Arch Linux)|(Artix Linux)|' \ 75 | -i $pkg/trunk/PKGBUILD 76 | ;; 77 | esac 78 | } 79 | 80 | find_tree(){ 81 | local tree="$1" pkg="$2" 82 | local result=$(find $tree -mindepth 2 -maxdepth 2 -type d -name "$pkg") 83 | result=${result%/*} 84 | echo ${result##*/} 85 | } 86 | 87 | clone_tree(){ 88 | local timer=$(get_timer) host_tree="$1" 89 | git clone $host_tree.git 90 | show_elapsed_time "${FUNCNAME}" "${timer}" 91 | } 92 | 93 | pull_tree(){ 94 | local branch="master" 95 | local local_head=$(get_local_head "$branch") 96 | local remote_head=$(get_remote_head "$branch") 97 | if [[ "${local_head}" == "${remote_head}" ]]; then 98 | msg2 "remote changes: no" 99 | else 100 | msg2 "remote changes: yes" 101 | git pull origin "$branch" 102 | fi 103 | } 104 | 105 | push_tree(){ 106 | local branch="master" 107 | git push origin "$branch" 108 | } 109 | 110 | get_import_path(){ 111 | local tree="$1" import_path= 112 | case $tree in 113 | packages) import_path=${tree_dir_arch}/packages ;; 114 | packages-galaxy) import_path=${tree_dir_arch}/community ;; 115 | esac 116 | echo $import_path 117 | } 118 | 119 | is_valid_repo(){ 120 | local src="$1" 121 | case $src in 122 | core|extra|community|multilib|testing|staging|community-testing|community-staging|multilib-testing|multilib-staging|trunk) return 0 ;; 123 | *) return 1 ;; 124 | esac 125 | } 126 | 127 | find_repo(){ 128 | local pkg="$1" unst="$2" stag="$3" repo= 129 | 130 | if [[ -f $pkg/repos/core-x86_64/PKGBUILD ]];then 131 | repo=core-x86_64 132 | elif [[ -f $pkg/repos/core-any/PKGBUILD ]];then 133 | repo=core-any 134 | fi 135 | 136 | if [[ -f $pkg/repos/extra-x86_64/PKGBUILD ]];then 137 | repo=extra-x86_64 138 | elif [[ -f $pkg/repos/extra-any/PKGBUILD ]];then 139 | repo=extra-any 140 | fi 141 | 142 | if [[ -f $pkg/repos/testing-x86_64/PKGBUILD ]];then 143 | repo=testing-x86_64 144 | elif [[ -f $pkg/repos/testing-any/PKGBUILD ]];then 145 | repo=testing-any 146 | fi 147 | 148 | if $stag;then 149 | if [[ -f $pkg/repos/staging-x86_64/PKGBUILD ]];then 150 | repo=staging-x86_64 151 | elif [[ -f $pkg/repos/staging-any/PKGBUILD ]];then 152 | repo=staging-any 153 | fi 154 | fi 155 | 156 | if [[ -f $pkg/repos/community-x86_64/PKGBUILD ]];then 157 | repo=community-x86_64 158 | elif [[ -f $pkg/repos/community-any/PKGBUILD ]];then 159 | repo=community-any 160 | fi 161 | 162 | if [[ -f $pkg/repos/community-testing-x86_64/PKGBUILD ]];then 163 | repo=community-testing-x86_64 164 | elif [[ -f $pkg/repos/community-testing-any/PKGBUILD ]];then 165 | repo=community-testing-any 166 | fi 167 | 168 | if $stag;then 169 | if [[ -f $pkg/repos/community-staging-x86_64/PKGBUILD ]];then 170 | repo=community-staging-x86_64 171 | elif [[ -f $pkg/repos/community-staging-any/PKGBUILD ]];then 172 | repo=community-staging-any 173 | fi 174 | fi 175 | 176 | if [[ -f $pkg/repos/multilib-x86_64/PKGBUILD ]];then 177 | repo=multilib-x86_64 178 | fi 179 | 180 | if [[ -f $pkg/repos/multilib-testing-x86_64/PKGBUILD ]];then 181 | repo=multilib-testing-x86_64 182 | fi 183 | 184 | if $stag;then 185 | if [[ -f $pkg/repos/multilib-staging-x86_64/PKGBUILD ]];then 186 | repo=multilib-staging-x86_64 187 | fi 188 | fi 189 | 190 | if $unst;then 191 | if [[ -f $pkg/repos/gnome-unstable-x86_64/PKGBUILD ]];then 192 | repo=gnome-unstable-x86_64 193 | elif [[ -f $pkg/repos/gnome-unstable-any/PKGBUILD ]];then 194 | repo=gnome-unstable-any 195 | fi 196 | 197 | if [[ -f $pkg/repos/kde-unstable-x86_64/PKGBUILD ]];then 198 | repo=kde-unstable-x86_64 199 | elif [[ -f $pkg/repos/kde-unstable-any/PKGBUILD ]];then 200 | repo=kde-unstable-any 201 | fi 202 | fi 203 | echo $repo 204 | } 205 | 206 | arch_to_artix_repo(){ 207 | local repo="$1" 208 | case $repo in 209 | core-*) repo=system ;; 210 | extra-*) repo=world ;; 211 | community-x86_64|community-any) repo=galaxy ;; 212 | multilib-x86_64) repo=lib32 ;; 213 | testing-*) repo=gremlins ;; 214 | staging-*) repo=goblins ;; 215 | multilib-testing-x86_64) repo=lib32-gremlins ;; 216 | multilib-staging-x86_64) repo=lib32-goblins ;; 217 | community-testing-*) repo=galaxy-gremlins ;; 218 | community-staging-*) repo=galaxy-goblins ;; 219 | kde-unstable-*|gnome-unstable-*) repo=goblins ;; 220 | esac 221 | echo $repo 222 | } 223 | 224 | # $1: sofile 225 | # $2: soarch 226 | process_sofile() { 227 | # extract the library name: libfoo.so 228 | local soname="${1%.so?(+(.+([0-9])))}".so 229 | # extract the major version: 1 230 | soversion="${1##*\.so\.}" 231 | if [[ "$soversion" = "$1" ]] && (($IGNORE_INTERNAL)); then 232 | continue 233 | fi 234 | if ! in_array "${soname}=${soversion}-$2" ${soobjects[@]}; then 235 | # libfoo.so=1-64 236 | msg "${soname}=${soversion}-$2" 237 | soobjects+=("${soname}=${soversion}-$2") 238 | fi 239 | } 240 | 241 | pkgver_equal() { 242 | if [[ $1 = *-* && $2 = *-* ]]; then 243 | # if both versions have a pkgrel, then they must be an exact match 244 | [[ $1 = "$2" ]] 245 | else 246 | # otherwise, trim any pkgrel and compare the bare version. 247 | [[ ${1%%-*} = "${2%%-*}" ]] 248 | fi 249 | } 250 | 251 | find_cached_package() { 252 | local searchdirs=("$PKGDEST" "$PWD") results=() 253 | local targetname=$1 targetver=$2 targetarch=$3 254 | local dir pkg pkgbasename name ver rel arch r results 255 | 256 | for dir in "${searchdirs[@]}"; do 257 | [[ -d $dir ]] || continue 258 | 259 | for pkg in "$dir"/*.pkg.tar.?z; do 260 | [[ -f $pkg ]] || continue 261 | 262 | # avoid adding duplicates of the same inode 263 | for r in "${results[@]}"; do 264 | [[ $r -ef $pkg ]] && continue 2 265 | done 266 | 267 | # split apart package filename into parts 268 | pkgbasename=${pkg##*/} 269 | pkgbasename=${pkgbasename%.pkg.tar.?z} 270 | 271 | arch=${pkgbasename##*-} 272 | pkgbasename=${pkgbasename%-"$arch"} 273 | 274 | rel=${pkgbasename##*-} 275 | pkgbasename=${pkgbasename%-"$rel"} 276 | 277 | ver=${pkgbasename##*-} 278 | name=${pkgbasename%-"$ver"} 279 | 280 | if [[ $targetname = "$name" && $targetarch = "$arch" ]] && 281 | pkgver_equal "$targetver" "$ver-$rel"; then 282 | results+=("$pkg") 283 | fi 284 | done 285 | done 286 | 287 | case ${#results[*]} in 288 | 0) 289 | return 1 290 | ;; 291 | 1) 292 | printf '%s\n' "${results[0]}" 293 | return 0 294 | ;; 295 | *) 296 | error 'Multiple packages found:' 297 | printf '\t%s\n' "${results[@]}" >&2 298 | return 1 299 | ;; 300 | esac 301 | } 302 | -------------------------------------------------------------------------------- /lib/util.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This program is free software; you can redistribute it and/or modify 3 | # it under the terms of the GNU General Public License as published by 4 | # the Free Software Foundation; version 2 of the License. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | 11 | get_timer(){ 12 | echo $(date +%s) 13 | } 14 | 15 | # $1: start timer 16 | elapsed_time(){ 17 | echo $(echo $1 $(get_timer) | awk '{ printf "%0.2f",($2-$1)/60 }') 18 | } 19 | 20 | show_elapsed_time(){ 21 | info "Time %s: %s minutes" "$1" "$(elapsed_time $2)" 22 | } 23 | 24 | load_vars() { 25 | local var 26 | 27 | [[ -f $1 ]] || return 1 28 | 29 | for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER CARCH GPGKEY; do 30 | [[ -z ${!var:-} ]] && eval "$(grep -a "^${var}=" "$1")" 31 | done 32 | 33 | return 0 34 | } 35 | 36 | prepare_dir(){ 37 | [[ ! -d $1 ]] && mkdir -p $1 38 | } 39 | 40 | get_disturl(){ 41 | source /usr/lib/os-release 42 | echo "${HOME_URL}" 43 | } 44 | 45 | get_osname(){ 46 | source /usr/lib/os-release 47 | echo "${NAME}" 48 | } 49 | 50 | init_artools_base(){ 51 | 52 | target_arch=$(uname -m) 53 | 54 | [[ -z ${chroots_dir} ]] && chroots_dir='/var/lib/artools' 55 | 56 | [[ -z ${workspace_dir} ]] && workspace_dir=/home/${OWNER}/artools-workspace 57 | 58 | prepare_dir "${workspace_dir}" 59 | } 60 | 61 | init_artools_pkg(){ 62 | 63 | [[ -z ${tree_dir_artix} ]] && tree_dir_artix=${workspace_dir}/artix 64 | 65 | [[ -z ${host_tree_artix} ]] && host_tree_artix='https://github.com/artix-linux' 66 | 67 | [[ -z ${tree_dir_arch} ]] && tree_dir_arch=${workspace_dir}/archlinux 68 | 69 | [[ -z ${host_tree_arch} ]] && host_tree_arch='git://projects.archlinux.org/svntogit' 70 | 71 | chroots_pkg="${chroots_dir}/buildpkg" 72 | 73 | [[ -z ${repos_root} ]] && repos_root="${workspace_dir}/repos" 74 | } 75 | 76 | init_artools_iso(){ 77 | chroots_iso="${chroots_dir}/buildiso" 78 | 79 | [[ -z ${iso_pool} ]] && iso_pool="${workspace_dir}/iso" 80 | 81 | prepare_dir "${iso_pool}" 82 | 83 | profile='base' 84 | 85 | [[ -z ${iso_version} ]] && iso_version=$(date +%Y%m%d) 86 | 87 | iso_label="ARTIX_$(date +%Y%m)" 88 | 89 | [[ -z ${initsys} ]] && initsys="openrc" 90 | 91 | [[ -z ${gpgkey} ]] && gpgkey='' 92 | 93 | [[ -z ${uplimit} ]] && uplimit=100 94 | 95 | [[ -z ${tracker_url} ]] && tracker_url='udp://mirror.strits.dk:6969' 96 | 97 | [[ -z ${piece_size} ]] && piece_size=21 98 | 99 | [[ -z ${file_host} ]] && file_host="sourceforge.net" 100 | 101 | [[ -z ${project} ]] && project="artix-linux" 102 | 103 | [[ -z ${account} ]] && account="[SetUser]" 104 | 105 | [[ -z ${host_mirrors[@]} ]] && host_mirrors=('netcologne' 'freefr' 'netix' 'kent' '10gbps-io') 106 | 107 | torrent_meta="$(get_osname)" 108 | } 109 | 110 | 111 | load_config(){ 112 | 113 | [[ -f $1 ]] || return 1 114 | 115 | artools_conf="$1" 116 | 117 | [[ -r ${artools_conf} ]] && source ${artools_conf} 118 | 119 | init_artools_base 120 | 121 | init_artools_pkg 122 | 123 | init_artools_iso 124 | 125 | return 0 126 | } 127 | 128 | user_own(){ 129 | local flag=$2 130 | chown ${flag} "${OWNER}:$(id --group ${OWNER})" "$1" 131 | } 132 | 133 | user_run(){ 134 | su ${OWNER} -c "$@" 135 | } 136 | 137 | clean_dir(){ 138 | if [[ -d $1 ]]; then 139 | msg "Cleaning [%s] ..." "$1" 140 | rm -r $1/* 141 | fi 142 | } 143 | 144 | load_user_info(){ 145 | OWNER=${SUDO_USER:-$USER} 146 | 147 | if [[ -n $SUDO_USER ]]; then 148 | eval "USER_HOME=~$SUDO_USER" 149 | else 150 | USER_HOME=$HOME 151 | fi 152 | 153 | AT_USERCONFDIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/artools" 154 | PAC_USERCONFDIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/pacman" 155 | prepare_dir "${AT_USERCONFDIR}" 156 | } 157 | 158 | show_version(){ 159 | msg "artools" 160 | msg2 "version: %s" "${version}" 161 | } 162 | 163 | show_config(){ 164 | if [[ -f ${AT_USERCONFDIR}/artools.conf ]]; then 165 | msg2 "config: %s" "~/.config/artools/artools.conf" 166 | else 167 | msg2 "config: %s" "${artools_conf}" 168 | fi 169 | } 170 | 171 | check_root() { 172 | (( EUID == 0 )) && return 173 | if type -P sudo >/dev/null; then 174 | exec sudo -- "${orig_argv[@]}" 175 | else 176 | exec su root -c "$(printf ' %q' "${orig_argv[@]}")" 177 | fi 178 | } 179 | --------------------------------------------------------------------------------