mirror of
				https://gitlab.archlinux.org/archlinux/devtools.git
				synced 2025-11-04 09:44:42 +01:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					85705363cd | ||
| 
						 | 
					4a9ecdfe15 | ||
| 
						 | 
					33fda4e8ff | 
							
								
								
									
										117
									
								
								makechrootpkg.in
									
									
									
									
									
								
							
							
						
						
									
										117
									
								
								makechrootpkg.in
									
									
									
									
									
								
							@@ -66,60 +66,6 @@ usage() {
 | 
			
		||||
	exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
orig_argv=("$@")
 | 
			
		||||
 | 
			
		||||
while getopts 'hcur:I:l:nTD:d:' arg; do
 | 
			
		||||
	case "$arg" in
 | 
			
		||||
		c) clean_first=true ;;
 | 
			
		||||
		D) bindmounts_ro+=(--bind-ro="$OPTARG") ;;
 | 
			
		||||
		d) bindmounts_rw+=(--bind="$OPTARG") ;;
 | 
			
		||||
		u) update_first=true ;;
 | 
			
		||||
		r) passeddir="$OPTARG" ;;
 | 
			
		||||
		I) install_pkgs+=("$OPTARG") ;;
 | 
			
		||||
		l) copy="$OPTARG" ;;
 | 
			
		||||
		n) run_namcap=true; makepkg_args+=(-i) ;;
 | 
			
		||||
		T) temp_chroot=true; copy+="-$$" ;;
 | 
			
		||||
		h|*) usage ;;
 | 
			
		||||
	esac
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
 | 
			
		||||
 | 
			
		||||
check_root "$0" "${orig_argv[@]}"
 | 
			
		||||
 | 
			
		||||
# Canonicalize chrootdir, getting rid of trailing /
 | 
			
		||||
chrootdir=$(readlink -e "$passeddir")
 | 
			
		||||
[[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"
 | 
			
		||||
[[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir"
 | 
			
		||||
 | 
			
		||||
# Detect chrootdir filesystem type
 | 
			
		||||
chroottype=$(stat -f -c %T "$chrootdir")
 | 
			
		||||
 | 
			
		||||
if [[ ${copy:0:1} = / ]]; then
 | 
			
		||||
	copydir=$copy
 | 
			
		||||
else
 | 
			
		||||
	copydir="$chrootdir/$copy"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Pass all arguments after -- right to makepkg
 | 
			
		||||
makepkg_args+=("${@:$OPTIND}")
 | 
			
		||||
 | 
			
		||||
# See if -R was passed to makepkg
 | 
			
		||||
for arg in "${@:OPTIND}"; do
 | 
			
		||||
	case ${arg%%=*} in
 | 
			
		||||
		-*R*|--repackage)
 | 
			
		||||
			repack=true
 | 
			
		||||
			break 2
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
if [[ -n $SUDO_USER ]]; then
 | 
			
		||||
	eval "USER_HOME=~$SUDO_USER"
 | 
			
		||||
else
 | 
			
		||||
	USER_HOME=$HOME
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# {{{ functions
 | 
			
		||||
load_vars() {
 | 
			
		||||
	local makepkg_conf="$1" var
 | 
			
		||||
@@ -207,10 +153,11 @@ prepare_chroot() {
 | 
			
		||||
		echo 'BUILDDIR="/build"' >> "$copydir/etc/makepkg.conf"
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	# Read .makepkg.conf and .gnupg/pubring.gpg even if called via sudo
 | 
			
		||||
	if [[ -r "$USER_HOME/.gnupg/pubring.gpg" ]]; then
 | 
			
		||||
		install -D "$USER_HOME/.gnupg/pubring.gpg" \
 | 
			
		||||
			   "$copydir/build/.gnupg/pubring.gpg"
 | 
			
		||||
	# Read .makepkg.conf and gnupg pubring
 | 
			
		||||
	if [[ -r $USER_HOME/.gnupg/pubring.kbx ]]; then
 | 
			
		||||
		install -D "$USER_HOME/.gnupg/pubring.kbx" "$copydir/build/.gnupg/pubring.kbx"
 | 
			
		||||
	elif [[ -r $USER_HOME/.gnupg/pubring.gpg ]]; then
 | 
			
		||||
		install -D "$USER_HOME/.gnupg/pubring.gpg" "$copydir/build/.gnupg/pubring.gpg"
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	mkdir -p "$copydir/pkgdest"
 | 
			
		||||
@@ -363,6 +310,60 @@ move_products() {
 | 
			
		||||
}
 | 
			
		||||
# }}}
 | 
			
		||||
 | 
			
		||||
orig_argv=("$@")
 | 
			
		||||
 | 
			
		||||
while getopts 'hcur:I:l:nTD:d:' arg; do
 | 
			
		||||
	case "$arg" in
 | 
			
		||||
		c) clean_first=true ;;
 | 
			
		||||
		D) bindmounts_ro+=(--bind-ro="$OPTARG") ;;
 | 
			
		||||
		d) bindmounts_rw+=(--bind="$OPTARG") ;;
 | 
			
		||||
		u) update_first=true ;;
 | 
			
		||||
		r) passeddir="$OPTARG" ;;
 | 
			
		||||
		I) install_pkgs+=("$OPTARG") ;;
 | 
			
		||||
		l) copy="$OPTARG" ;;
 | 
			
		||||
		n) run_namcap=true; makepkg_args+=(-i) ;;
 | 
			
		||||
		T) temp_chroot=true; copy+="-$$" ;;
 | 
			
		||||
		h|*) usage ;;
 | 
			
		||||
	esac
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
 | 
			
		||||
 | 
			
		||||
check_root "$0" "${orig_argv[@]}"
 | 
			
		||||
 | 
			
		||||
# Canonicalize chrootdir, getting rid of trailing /
 | 
			
		||||
chrootdir=$(readlink -e "$passeddir")
 | 
			
		||||
[[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"
 | 
			
		||||
[[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir"
 | 
			
		||||
 | 
			
		||||
# Detect chrootdir filesystem type
 | 
			
		||||
chroottype=$(stat -f -c %T "$chrootdir")
 | 
			
		||||
 | 
			
		||||
if [[ ${copy:0:1} = / ]]; then
 | 
			
		||||
	copydir=$copy
 | 
			
		||||
else
 | 
			
		||||
	copydir="$chrootdir/$copy"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Pass all arguments after -- right to makepkg
 | 
			
		||||
makepkg_args+=("${@:$OPTIND}")
 | 
			
		||||
 | 
			
		||||
# See if -R was passed to makepkg
 | 
			
		||||
for arg in "${@:OPTIND}"; do
 | 
			
		||||
	case ${arg%%=*} in
 | 
			
		||||
		-*R*|--repackage)
 | 
			
		||||
			repack=true
 | 
			
		||||
			break 2
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
if [[ -n $SUDO_USER ]]; then
 | 
			
		||||
	eval "USER_HOME=~$SUDO_USER"
 | 
			
		||||
else
 | 
			
		||||
	USER_HOME=$HOME
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
umask 0022
 | 
			
		||||
 | 
			
		||||
load_vars "$USER_HOME/.makepkg.conf"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user