forked from mirrored-repos/manjaro-tools
Compare commits
21 commits
master
...
arch-patch
Author | SHA1 | Date | |
---|---|---|---|
|
551cea0835 | ||
|
f3bbc3b96f | ||
|
c6bd1d3a5e | ||
|
d2bb99ff1a | ||
|
6518825280 | ||
|
bf2ddc1e1d | ||
|
d455564eb6 | ||
|
a4fc8325df | ||
|
b121fe7490 | ||
|
518992d723 | ||
|
a1492e8d1e | ||
|
25ddeb1593 | ||
|
37b9feb061 | ||
|
93626731c7 | ||
|
9533b8ce93 | ||
|
ed95e249a2 | ||
|
8a5fc4e0b0 | ||
|
734ea24b57 | ||
|
d477c42ecb | ||
|
92aaea7694 | ||
|
187aac2a35 |
15 changed files with 410 additions and 341 deletions
|
@ -48,8 +48,7 @@ usage() {
|
|||
# exit $(( $# ? 0 : 1 ))
|
||||
# fi
|
||||
#
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts=':C:cdGiM'
|
||||
|
||||
|
@ -67,7 +66,7 @@ while getopts ${opts} arg; do
|
|||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
(( $# )) || die "No root directory specified"
|
||||
newroot=$1; shift
|
||||
|
@ -97,7 +96,7 @@ if ! pacman -r "$newroot" -Sy "${pacman_args[@]}"; then
|
|||
fi
|
||||
|
||||
# kill chroot process if needed (TODO: check if needed at all)
|
||||
kill_chroot_process "$newroot"
|
||||
# kill_chroot_process "$newroot"
|
||||
|
||||
if ${copykeyring};then
|
||||
copy_keyring "$newroot"
|
||||
|
|
|
@ -135,7 +135,7 @@ usage() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='p:a:b:r:t:k:i:g:czxmvqh'
|
||||
|
||||
|
@ -164,7 +164,7 @@ shift $(($OPTIND - 1))
|
|||
|
||||
timer_start=$(get_timer)
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
prepare_dir "${log_dir}"
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ usage() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='p:a:b:r:i:cwnsuqh'
|
||||
|
||||
|
@ -127,7 +127,7 @@ done
|
|||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
prepare_dir "${log_dir}"
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ usage() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='sacqh'
|
||||
|
||||
|
@ -72,7 +72,7 @@ done
|
|||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
prepare_dir "${tree_dir_abs}"
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ usage() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='p:a:i:k:gcvqh'
|
||||
|
||||
|
@ -133,7 +133,7 @@ done
|
|||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
prepare_dir "${tmp_dir}"
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ import ${LIBDIR}/util.sh
|
|||
import ${LIBDIR}/util-mount.sh
|
||||
|
||||
working_dir=''
|
||||
files=()
|
||||
keep_mirrors=false
|
||||
nosetarch=false
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] working-dir [run arguments]"
|
||||
|
@ -30,18 +32,20 @@ usage() {
|
|||
echo ' -M <file> Location of a makepkg config file'
|
||||
echo ' -S <file> Location of a pacman-mirrors config file'
|
||||
echo ' -c <dir> Set pacman cache'
|
||||
echo ' -f <file> Copy file from the host to the chroot'
|
||||
echo ' -s Do not run setarch'
|
||||
echo ' -r <list> Bind mountargs ro'
|
||||
echo ' -w <list> Bind mountargs rw'
|
||||
echo ' List format [src1:target1,...,srcN:targetN]'
|
||||
echo ' List format [src1:target1 ... srcN:targetN]'
|
||||
echo ' -B Use custom build mirror'
|
||||
echo ' -K Keep mirrorlist (-B)'
|
||||
echo ' -h This message'
|
||||
exit 1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='hKC:M:S:c:r:w:B:'
|
||||
opts='hKC:M:S:c:r:w:B:f:s'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
|
@ -49,8 +53,10 @@ while getopts ${opts} arg; do
|
|||
M) makepkg_conf="$OPTARG" ;;
|
||||
S) mirrors_conf="$OPTARG" ;;
|
||||
c) cache_dir="$OPTARG" ;;
|
||||
r) mountargs_ro="$OPTARG" ;;
|
||||
w) mountargs_rw="$OPTARG" ;;
|
||||
f) files+=("$OPTARG") ;;
|
||||
s) nosetarch=true ;;
|
||||
r) bindmounts_ro=("$OPTARG") ;;
|
||||
w) bindmounts_rw=("$OPTARG") ;;
|
||||
B) build_mirror="$OPTARG" ;;
|
||||
K) keep_mirrors=true ;;
|
||||
h|?) usage ;;
|
||||
|
@ -60,7 +66,8 @@ done
|
|||
shift $(($OPTIND - 1))
|
||||
|
||||
(( $# < 1 )) && die 'You must specify a directory.'
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
|
||||
check_root
|
||||
|
||||
working_dir=$(readlink -f "$1")
|
||||
shift 1
|
||||
|
@ -81,6 +88,12 @@ copy_hostconf () {
|
|||
[[ -n $makepkg_conf ]] && cp $makepkg_conf "$1/etc/makepkg.conf"
|
||||
[[ -n $mirrors_conf ]] && cp ${mirrors_conf} "$1/etc/pacman-mirrors.conf"
|
||||
|
||||
local file
|
||||
for file in "${files[@]}"; do
|
||||
mkdir -p "$(dirname "$working_dir$file")"
|
||||
cp -T "$file" "$working_dir$file"
|
||||
done
|
||||
|
||||
if [[ -n ${build_mirror} ]];then
|
||||
build_mirror=${build_mirror}'/$repo/$arch'
|
||||
if ${keep_mirrors}; then
|
||||
|
@ -95,7 +108,7 @@ copy_hostconf () {
|
|||
sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$1/etc/pacman.conf"
|
||||
}
|
||||
|
||||
chroot_extra_umount() {
|
||||
chroot_extra_mount() {
|
||||
chroot_mount "/etc/resolv.conf" "$1/etc/resolv.conf" -B
|
||||
chroot_mount "${cache_dirs[0]}" "$1${cache_dirs[0]}" -B
|
||||
|
||||
|
@ -103,21 +116,13 @@ chroot_extra_umount() {
|
|||
chroot_mount "$cache_dir" "$1${cache_dir}" -Br
|
||||
done
|
||||
|
||||
if [[ -n ${mountargs_ro[@]} ]];then
|
||||
local IFS=','
|
||||
for m in ${mountargs_ro[@]}; do
|
||||
chroot_mount "${m%%:*}" "$1${m##*:}" -Br
|
||||
done
|
||||
unset IFS
|
||||
fi
|
||||
for m in ${bindmounts_ro[@]}; do
|
||||
chroot_mount "${m%%:*}" "$1${m##*:}" -Br
|
||||
done
|
||||
|
||||
if [[ -n ${mountargs_rw[@]} ]];then
|
||||
local IFS=','
|
||||
for m in ${mountargs_rw[@]}; do
|
||||
chroot_mount "${m%%:*}" "$1${m##*:}" -B
|
||||
done
|
||||
unset IFS
|
||||
fi
|
||||
for m in ${bindmounts_rw[@]}; do
|
||||
chroot_mount "${m%%:*}" "$1${m##*:}" -B
|
||||
done
|
||||
}
|
||||
|
||||
umask 0022
|
||||
|
@ -131,12 +136,14 @@ fi
|
|||
|
||||
chroot_api_mount "${working_dir}" || die "failed to setup API filesystems in chroot %s" "${working_dir}"
|
||||
|
||||
chroot_extra_umount "${working_dir}"
|
||||
chroot_extra_mount "${working_dir}"
|
||||
|
||||
copy_hostconf "${working_dir}"
|
||||
|
||||
eval $(grep '^CARCH=' "$working_dir/etc/makepkg.conf")
|
||||
|
||||
${nosetarch} && unset CARCH
|
||||
|
||||
${CARCH:+setarch "$CARCH"} chroot "${working_dir}" "$@"
|
||||
|
||||
kill_chroot_process "${working_dir}"
|
||||
# kill_chroot_process "${working_dir}"
|
||||
|
|
|
@ -55,7 +55,7 @@ usage() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts=':haq'
|
||||
|
||||
|
@ -69,7 +69,7 @@ while getopts ${opts} arg; do
|
|||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
if ${automount};then
|
||||
chrootdir=/mnt
|
||||
|
|
|
@ -18,9 +18,12 @@ LIBDIR='@libdir@'
|
|||
import ${LIBDIR}/util.sh
|
||||
|
||||
working_dir=''
|
||||
files=()
|
||||
|
||||
build_locales=false
|
||||
keep_mirrors=false
|
||||
keep_flag=''
|
||||
nosetarch=false
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] working-dir package-list..."
|
||||
|
@ -29,6 +32,8 @@ usage() {
|
|||
echo ' -M <file> Location of a makepkg config file'
|
||||
echo ' -S <file> Location of a pacman-mirrors config file'
|
||||
echo ' -c <dir> Set pacman cache'
|
||||
echo ' -f <file> Copy file from the host to the chroot'
|
||||
echo ' -s Do not run setarch'
|
||||
echo ' -L Use build locale.gen en/de'
|
||||
echo ' -B Use custom build mirror'
|
||||
echo ' -K Keep mirrorlist (-B)'
|
||||
|
@ -37,9 +42,9 @@ usage() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='hLKC:M:S:c:B:'
|
||||
opts='hLKC:M:S:c:B:f:s'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
|
@ -47,18 +52,20 @@ while getopts ${opts} arg; do
|
|||
M) makepkg_conf="$OPTARG" ;;
|
||||
S) mirrors_conf="$OPTARG" ;;
|
||||
c) cache_dir="$OPTARG" ;;
|
||||
f) files+=("$OPTARG") ;;
|
||||
s) nosetarch=true ;;
|
||||
L) build_locales=true ;;
|
||||
B) build_mirror="$OPTARG" ;;
|
||||
K) keep_mirrors=true; keep_flag='-K' ;;
|
||||
h|?) usage ;;
|
||||
*) error "invalid argument '$arg'"; usage ;;
|
||||
*) error "invalid argument '%s'" "$arg"; usage ;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
(( $# < 2 )) && die 'You must specify a directory and one or more packages.'
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
working_dir="$(readlink -f $1)"
|
||||
shift 1
|
||||
|
@ -89,6 +96,11 @@ if is_btrfs "$working_dir"; then
|
|||
chmod 0755 "$working_dir"
|
||||
fi
|
||||
|
||||
for file in "${files[@]}"; do
|
||||
mkdir -p "$(dirname "$working_dir$file")"
|
||||
cp "$file" "$working_dir$file"
|
||||
done
|
||||
|
||||
# Workaround when creating a chroot in a branch different of the host
|
||||
if [[ -n $pac_conf ]] && [[ -n $mirrors_conf ]] && [[ -n ${build_mirror} ]]; then
|
||||
url=${build_mirror}'/$repo/$arch'
|
||||
|
@ -96,11 +108,21 @@ if [[ -n $pac_conf ]] && [[ -n $mirrors_conf ]] && [[ -n ${build_mirror} ]]; the
|
|||
pac_base="$working_dir/pacman-basestrap.conf"
|
||||
sed "s#Include = /etc/pacman.d/mirrorlist#Server = ${url}#g" $pac_conf > $pac_base
|
||||
|
||||
_env=()
|
||||
while read -r varname; do
|
||||
_env+=("$varname=${!varname}")
|
||||
done < <(declare -x | sed -r 's/^declare -x ([^=]*)=.*/\1/' | grep -i '_proxy$')
|
||||
env -i "${_env[@]}" \
|
||||
basestrap -GMcd ${pac_base:+-C "$pac_base"} "$working_dir" \
|
||||
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
|
||||
|
||||
[[ -f "$pac_base" ]] && rm "$pac_base"
|
||||
else
|
||||
_env=()
|
||||
while read -r varname; do
|
||||
_env+=("$varname=${!varname}")
|
||||
done < <(declare -x | sed -r 's/^declare -x ([^=]*)=.*/\1/' | grep -i '_proxy$')
|
||||
env -i "${_env[@]}" \
|
||||
basestrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \
|
||||
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
|
||||
fi
|
||||
|
@ -117,6 +139,7 @@ if ${build_locales};then
|
|||
fi
|
||||
|
||||
chroot_args=(${pac_conf:+-C "$pac_conf"} ${makepkg_conf:+-M "$makepkg_conf"} ${mirrors_conf:+-S "$mirrors_conf"} ${build_mirror:+-B "$build_mirror"} ${cache_dir:+-c "$cache_dir"} ${keep_flag})
|
||||
${nosetarch} && chroot_args+=(${nosetarch:+-s})
|
||||
|
||||
exec chroot-run \
|
||||
${chroot_args[*]} \
|
||||
|
|
|
@ -19,138 +19,115 @@ import ${LIBDIR}/util.sh
|
|||
|
||||
shopt -s nullglob
|
||||
|
||||
makepkg_args=(-s --noconfirm -L)
|
||||
repack=false
|
||||
update_first=false
|
||||
clean_first=false
|
||||
install_pkg=
|
||||
run_namcap=false
|
||||
temp_chroot=false
|
||||
chrootdir=
|
||||
passeddir=
|
||||
declare -a install_pkgs
|
||||
declare -i ret=0
|
||||
init_variables() {
|
||||
default_makepkg_args=(-s --noconfirm -L --holdver)
|
||||
makepkg_args=("${default_makepkg_args[@]}")
|
||||
repack=false
|
||||
update_first=false
|
||||
clean_first=false
|
||||
run_namcap=false
|
||||
temp_chroot=false
|
||||
chrootdir=
|
||||
passeddir=
|
||||
makepkg_user=
|
||||
declare -ga install_pkgs
|
||||
declare -gi ret=0
|
||||
|
||||
copy=$USER
|
||||
[[ -n $SUDO_USER ]] && copy=$SUDO_USER
|
||||
[[ -z "$copy" || $copy = root ]] && copy=copy
|
||||
src_owner=${SUDO_USER:-$USER}
|
||||
bindmounts_ro=()
|
||||
bindmounts_rw=()
|
||||
|
||||
copy=$USER
|
||||
[[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER
|
||||
[[ -z "$copy" || $copy = root ]] && copy=copy
|
||||
src_owner=${SUDO_USER:-$USER}
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]"
|
||||
echo ' Run this script in a PKGBUILD dir to build a package inside a'
|
||||
echo ' clean chroot. Arguments passed to this script after the'
|
||||
echo ' end-of-options marker (--) will be passed to makepkg.'
|
||||
echo ' Run this script in a PKGBUILD dir to build a package inside a'
|
||||
echo ' clean chroot. Arguments passed to this script after the'
|
||||
echo ' end-of-options marker (--) will be passed to makepkg.'
|
||||
echo ''
|
||||
echo ' The chroot dir consists of the following directories:'
|
||||
echo ' <chrootdir>/{root, copy} but only "root" is required'
|
||||
echo ' by default. The working copy will be created as needed'
|
||||
echo ' The chroot dir consists of the following directories:'
|
||||
echo ' <chrootdir>/{root, copy} but only "root" is required'
|
||||
echo ' by default. The working copy will be created as needed'
|
||||
echo ''
|
||||
echo ' The chroot "root" directory must be created via the following'
|
||||
echo ' command:'
|
||||
echo ' mkchroot <chrootdir>/root base-devel'
|
||||
echo 'The chroot "root" directory must be created via the following'
|
||||
echo 'command:'
|
||||
echo ' mkarchroot <chrootdir>/root base-devel'
|
||||
echo ''
|
||||
echo " Default makepkg args: ${makepkg_args[*]}"
|
||||
echo 'This script reads {SRC,SRCPKG,PKG,LOG}DEST, MAKEFLAGS and PACKAGER'
|
||||
echo 'from makepkg.conf(5), if those variables are not part of the'
|
||||
echo 'environment.'
|
||||
echo ''
|
||||
echo ' Flags:'
|
||||
echo ' -h This help'
|
||||
echo ' -c Clean the chroot before building'
|
||||
echo ' -u Update the working copy of the chroot before building'
|
||||
echo ' This is useful for rebuilds without dirtying the pristine'
|
||||
echo ' chroot'
|
||||
echo ' -r <dir> The chroot dir to use'
|
||||
echo ' -I <pkg> Install a package into the working copy of the chroot'
|
||||
echo ' -l <copy> The directory to use as the working copy of the chroot'
|
||||
echo ' Useful for maintaining multiple copies'
|
||||
echo " Default: $copy"
|
||||
echo ' -n Run namcap on the package'
|
||||
echo ' -T Build in a temporary directory'
|
||||
echo "Default makepkg args: ${default_makepkg_args[*]}"
|
||||
echo ''
|
||||
echo 'Flags:'
|
||||
echo '-h This help'
|
||||
echo '-c Clean the chroot before building'
|
||||
echo '-d <dir> Bind directory into build chroot as read-write'
|
||||
echo '-D <dir> Bind directory into build chroot as read-only'
|
||||
echo '-u Update the working copy of the chroot before building'
|
||||
echo ' This is useful for rebuilds without dirtying the pristine'
|
||||
echo ' chroot'
|
||||
echo '-r <dir> The chroot dir to use'
|
||||
echo '-I <pkg> Install a package into the working copy of the chroot'
|
||||
echo '-l <copy> The directory to use as the working copy of the chroot'
|
||||
echo ' Useful for maintaining multiple copies'
|
||||
echo " Default: $copy"
|
||||
echo '-n Run namcap on the package'
|
||||
echo '-T Build in a temporary directory'
|
||||
echo '-U Run makepkg as a specified user'
|
||||
exit 1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
|
||||
while getopts 'hcur:I:l:nT' arg; do
|
||||
case "$arg" in
|
||||
c) clean_first=true ;;
|
||||
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: mkchroot %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
|
||||
|
||||
load_user_info
|
||||
|
||||
# {{{ functions
|
||||
|
||||
create_chroot() {
|
||||
# Lock the chroot we want to use. We'll keep this lock until we exit.
|
||||
lock 9 "$copydir.lock" "Locking chroot copy [$copy]"
|
||||
|
||||
if [[ ! -d $copydir ]] || $clean_first; then
|
||||
# Get a read lock on the root chroot to make
|
||||
# sure we don't clone a half-updated chroot
|
||||
slock 8 "$chrootdir/root.lock" "Locking clean chroot"
|
||||
|
||||
stat_busy "Creating clean working copy [$copy]"
|
||||
if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
|
||||
subvolume_delete_recursive "$copydir" ||
|
||||
die "Unable to delete subvolume %s" "$copydir"
|
||||
btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null ||
|
||||
die "Unable to create subvolume %s" "$copydir"
|
||||
else
|
||||
mkdir -p "$copydir"
|
||||
rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir"
|
||||
fi
|
||||
stat_done
|
||||
|
||||
# Drop the read lock again
|
||||
exec 8>&-
|
||||
sync_chroot() {
|
||||
local chrootdir=$1
|
||||
local copy=$2
|
||||
local copydir=''
|
||||
if [[ ${copy:0:1} = / ]]; then
|
||||
copydir=$copy
|
||||
else
|
||||
copydir="$chrootdir/$copy"
|
||||
fi
|
||||
|
||||
if [[ "$chrootdir/root" -ef "$copydir" ]]; then
|
||||
error 'Cannot sync copy with itself: %s' "$copydir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Get a read lock on the root chroot to make
|
||||
# sure we don't clone a half-updated chroot
|
||||
slock 8 "$chrootdir/root.lock" \
|
||||
"Locking clean chroot [%s]" "$chrootdir/root"
|
||||
|
||||
stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copydir"
|
||||
if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
|
||||
subvolume_delete_recursive "$copydir" ||
|
||||
die "Unable to delete subvolume %s" "$copydir"
|
||||
btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null ||
|
||||
die "Unable to create subvolume %s" "$copydir"
|
||||
else
|
||||
mkdir -p "$copydir"
|
||||
rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir"
|
||||
fi
|
||||
stat_done
|
||||
|
||||
# Drop the read lock again
|
||||
lock_close 8
|
||||
|
||||
# Update mtime
|
||||
touch "$copydir"
|
||||
}
|
||||
|
||||
clean_temporary() {
|
||||
stat_busy "Removing temporary copy [$copy]"
|
||||
# Usage: delete_chroot $copydir [$copy]
|
||||
delete_chroot() {
|
||||
local copydir=$1
|
||||
local copy=${1:-$2}
|
||||
|
||||
stat_busy "Removing chroot copy [%s]" "$copy"
|
||||
if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
|
||||
btrfs subvolume delete "$copydir" >/dev/null ||
|
||||
subvolume_delete_recursive "$copydir" ||
|
||||
die "Unable to delete subvolume %s" "$copydir"
|
||||
else
|
||||
# avoid change of filesystem in case of an umount failure
|
||||
|
@ -163,24 +140,35 @@ clean_temporary() {
|
|||
stat_done
|
||||
}
|
||||
|
||||
# Usage: install_packages $copydir $pkgs...
|
||||
install_packages() {
|
||||
local copydir=$1
|
||||
local install_pkgs=("${@:2}")
|
||||
|
||||
local -a pkgnames
|
||||
local ret
|
||||
|
||||
pkgnames=("${install_pkgs[@]##*/}")
|
||||
|
||||
cp -- "${install_pkgs[@]}" "$copydir/root/"
|
||||
|
||||
chroot-run "$copydir" \
|
||||
pacman -U --noconfirm -- "${pkgnames[@]/#//root/}"
|
||||
chroot-run -r "${bindmounts_ro[*]}" -w "${bindmounts_rw[*]}" "$copydir" \
|
||||
pacman -U --noconfirm -- "${pkgnames[@]/#//root/}"
|
||||
ret=$?
|
||||
rm -- "${pkgnames[@]/#/$copydir/root/}"
|
||||
|
||||
# If there is no PKGBUILD we are done
|
||||
[[ -f PKGBUILD ]] || exit $ret
|
||||
return $ret
|
||||
}
|
||||
|
||||
# Usage: prepare_chroot $copydir $HOME $repack $run_namcap
|
||||
# Globals:
|
||||
# - MAKEFLAGS
|
||||
# - PACKAGER
|
||||
prepare_chroot() {
|
||||
local copydir=$1
|
||||
local USER_HOME=$2
|
||||
local repack=$3
|
||||
local run_namcap=$4
|
||||
|
||||
$repack || rm -rf "$copydir/build"
|
||||
|
||||
local builduser_uid="${SUDO_UID:-$UID}"
|
||||
|
@ -204,7 +192,7 @@ prepare_chroot() {
|
|||
|
||||
sed -e '/^MAKEFLAGS=/d' -e '/^PACKAGER=/d' -i "$copydir/etc/makepkg.conf"
|
||||
for x in BUILDDIR=/build PKGDEST=/pkgdest SRCPKGDEST=/srcpkgdest SRCDEST=/srcdest LOGDEST=/logdest \
|
||||
"MAKEFLAGS='$MAKEFLAGS'" "PACKAGER='$PACKAGER'"
|
||||
"MAKEFLAGS='${MAKEFLAGS:-}'" "PACKAGER='${PACKAGER:-}'"
|
||||
do
|
||||
grep -q "^$x" "$copydir/etc/makepkg.conf" && continue
|
||||
echo "$x" >>"$copydir/etc/makepkg.conf"
|
||||
|
@ -220,9 +208,7 @@ EOF
|
|||
{
|
||||
printf '#!/bin/bash\n'
|
||||
declare -f _chrootbuild
|
||||
printf '_chrootbuild'
|
||||
printf ' %q' "${makepkg_args[@]}"
|
||||
printf ' || exit\n'
|
||||
printf '_chrootbuild "$@" || exit\n'
|
||||
|
||||
if $run_namcap; then
|
||||
declare -f _chrootnamcap
|
||||
|
@ -236,9 +222,6 @@ EOF
|
|||
# so no global variables
|
||||
_chrootbuild() {
|
||||
. /etc/profile
|
||||
# export HOME=/build
|
||||
# cd /startdir
|
||||
# sudo -u builduser makepkg "$@"
|
||||
sudo -iu builduser bash -c 'cd /startdir; makepkg "$@"' -bash "$@"
|
||||
}
|
||||
|
||||
|
@ -250,37 +233,52 @@ _chrootnamcap() {
|
|||
done
|
||||
}
|
||||
|
||||
# Usage: download_sources $copydir $src_owner
|
||||
# Globals:
|
||||
# - SRCDEST
|
||||
# - USER
|
||||
download_sources() {
|
||||
local copydir=$1
|
||||
local src_owner=$2
|
||||
|
||||
local builddir="$(mktemp -d)"
|
||||
chmod 1777 "$builddir"
|
||||
|
||||
# Ensure sources are downloaded
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
sudo -u $SUDO_USER env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \
|
||||
makepkg_user=${makepkg_user:-$SUDO_USER}
|
||||
if [[ -n $makepkg_user ]]; then
|
||||
sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \
|
||||
makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o
|
||||
else
|
||||
( export SRCDEST BUILDDIR="$builddir"
|
||||
makepkg --asroot --config="$copydir/etc/makepkg.conf" --verifysource -o
|
||||
)
|
||||
error "Running makepkg as root is not allowed."
|
||||
exit 1
|
||||
fi
|
||||
(( $? != 0 )) && die "Could not download sources."
|
||||
|
||||
# Clean up garbage from verifysource
|
||||
rm -rf $builddir
|
||||
rm -rf "$builddir"
|
||||
}
|
||||
|
||||
# Usage: move_products $copydir $owner
|
||||
# Globals:
|
||||
# - PKGDEST
|
||||
# - LOGDEST
|
||||
move_products() {
|
||||
local copydir=$1
|
||||
local src_owner=$2
|
||||
|
||||
local pkgfile
|
||||
for pkgfile in "$copydir"/pkgdest/*; do
|
||||
chown "$src_owner" "$pkgfile"
|
||||
mv "$pkgfile" "$PKGDEST"
|
||||
|
||||
# Fix broken symlink because of temporary chroot PKGDEST /pkgdest
|
||||
if [[ "$PWD" != "$PKGDEST" && -L "$PWD/${pkgfile##*/}" ]]; then
|
||||
rm "$PWD/${pkgfile##*/}"
|
||||
ln -sf "$PKGDEST/${pkgfile##*/}"
|
||||
fi
|
||||
done
|
||||
|
||||
local l
|
||||
for l in "$copydir"/logdest/*; do
|
||||
[[ $l == */logpipe.* ]] && continue
|
||||
chown "$src_owner" "$l"
|
||||
|
@ -294,49 +292,112 @@ move_products() {
|
|||
}
|
||||
# }}}
|
||||
|
||||
umask 0022
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
load_vars "$USER_HOME/.makepkg.conf" || load_vars /etc/makepkg.conf
|
||||
main() {
|
||||
init_variables
|
||||
|
||||
# Use PKGBUILD directory if these don't exist
|
||||
[[ -d $PKGDEST ]] || PKGDEST=$PWD
|
||||
[[ -d $SRCDEST ]] || SRCDEST=$PWD
|
||||
[[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD
|
||||
[[ -d $LOGDEST ]] || LOGDEST=$PWD
|
||||
local opts='hcur:I:l:nTD:d:U:'
|
||||
|
||||
create_chroot
|
||||
while getopts ${opts} arg; do
|
||||
case "$arg" in
|
||||
c) clean_first=true ;;
|
||||
D) bindmounts_ro+=("$OPTARG") ;;
|
||||
d) bindmounts_rw+=("$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+="-$$" ;;
|
||||
U) makepkg_user="$OPTARG" ;;
|
||||
h|*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
$update_first && chroot-run \
|
||||
-r "${mountargs_ro}" \
|
||||
-w "${mountargs_rw}" \
|
||||
"$copydir" \
|
||||
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
|
||||
[[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.'
|
||||
|
||||
check_root
|
||||
|
||||
# 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"
|
||||
|
||||
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
|
||||
|
||||
load_user_info
|
||||
|
||||
umask 0022
|
||||
|
||||
load_vars "${XDG_CONFIG_HOME:-$USER_HOME/.config}/pacman/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf"
|
||||
load_vars /etc/makepkg.conf
|
||||
|
||||
# Use PKGBUILD directory if these don't exist
|
||||
[[ -d $PKGDEST ]] || PKGDEST=$PWD
|
||||
[[ -d $SRCDEST ]] || SRCDEST=$PWD
|
||||
[[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD
|
||||
[[ -d $LOGDEST ]] || LOGDEST=$PWD
|
||||
|
||||
# Lock the chroot we want to use. We'll keep this lock until we exit.
|
||||
lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy"
|
||||
|
||||
if [[ ! -d $copydir ]] || $clean_first; then
|
||||
sync_chroot "$chrootdir" "$copy"
|
||||
fi
|
||||
|
||||
$update_first && chroot-run -r "${bindmounts_ro[*]}" -w "${bindmounts_rw[*]}" "$copydir" \
|
||||
pacman -Syu --noconfirm
|
||||
|
||||
[[ -n ${install_pkgs[*]} ]] && install_packages
|
||||
|
||||
download_sources
|
||||
|
||||
prepare_chroot
|
||||
|
||||
mountargs_rw="${PWD}:/startdir,${SRCDEST}:/srcdest"
|
||||
|
||||
if chroot-run -r "${mountargs_ro}" \
|
||||
-w "${mountargs_rw}" \
|
||||
"$copydir" \
|
||||
/chrootbuild; then
|
||||
move_products
|
||||
else
|
||||
(( ret += 1 ))
|
||||
fi
|
||||
|
||||
$temp_chroot && clean_temporary
|
||||
|
||||
if (( ret != 0 )); then
|
||||
if $temp_chroot; then
|
||||
die "Build failed"
|
||||
else
|
||||
die "Build failed, check %s/build" "$copydir"
|
||||
if [[ -n ${install_pkgs[*]:-} ]]; then
|
||||
install_packages "$copydir" "${install_pkgs[@]}"
|
||||
ret=$?
|
||||
# If there is no PKGBUILD we have done
|
||||
[[ -f PKGBUILD ]] || return $ret
|
||||
fi
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
download_sources "$copydir" "$src_owner"
|
||||
|
||||
prepare_chroot "$copydir" "$USER_HOME" "$repack" "$run_namcap"
|
||||
|
||||
bindmounts_rw+=("${PWD}:/startdir" "${SRCDEST}:/srcdest")
|
||||
|
||||
if chroot-run -r "${bindmounts_ro[*]}" -w "${bindmounts_rw[*]}" "$copydir" \
|
||||
/chrootbuild "${makepkg_args[@]}"; then
|
||||
move_products "$copydir" "$src_owner"
|
||||
else
|
||||
(( ret += 1 ))
|
||||
fi
|
||||
|
||||
$temp_chroot && delete_chroot "$copydir" "$copy"
|
||||
|
||||
if (( ret != 0 )); then
|
||||
if $temp_chroot; then
|
||||
die "Build failed"
|
||||
else
|
||||
die "Build failed, check %s/build" "$copydir"
|
||||
fi
|
||||
else
|
||||
true
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
|
@ -76,12 +76,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|||
you will upload.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-c</option></term>
|
||||
|
||||
<listitem><para>Create new remote release.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-l</option></term>
|
||||
|
||||
|
|
|
@ -44,12 +44,12 @@ prepare_boot_extras(){
|
|||
}
|
||||
|
||||
prepare_grub(){
|
||||
local platform=i386-pc img='core.img' grub=$2/boot/grub efi=$2/efi/boot \
|
||||
data=$1/usr/share/grub lib=$1/usr/lib/grub prefix=/boot/grub
|
||||
local platform=i386-pc img='core.img' grub=$3/boot/grub efi=$3/efi/boot \
|
||||
lib=$1/usr/lib/grub prefix=/boot/grub theme=$2/usr/share/grub data=$1/usr/share/grub
|
||||
|
||||
prepare_dir ${grub}/${platform}
|
||||
|
||||
cp ${data}/cfg/*.cfg ${grub}
|
||||
cp ${theme}/cfg/*.cfg ${grub}
|
||||
|
||||
cp ${lib}/${platform}/* ${grub}/${platform}
|
||||
|
||||
|
@ -80,11 +80,11 @@ prepare_grub(){
|
|||
grub-mkimage -d ${grub}/${platform} -o ${efi}/${img} -O ${platform} -p ${prefix} iso9660
|
||||
|
||||
prepare_dir ${grub}/themes
|
||||
cp -r ${data}/themes/${iso_name}-live ${grub}/themes/
|
||||
cp -r ${theme}/themes/${iso_name}-live ${grub}/themes/
|
||||
cp ${data}/unicode.pf2 ${grub}
|
||||
cp -r ${data}/{locales,tz,video} ${grub}
|
||||
cp -r ${theme}/{locales,tz} ${grub}
|
||||
|
||||
local size=8M mnt="${mnt_dir}/efiboot" efi_img="$2/efi.img"
|
||||
local size=4M mnt="${mnt_dir}/efiboot" efi_img="$3/efi.img"
|
||||
msg2 "Creating fat image of %s ..." "${size}"
|
||||
truncate -s ${size} "${efi_img}"
|
||||
mkfs.fat -n MISO_EFI "${efi_img}" &>/dev/null
|
||||
|
|
|
@ -161,55 +161,35 @@ make_sfs() {
|
|||
|
||||
assemble_iso(){
|
||||
msg "Creating ISO image..."
|
||||
local iso_publisher iso_app_id
|
||||
|
||||
iso_publisher="$(get_osname) <$(get_disturl)>"
|
||||
|
||||
iso_app_id="$(get_osname) Live/Rescue CD"
|
||||
|
||||
# xorriso -as mkisofs \
|
||||
# --protective-msdos-label \
|
||||
# -volid "${iso_label}" \
|
||||
# -appid "${iso_app_id}" \
|
||||
# -publisher "${iso_publisher}" \
|
||||
# -preparer "Prepared by manjaro-tools/${0##*/}" \
|
||||
# -e /efi.img \
|
||||
# -b boot/grub/i386-pc/eltorito.img \
|
||||
# -c boot.catalog \
|
||||
# -no-emul-boot \
|
||||
# -boot-load-size 4 \
|
||||
# -boot-info-table \
|
||||
# -graft-points \
|
||||
# --grub2-boot-info \
|
||||
# --grub2-mbr ${iso_root}/boot/grub/i386-pc/boot_hybrid.img \
|
||||
# --sort-weight 0 / --sort-weight 1 /boot \
|
||||
# -isohybrid-gpt-basdat \
|
||||
# -eltorito-alt-boot \
|
||||
# -output "${iso_dir}/${iso_file}" \
|
||||
# "${iso_root}/"
|
||||
local iso_publisher="$(get_osname) <$(get_disturl)>" \
|
||||
iso_app_id="$(get_osname) Live/Rescue CD" \
|
||||
mod_date=$(date -u +%Y-%m-%d-%H-%M-%S-00 | sed -e s/-//g)
|
||||
|
||||
xorriso -as mkisofs \
|
||||
--protective-msdos-label \
|
||||
-volid "${iso_label}" \
|
||||
-appid "${iso_app_id}" \
|
||||
-publisher "${iso_publisher}" \
|
||||
-preparer "Prepared by manjaro-tools/${0##*/}" \
|
||||
-b boot/grub/i386-pc/eltorito.img \
|
||||
-c boot.catalog \
|
||||
-no-emul-boot \
|
||||
-boot-load-size 4 \
|
||||
-boot-info-table \
|
||||
-graft-points \
|
||||
--grub2-boot-info \
|
||||
--grub2-mbr ${iso_root}/boot/grub/i386-pc/boot_hybrid.img \
|
||||
--sort-weight 0 / --sort-weight 1 /boot \
|
||||
-eltorito-alt-boot \
|
||||
-efi-boot-part --efi-boot-image \
|
||||
-e efi.img \
|
||||
-no-emul-boot \
|
||||
-isohybrid-gpt-basdat \
|
||||
-output "${iso_dir}/${iso_file}" \
|
||||
"${iso_root}/"
|
||||
--modification-date=${mod_date} \
|
||||
--protective-msdos-label \
|
||||
-volid "${iso_label}" \
|
||||
-appid "${iso_app_id}" \
|
||||
-publisher "${iso_publisher}" \
|
||||
-preparer "Prepared by manjaro-tools/${0##*/}" \
|
||||
-r -graft-points -no-pad \
|
||||
--sort-weight 0 / \
|
||||
--sort-weight 1 /boot \
|
||||
--grub2-mbr ${iso_root}/boot/grub/i386-pc/boot_hybrid.img \
|
||||
-partition_offset 16 \
|
||||
-b boot/grub/i386-pc/eltorito.img \
|
||||
-c boot.catalog \
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info \
|
||||
-eltorito-alt-boot \
|
||||
-append_partition 2 0xef ${iso_root}/efi.img \
|
||||
-e --interval:appended_partition_2:all:: \
|
||||
-no-emul-boot \
|
||||
-iso-level 3 \
|
||||
-o ${iso_dir}/${iso_file} \
|
||||
${iso_root}/
|
||||
|
||||
# arg to add with xorriso-1.4.7
|
||||
# -iso_mbr_part_type 0x00
|
||||
}
|
||||
|
||||
# Build ISO
|
||||
|
@ -408,15 +388,18 @@ configure_grub(){
|
|||
-i $1
|
||||
}
|
||||
|
||||
configure_grub_theme(){
|
||||
sed -e "s|@ISO_NAME@|${iso_name}|" -i "$1"
|
||||
}
|
||||
|
||||
make_grub(){
|
||||
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
||||
msg "Prepare [/iso/boot/grub]"
|
||||
|
||||
local path="${work_dir}/rootfs"
|
||||
|
||||
prepare_grub "${path}" "${iso_root}"
|
||||
prepare_grub "${work_dir}/rootfs" "${work_dir}/livefs" "${iso_root}"
|
||||
|
||||
configure_grub "${iso_root}/boot/grub/kernels.cfg"
|
||||
configure_grub_theme "${iso_root}/boot/grub/variable.cfg"
|
||||
|
||||
: > ${work_dir}/build.${FUNCNAME}
|
||||
msg "Done [/iso/boot/grub]"
|
||||
|
|
|
@ -11,11 +11,9 @@
|
|||
export LC_MESSAGES=C
|
||||
export LANG=C
|
||||
|
||||
disable_colors(){
|
||||
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
|
||||
}
|
||||
declare ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
|
||||
enable_colors(){
|
||||
if [[ -t 2 ]]; then
|
||||
# prefer terminal safe colored and bold text when tput is supported
|
||||
if tput setaf 0 &>/dev/null; then
|
||||
ALL_OFF="$(tput sgr0)"
|
||||
|
@ -32,14 +30,8 @@ enable_colors(){
|
|||
YELLOW="${BOLD}\e[33m"
|
||||
BLUE="${BOLD}\e[34m"
|
||||
fi
|
||||
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
|
||||
}
|
||||
|
||||
if [[ -t 2 ]]; then
|
||||
enable_colors
|
||||
else
|
||||
disable_colors
|
||||
fi
|
||||
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
|
||||
|
||||
plain() {
|
||||
local mesg=$1; shift
|
||||
|
@ -73,13 +65,42 @@ error() {
|
|||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" >&2
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n $1; then
|
||||
stat_busy "$3"
|
||||
flock $1
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn $1; then
|
||||
stat_busy "$3"
|
||||
flock -s $1
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
exit ${1:-0}
|
||||
}
|
||||
|
|
|
@ -370,7 +370,7 @@ write_calamares_yaml(){
|
|||
for conf in "${yaml_dir}"/etc/calamares/modules/*.conf "${yaml_dir}"/etc/calamares/settings.conf; do
|
||||
check_yaml "$conf"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
write_netgroup_yaml(){
|
||||
|
@ -385,7 +385,7 @@ write_netgroup_yaml(){
|
|||
for p in ${packages[@]};do
|
||||
echo " - $p" >> "$2"
|
||||
done
|
||||
${validate} && check_yaml "$2"
|
||||
${validate} && check_yaml "$2"
|
||||
}
|
||||
|
||||
write_pacman_group_yaml(){
|
||||
|
|
85
lib/util.sh
85
lib/util.sh
|
@ -123,7 +123,6 @@ get_timer(){
|
|||
echo $(date +%s)
|
||||
}
|
||||
|
||||
|
||||
# $1: start timer
|
||||
elapsed_time(){
|
||||
echo $(echo $1 $(get_timer) | awk '{ printf "%0.2f",($2-$1)/60 }')
|
||||
|
@ -133,33 +132,6 @@ show_elapsed_time(){
|
|||
info "Time %s: %s minutes" "$1" "$(elapsed_time $2)"
|
||||
}
|
||||
|
||||
lock() {
|
||||
eval "exec $1>"'"$2"'
|
||||
if ! flock -n $1; then
|
||||
stat_busy "$3"
|
||||
flock $1
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
eval "exec $1>"'"$2"'
|
||||
if ! flock -sn $1; then
|
||||
stat_busy "$3"
|
||||
flock -s $1
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
check_root() {
|
||||
(( EUID == 0 )) && return
|
||||
if type -P sudo >/dev/null; then
|
||||
exec sudo -- "$@"
|
||||
else
|
||||
exec su root -c "$(printf ' %q' "$@")"
|
||||
fi
|
||||
}
|
||||
|
||||
copy_mirrorlist(){
|
||||
cp -a /etc/pacman.d/mirrorlist "$1/etc/pacman.d/"
|
||||
}
|
||||
|
@ -690,29 +662,6 @@ show_config(){
|
|||
fi
|
||||
}
|
||||
|
||||
# $1: chroot
|
||||
kill_chroot_process(){
|
||||
# enable to have more debug info
|
||||
#msg "machine-id (etc): $(cat $1/etc/machine-id)"
|
||||
#[[ -e $1/var/lib/dbus/machine-id ]] && msg "machine-id (lib): $(cat $1/var/lib/dbus/machine-id)"
|
||||
#msg "running processes: "
|
||||
#lsof | grep $1
|
||||
|
||||
local prefix="$1" flink pid name
|
||||
for root_dir in /proc/*/root; do
|
||||
flink=$(readlink $root_dir)
|
||||
if [ "x$flink" != "x" ]; then
|
||||
if [ "x${flink:0:${#prefix}}" = "x$prefix" ]; then
|
||||
# this process is in the chroot...
|
||||
pid=$(basename $(dirname "$root_dir"))
|
||||
name=$(ps -p $pid -o comm=)
|
||||
info "Killing chroot process: %s (%s)" "$name" "$pid"
|
||||
kill -9 "$pid"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
create_min_fs(){
|
||||
msg "Creating install root at %s" "$1"
|
||||
mkdir -m 0755 -p $1/var/{cache/pacman/pkg,lib/pacman,log} $1/{dev,run,etc}
|
||||
|
@ -758,8 +707,17 @@ run(){
|
|||
fi
|
||||
}
|
||||
|
||||
check_root() {
|
||||
(( EUID == 0 )) && return
|
||||
if type -P sudo >/dev/null; then
|
||||
exec sudo -- "${orig_argv[@]}"
|
||||
else
|
||||
exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
|
||||
fi
|
||||
}
|
||||
|
||||
is_btrfs() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
|
||||
}
|
||||
|
||||
subvolume_delete_recursive() {
|
||||
|
@ -776,3 +734,26 @@ subvolume_delete_recursive() {
|
|||
|
||||
return 0
|
||||
}
|
||||
|
||||
# $1: chroot
|
||||
# kill_chroot_process(){
|
||||
# # enable to have more debug info
|
||||
# #msg "machine-id (etc): $(cat $1/etc/machine-id)"
|
||||
# #[[ -e $1/var/lib/dbus/machine-id ]] && msg "machine-id (lib): $(cat $1/var/lib/dbus/machine-id)"
|
||||
# #msg "running processes: "
|
||||
# #lsof | grep $1
|
||||
#
|
||||
# local prefix="$1" flink pid name
|
||||
# for root_dir in /proc/*/root; do
|
||||
# flink=$(readlink $root_dir)
|
||||
# if [ "x$flink" != "x" ]; then
|
||||
# if [ "x${flink:0:${#prefix}}" = "x$prefix" ]; then
|
||||
# # this process is in the chroot...
|
||||
# pid=$(basename $(dirname "$root_dir"))
|
||||
# name=$(ps -p $pid -o comm=)
|
||||
# info "Killing chroot process: %s (%s)" "$name" "$pid"
|
||||
# kill -9 "$pid"
|
||||
# fi
|
||||
# fi
|
||||
# done
|
||||
# }
|
||||
|
|
Loading…
Reference in a new issue