forked from artix/artools
		
	Compare commits
	
		
			10 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 34ed4ef723 | |||
| aaa319c67a | |||
| 3304c888a5 | |||
| 095c7ced45 | |||
| f4eef7a3cd | |||
| 6fc1850f1f | |||
| c0a3a7e796 | |||
| 08fff866ed | |||
| 8bef697c44 | |||
| a6eadf1af4 | 
							
								
								
									
										30
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								Makefile
									
									
									
									
									
								
							| @@ -36,28 +36,6 @@ TOOLS_CONFIGS_BASE=$(wildcard config/conf/*base*) | |||||||
| TOOLS_CONFIGS_PKG=$(wildcard config/conf/*pkg*) | TOOLS_CONFIGS_PKG=$(wildcard config/conf/*pkg*) | ||||||
| TOOLS_CONFIGS_ISO=$(wildcard config/conf/*iso*) | TOOLS_CONFIGS_ISO=$(wildcard config/conf/*iso*) | ||||||
|  |  | ||||||
| LN_BUILDPKG = \ |  | ||||||
| 	buildpkg-system-x86_64 \ |  | ||||||
| 	buildpkg-system-gremlins-x86_64 \ |  | ||||||
| 	buildpkg-system-goblins-x86_64 \ |  | ||||||
| 	buildpkg-world-x86_64 \ |  | ||||||
| 	buildpkg-world-gremlins-x86_64 \ |  | ||||||
| 	buildpkg-world-goblins-x86_64 \ |  | ||||||
| 	buildpkg-lib32-x86_64 \ |  | ||||||
| 	buildpkg-lib32-gremlins-x86_64 \ |  | ||||||
| 	buildpkg-lib32-goblins-x86_64 \ |  | ||||||
| 	buildpkg-galaxy-x86_64 \ |  | ||||||
| 	buildpkg-galaxy-gremlins-x86_64 \ |  | ||||||
| 	buildpkg-galaxy-goblins-x86_64 |  | ||||||
|  |  | ||||||
| LN_BUILDISO = \ |  | ||||||
| 	buildiso-world \ |  | ||||||
| 	buildiso-world-gremlins \ |  | ||||||
| 	buildiso-world-goblins \ |  | ||||||
| 	buildiso-galaxy \ |  | ||||||
| 	buildiso-galaxy-gremlins \ |  | ||||||
| 	buildiso-galaxy-goblins |  | ||||||
|  |  | ||||||
| all: binprogs_base binprogs_pkg binprogs_iso library_base library_pkg library_iso conf_base conf_pkg conf_iso | all: binprogs_base binprogs_pkg binprogs_iso library_base library_pkg library_iso conf_base conf_pkg conf_iso | ||||||
| binprogs_base: $(BINPROGS_BASE) | binprogs_base: $(BINPROGS_BASE) | ||||||
| binprogs_pkg: $(BINPROGS_PKG) | binprogs_pkg: $(BINPROGS_PKG) | ||||||
| @@ -134,12 +112,8 @@ install_pkg: binprogs_pkg | |||||||
|  |  | ||||||
| 	for conf in $(notdir $(MAKEPKG_CONFIGS)); do install -Dm0644 $(BUILDDIR)/makepkg.conf.d/$$conf $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done | 	for conf in $(notdir $(MAKEPKG_CONFIGS)); do install -Dm0644 $(BUILDDIR)/makepkg.conf.d/$$conf $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done | ||||||
| 	for a in $(SETARCH_ALIASES); do install -m0644 $$a -t $(DESTDIR)$(DATADIR)/setarch-aliases.d; done | 	for a in $(SETARCH_ALIASES); do install -m0644 $$a -t $(DESTDIR)$(DATADIR)/setarch-aliases.d; done | ||||||
| 	for l in $(LN_BUILDPKG); do ln -sf buildpkg $(DESTDIR)$(PREFIX)/bin/$$l; done |  | ||||||
| 	ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides | 	ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides | ||||||
|  |  | ||||||
| 	# compat symlink |  | ||||||
| 	ln -sf repopkg $(DESTDIR)$(PREFIX)/bin/deploypkg |  | ||||||
|  |  | ||||||
| install_iso: binprogs_iso | install_iso: binprogs_iso | ||||||
| 	install -dm0755 $(DESTDIR)$(SYSCONFDIR)/$(TOOLS) | 	install -dm0755 $(DESTDIR)$(SYSCONFDIR)/$(TOOLS) | ||||||
| 	install -dm0755 $(DESTDIR)$(PREFIX)/bin | 	install -dm0755 $(DESTDIR)$(PREFIX)/bin | ||||||
| @@ -149,8 +123,6 @@ install_iso: binprogs_iso | |||||||
|  |  | ||||||
| 	for conf in $(notdir $(TOOLS_CONFIGS_ISO)); do install -Dm0644 $(BUILDDIR)/$(TOOLS)/$$conf $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)/$${conf##*/}; done | 	for conf in $(notdir $(TOOLS_CONFIGS_ISO)); do install -Dm0644 $(BUILDDIR)/$(TOOLS)/$$conf $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)/$${conf##*/}; done | ||||||
|  |  | ||||||
| 	for l in $(LN_BUILDISO); do ln -sf buildiso $(DESTDIR)$(PREFIX)/bin/$$l; done |  | ||||||
|  |  | ||||||
| install: all install_base install_pkg install_iso | install: all install_base install_pkg install_iso | ||||||
|  |  | ||||||
| uninstall: | uninstall: | ||||||
| @@ -161,8 +133,6 @@ uninstall: | |||||||
| 	for conf in $(notdir $(MAKEPKG_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done | 	for conf in $(notdir $(MAKEPKG_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done | ||||||
| 	for conf in $(notdir $(PACMAN_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done | 	for conf in $(notdir $(PACMAN_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done | ||||||
| 	for f in $(notdir $(SETARCH_ALIASES)); do rm -f $(DESTDIR)$(DATADIR)/setarch-aliases.d/$$f; done | 	for f in $(notdir $(SETARCH_ALIASES)); do rm -f $(DESTDIR)$(DATADIR)/setarch-aliases.d/$$f; done | ||||||
| 	for l in $(LN_BUILDPKG); do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done |  | ||||||
| 	for l in $(LN_BUILDISO); do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done |  | ||||||
| 	rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides | 	rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides | ||||||
| 	rmdir --ignore-fail-on-non-empty \ | 	rmdir --ignore-fail-on-non-empty \ | ||||||
| 		$(DESTDIR)$(DATADIR)/setarch-aliases.d \ | 		$(DESTDIR)$(DATADIR)/setarch-aliases.d \ | ||||||
|   | |||||||
| @@ -74,11 +74,11 @@ Specifying args will override artools-{base,pkg,iso}.conf settings. | |||||||
| Both, pacman.conf and makepkg.conf for chroots are loaded from | Both, pacman.conf and makepkg.conf for chroots are loaded from | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| usr/share/artools/makepkg.conf.d/makepkg.conf | usr/share/artools/makepkg.conf.d/${arch}.conf | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| usr/share/artools/pacmanconf.d/${repo}.conf | usr/share/artools/pacmanconf.d/${repo}-${arch}.conf | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| and can be overridden dropping them in | and can be overridden dropping them in | ||||||
|   | |||||||
| @@ -10,3 +10,11 @@ | |||||||
|  |  | ||||||
| # the workspace directory | # the workspace directory | ||||||
| # WORKSPACE_DIR="${USER_HOME}/artools-workspace" | # WORKSPACE_DIR="${USER_HOME}/artools-workspace" | ||||||
|  |  | ||||||
|  | # the arch to build | ||||||
|  | # ARCH=$(uname -m) | ||||||
|  |  | ||||||
|  | # default pacman.conf repos to include | ||||||
|  | # possible buildpkg values: {system,world,galaxy,lib32}{-gremlins,-goblins} | ||||||
|  | # possible buildiso values: {world,galaxy}{-gremlins,-goblins} | ||||||
|  | # REPO="world" | ||||||
|   | |||||||
| @@ -197,8 +197,10 @@ gen_iso_fn(){ | |||||||
| prepare_build(){ | prepare_build(){ | ||||||
|     load_profile |     load_profile | ||||||
|  |  | ||||||
|     pacman_conf="${DATADIR}/pacman.conf.d/${repo}.conf" |     pacman_conf="${DATADIR}/pacman.conf.d/${repo}-${arch}.conf" | ||||||
|     [[ -f "${USER_CONF_DIR}/pacman.conf.d/${repo}.conf" ]] && pacman_conf="${USER_CONF_DIR}/pacman.conf.d/${repo}.conf" |     if [[ -f "${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf" ]]; then | ||||||
|  |         pacman_conf="${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf" | ||||||
|  |     fi | ||||||
|  |  | ||||||
|     iso_file=$(gen_iso_fn).iso |     iso_file=$(gen_iso_fn).iso | ||||||
|  |  | ||||||
| @@ -324,17 +326,21 @@ boot_only=false | |||||||
| basestrap_args=(-GMc) | basestrap_args=(-GMc) | ||||||
| cmd=${0##*/} | cmd=${0##*/} | ||||||
|  |  | ||||||
| repo=${cmd#buildiso-} | repo=${REPO} | ||||||
| owner=${SUDO_USER:-$USER} | owner=${SUDO_USER:-$USER} | ||||||
| profile='base' | profile='base' | ||||||
| chroots_iso="${CHROOTS_DIR}/buildiso" | chroots_iso="${CHROOTS_DIR}/buildiso" | ||||||
| arch=$(uname -m) | arch=${ARCH} | ||||||
|  |  | ||||||
| usage() { | usage() { | ||||||
|     printf 'Usage: %s [options]\n' "${cmd}" |     printf 'Usage: %s [options]\n' "${cmd}" | ||||||
|     printf '    -p <profile>       Profile [default: %s]\n' "${profile}" |     printf '    -p <profile>       Profile [default: %s]\n' "${profile}" | ||||||
|     printf '    -r <dir>           Chroots directory\n' |     printf '    -r <dir>           Chroots directory\n' | ||||||
|     printf '                       [default: %s]\n' "${chroots_iso}" |     printf '                       [default: %s]\n' "${chroots_iso}" | ||||||
|  |     printf '    -R <repo>          Build repo\n' | ||||||
|  |     printf '                       [default: %s]\n' "${repo}" | ||||||
|  |     printf '    -a <arch>          Build arch\n' | ||||||
|  |     printf '                       [default: %s]\n' "${arch}" | ||||||
|     printf '    -t <dir>           Target directory\n' |     printf '    -t <dir>           Target directory\n' | ||||||
|     printf '                       [default: %s]\n' "${ISO_POOL}" |     printf '                       [default: %s]\n' "${ISO_POOL}" | ||||||
|     printf '    -i <name>          Init system to use\n' |     printf '    -i <name>          Init system to use\n' | ||||||
| @@ -358,11 +364,13 @@ usage() { | |||||||
|  |  | ||||||
| orig_args=("$@") | orig_args=("$@") | ||||||
|  |  | ||||||
| opts='p:r:t:i:g:czsbxmdqh' | opts='p:r:R:t:i:g:a:czsbxmdqh' | ||||||
|  |  | ||||||
| while getopts "${opts}" arg; do | while getopts "${opts}" arg; do | ||||||
|     case "${arg}" in |     case "${arg}" in | ||||||
|         p) profile="$OPTARG" ;; |         p) profile="$OPTARG" ;; | ||||||
|  |         a) arch="$OPTARG" ;; | ||||||
|  |         R) repo="$OPTARG" ;; | ||||||
|         r) chroots_iso="$OPTARG" ;; |         r) chroots_iso="$OPTARG" ;; | ||||||
|         t) ISO_POOL="$OPTARG" ;; |         t) ISO_POOL="$OPTARG" ;; | ||||||
|         i) INITSYS="$OPTARG" ;; |         i) INITSYS="$OPTARG" ;; | ||||||
|   | |||||||
| @@ -32,6 +32,10 @@ load_base_config(){ | |||||||
|  |  | ||||||
|     WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"} |     WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"} | ||||||
|  |  | ||||||
|  |     ARCH=${ARCH:-"$(uname -m)"} | ||||||
|  |  | ||||||
|  |     REPO=${REPO:-'world'} | ||||||
|  |  | ||||||
|     return 0 |     return 0 | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -277,7 +277,8 @@ show_db() { | |||||||
|     if ! yq -r ${REPO_DB} 1>/dev/null 2>/dev/null; then |     if ! yq -r ${REPO_DB} 1>/dev/null 2>/dev/null; then | ||||||
|         die "${REPO_DB} invalid!" |         die "${REPO_DB} invalid!" | ||||||
|     fi |     fi | ||||||
|     yq -rP '. | .repos |= with_entries(select(.value.version))' "${REPO_DB}" |     yq -rP '. | with_entries(select(.value.name))' "${REPO_DB}" | ||||||
|  |     yq -rP '. | .repos | with_entries(select(.value.version))' "${REPO_DB}" | ||||||
|     return 0 |     return 0 | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -41,12 +41,12 @@ artixpkg_repo_import_usage() { | |||||||
|     Usage: ${COMMAND} [OPTIONS] [PKGBASE]... |     Usage: ${COMMAND} [OPTIONS] [PKGBASE]... | ||||||
|  |  | ||||||
|     OPTIONS |     OPTIONS | ||||||
|         --switch TAG       Switch the current workspace to a specified version tag |         --tag TAG       Switch the current workspace to a specified version tag | ||||||
|         -h, --help         Show this help text |         -h, --help         Show this help text | ||||||
|  |  | ||||||
|     EXAMPLES |     EXAMPLES | ||||||
|         $ ${COMMAND} libfoo |         $ ${COMMAND} libfoo | ||||||
|         $ ${COMMAND} libfoo --switch TAG |         $ ${COMMAND} libfoo --tag TAG | ||||||
| _EOF_ | _EOF_ | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -61,12 +61,22 @@ artixpkg_repo_import() { | |||||||
|     local pkgbase |     local pkgbase | ||||||
|     local TAG |     local TAG | ||||||
|     local rsync_args=() |     local rsync_args=() | ||||||
|     rsync_args+=(-aWxvci --progress --delete-before --no-R --no-implied-dirs) |     rsync_args+=( | ||||||
|     rsync_args+=(--exclude '.git' --exclude '.gitignore' --exclude 'README.md' --exclude '.artixlinux') |         -axcihW | ||||||
|  |         --no-R | ||||||
|  |         --no-implied-dirs | ||||||
|  |         --exclude '.artixlinux' | ||||||
|  |         --exclude '.git' | ||||||
|  |         --exclude '.gitignore' | ||||||
|  |         --exclude 'README.md' | ||||||
|  |         --exclude '*.service' | ||||||
|  |         --exclude '*.timer' | ||||||
|  |         --exclude '*.socket' | ||||||
|  |     ) | ||||||
|  |  | ||||||
|     while (( $# )); do |     while (( $# )); do | ||||||
|         case $1 in |         case $1 in | ||||||
|         --switch=*) |         --tag=*) | ||||||
|             TAG="${1#*=}" |             TAG="${1#*=}" | ||||||
|             shift |             shift | ||||||
|         ;; |         ;; | ||||||
| @@ -122,11 +132,11 @@ artixpkg_repo_import() { | |||||||
|                 git checkout master &>/dev/null |                 git checkout master &>/dev/null | ||||||
|                 git branch -D "${version}" &>/dev/null |                 git branch -D "${version}" &>/dev/null | ||||||
|  |  | ||||||
|                 rsync "${rsync_args[@]}" "${temp}"/ "$(pwd)"/ &>/dev/null |                 stat_done | ||||||
|  |  | ||||||
|  |                 rsync "${rsync_args[@]}" "${temp}"/ "$(pwd)"/ #&>/dev/null | ||||||
|  |  | ||||||
|                 patch_pkgbase "${pkgbase}" |                 patch_pkgbase "${pkgbase}" | ||||||
|  |  | ||||||
|                 stat_done |  | ||||||
|             ) |             ) | ||||||
|         fi |         fi | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,26 +16,27 @@ source "${LIBDIR}"/base/chroot.sh | |||||||
| create_first=false | create_first=false | ||||||
| rebuild=false | rebuild=false | ||||||
|  |  | ||||||
| mkchrootpkg_args=(-c -n) | mkchrootpkg_args=(-c) | ||||||
|  |  | ||||||
| base_packages=('base-devel') | base_packages=('base-devel') | ||||||
| chroots_pkg="${CHROOTS_DIR}/buildpkg" | chroots_pkg="${CHROOTS_DIR}/buildpkg" | ||||||
|  |  | ||||||
| cmd=${0##*/} | arch=${ARCH} | ||||||
|  | repo=${REPO} | ||||||
| tag=${cmd#buildpkg-} |  | ||||||
| arch=${tag##*-} |  | ||||||
| repo=${tag%-*} |  | ||||||
|  |  | ||||||
| usage() { | usage() { | ||||||
|     printf 'Usage: %s [options] -- [mkchrootpkg_args]\n' "${0##*/}" |     printf 'Usage: %s [options] -- [mkchrootpkg_args]\n' "${0##*/}" | ||||||
|     printf '    -r <dir>           Create chroots in this directory\n' |     printf '    -r <dir>           Create chroots in this directory\n' | ||||||
|     printf '    -d <dir>           Destination repo chroot\n' |     printf '                       [default: %s]\n' "${chroots_pkg}" | ||||||
|  |     printf '    -d <dest>          Destination repo chroot\n' | ||||||
|  |     printf '                       [default: %s]\n' "${repo}" | ||||||
|     printf '    -a <arch>          Build arch chroot\n' |     printf '    -a <arch>          Build arch chroot\n' | ||||||
|  |     printf '                       [default: %s]\n' "${arch}" | ||||||
|     printf '    -c                 Recreate the chroot before building\n' |     printf '    -c                 Recreate the chroot before building\n' | ||||||
|     printf '    -m                 Major rebuild\n' |     printf '    -m                 Major rebuild\n' | ||||||
|     printf '    -N                 Disable check() function\n' |     printf '    -N                 Disable check() function\n' | ||||||
|     printf '    -C                 Run checkpkg after built\n' |     printf '    -C                 Run checkpkg after build\n' | ||||||
|  |     printf '    -n                 Run namcap after build\n' | ||||||
|     printf '    -h                 This help\n' |     printf '    -h                 This help\n' | ||||||
|     printf '\n' |     printf '\n' | ||||||
|     printf 'Default mkchrootpkg_args args: %s\n' "${mkchrootpkg_args[*]}" |     printf 'Default mkchrootpkg_args args: %s\n' "${mkchrootpkg_args[*]}" | ||||||
| @@ -43,7 +44,7 @@ usage() { | |||||||
|     exit "$1" |     exit "$1" | ||||||
| } | } | ||||||
|  |  | ||||||
| opts='hcCNmr:d:a:' | opts='hcCNmnr:d:a:' | ||||||
|  |  | ||||||
| while getopts "${opts}" arg; do | while getopts "${opts}" arg; do | ||||||
|     case "${arg}" in |     case "${arg}" in | ||||||
| @@ -54,6 +55,7 @@ while getopts "${opts}" arg; do | |||||||
|         m) rebuild=true; repo=${repo%-*} ;; |         m) rebuild=true; repo=${repo%-*} ;; | ||||||
|         C) mkchrootpkg_args+=(-C) ;; |         C) mkchrootpkg_args+=(-C) ;; | ||||||
|         N) mkchrootpkg_args+=(-N) ;; |         N) mkchrootpkg_args+=(-N) ;; | ||||||
|  |         n) mkchrootpkg_args+=(-n) ;; | ||||||
|         h|?) usage 0 ;; |         h|?) usage 0 ;; | ||||||
|     esac |     esac | ||||||
| done | done | ||||||
| @@ -62,15 +64,9 @@ if [[ "${repo}" == lib32* ]]; then | |||||||
|     base_packages+=('multilib-devel') |     base_packages+=('multilib-devel') | ||||||
| fi | fi | ||||||
|  |  | ||||||
| pacman_conf="${DATADIR}/pacman.conf.d/${repo}.conf" | pacman_conf="${DATADIR}/pacman.conf.d/${repo}-${arch}.conf" | ||||||
| if [[ -f ${USER_CONF_DIR}/pacman.conf.d/${repo}.conf ]]; then | if [[ -f ${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf ]]; then | ||||||
|     pacman_conf="${USER_CONF_DIR}/pacman.conf.d/${repo}.conf" |     pacman_conf="${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf" | ||||||
| fi |  | ||||||
| if [[ -f ${DATADIR}/pacman.conf.d/${repo}-${arch}.conf ]]; then |  | ||||||
|     pacman_conf="${DATADIR}/pacman.conf.d/${repo}-${arch}.conf" |  | ||||||
|     if [[ -f ${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf ]]; then |  | ||||||
|         pacman_conf="${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf" |  | ||||||
|     fi |  | ||||||
| fi | fi | ||||||
|  |  | ||||||
| makepkg_conf="${DATADIR}/makepkg.conf.d/${arch}.conf" | makepkg_conf="${DATADIR}/makepkg.conf.d/${arch}.conf" | ||||||
|   | |||||||
							
								
								
									
										123
									
								
								src/pkg/ckchrootpkg.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								src/pkg/ckchrootpkg.in
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,123 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | # | ||||||
|  | # SPDX-License-Identifier: GPL-3.0-or-later | ||||||
|  |  | ||||||
|  | LIBDIR=${LIBDIR:-'@libdir@'} | ||||||
|  |  | ||||||
|  | # shellcheck source=src/lib/base/util.sh | ||||||
|  | source "${LIBDIR}"/base/util.sh | ||||||
|  | # shellcheck source=src/lib/base/message.sh | ||||||
|  | source "${LIBDIR}"/base/message.sh | ||||||
|  | # shellcheck source=src/lib/base/chroot.sh | ||||||
|  | source "${LIBDIR}"/base/chroot.sh | ||||||
|  |  | ||||||
|  | shopt -s nullglob | ||||||
|  |  | ||||||
|  | chrootdir= | ||||||
|  | makepkg_user= | ||||||
|  | passeddir="${CHROOTS_DIR}/buildpkg" | ||||||
|  |  | ||||||
|  | arch=${ARCH} | ||||||
|  | repo=${REPO} | ||||||
|  |  | ||||||
|  | copy=$USER | ||||||
|  | [[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER | ||||||
|  | [[ -z "$copy" || $copy = root ]] && copy=copy | ||||||
|  |  | ||||||
|  | usage() { | ||||||
|  |     printf 'Usage: %s [options] -r <chrootdir>\n' "${0##*/}" | ||||||
|  |     printf '    -r <dir>           Create chroots in this directory\n' | ||||||
|  |     printf '                       Default: %s\n' "${passeddir}" | ||||||
|  |     printf '    -d <dest>          Destination repo chroot\n' | ||||||
|  |     printf '                       Default: %s\n' "${repo}" | ||||||
|  |     printf '    -a <arch>          Build arch chroot\n' | ||||||
|  |     printf '                       Default: %s\n' "${arch}" | ||||||
|  |     printf '    -l <copy>          The directory to use as the working copy of the chroot\n' | ||||||
|  |     printf '                       Useful for maintaining multiple copies\n' | ||||||
|  |     printf '                       Default: %s\n' "$copy" | ||||||
|  |     printf '    -U                 Run makepkg as a specified user\n' | ||||||
|  |     exit 1 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | opts='hr:l:U:d:a:' | ||||||
|  |  | ||||||
|  | while getopts "${opts}" arg; do | ||||||
|  |     case "$arg" in | ||||||
|  |         r) passeddir="$OPTARG" ;; | ||||||
|  |         l) copy="$OPTARG" ;; | ||||||
|  |         U) makepkg_user="$OPTARG" ;; | ||||||
|  |         d) repo="$OPTARG" ;; | ||||||
|  |         a) arch="$OPTARG" ;; | ||||||
|  |         h|*) usage ;; | ||||||
|  |     esac | ||||||
|  | done | ||||||
|  |  | ||||||
|  | [[ ! -f PKGBUILD ]] && die 'This must be run in a directory containing a PKGBUILD.' | ||||||
|  | [[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.' | ||||||
|  | makepkg_user=${makepkg_user:-${SUDO_USER:-$USER}} | ||||||
|  |  | ||||||
|  | check_root "" "${BASH_SOURCE[0]}" "$@" | ||||||
|  |  | ||||||
|  | # # Canonicalize chrootdir, getting rid of trailing / | ||||||
|  | chrootdir=$(readlink -e "$passeddir") | ||||||
|  |  | ||||||
|  | chrootdir="$chrootdir"/"${repo}-${arch}" | ||||||
|  |  | ||||||
|  | [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" | ||||||
|  | [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkchroot %s/root base-devel" "$chrootdir" | ||||||
|  |  | ||||||
|  | if [[ ${copy:0:1} = / ]]; then | ||||||
|  |     copydir=$copy | ||||||
|  | else | ||||||
|  |     copydir="$chrootdir/$copy" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | umask 0022 | ||||||
|  |  | ||||||
|  | ORIG_HOME=$HOME | ||||||
|  | IFS=: read -r _ _ _ _ _ HOME _ < <(getent passwd "${SUDO_USER:-$USER}") | ||||||
|  | load_makepkg_config | ||||||
|  | HOME=$ORIG_HOME | ||||||
|  |  | ||||||
|  | msg "Running checkpkg" | ||||||
|  |  | ||||||
|  | if chroot-run \ | ||||||
|  |     -b "-B:${PWD}:/startdir -B:${SRCDEST}:/srcdest" \ | ||||||
|  |     "$copydir" true | ||||||
|  | then | ||||||
|  |     mapfile -t pkgnames < <(sudo -u "$makepkg_user" bash -c 'source PKGBUILD; printf "%s\n" "${pkgname[@]}"') | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | mapfile -t remotepkgs < <(pacman --config "$copydir"/etc/pacman.conf \ | ||||||
|  |     --dbpath "$copydir"/var/lib/pacman \ | ||||||
|  |     -Sddp "${pkgnames[@]}") | ||||||
|  |  | ||||||
|  | if ! wait $!; then | ||||||
|  |     warning "Skipped checkpkg due to missing repo packages" | ||||||
|  |     exit 0 | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | # download package files if any non-local location exists | ||||||
|  | for remotepkg in "${remotepkgs[@]}"; do | ||||||
|  |     if [[ $remotepkg != file://* ]]; then | ||||||
|  |         msg2 "Downloading current versions" | ||||||
|  |         chroot-run "$copydir" pacman --noconfirm -Swdd "${pkgnames[@]}" | ||||||
|  |         mapfile -t remotepkgs < <(pacman --config "$copydir"/etc/pacman.conf \ | ||||||
|  |             --dbpath "$copydir"/var/lib/pacman \ | ||||||
|  |             -Sddp "${pkgnames[@]}") | ||||||
|  |         break | ||||||
|  |     fi | ||||||
|  | done | ||||||
|  |  | ||||||
|  | pkgfiles="${remotepkgs[@]/#file:\/\//}" | ||||||
|  |  | ||||||
|  | sudo -u "$makepkg_user" checkpkg --rmdir --warn --makepkg-config "$copydir/etc/makepkg.conf" "${pkgfiles[@]}" | ||||||
|  |  | ||||||
|  | msg "Running namcap" | ||||||
|  | #msg2 "Checking %s\n" "PKGBUILD" | ||||||
|  | sudo -u "$makepkg_user" namcap PKGBUILD 2>&1 | tee "PKGBUILD-namcap.log" | ||||||
|  |  | ||||||
|  | for pkgfile in "${pkgfiles[@]}"; do | ||||||
|  |     #msg2 "Checking %s\n" "${pkgfile##*/}" | ||||||
|  |     sudo -u "$makepkg_user" namcap "$pkgfile" 2>&1 | tee "${pkgfile##*/}-namcap.log" | ||||||
|  | done | ||||||
| @@ -205,6 +205,8 @@ _chrootbuild() { | |||||||
|     # No coredumps |     # No coredumps | ||||||
|     ulimit -c 0 |     ulimit -c 0 | ||||||
|  |  | ||||||
|  |     . /etc/locale.conf | ||||||
|  |  | ||||||
|     # shellcheck source=/dev/null |     # shellcheck source=/dev/null | ||||||
|     . /etc/profile |     . /etc/profile | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user