Make default copydir user-dependent
Eases usage when chroots are shared between multiple users.
This commit is contained in:
parent
0af05a48ab
commit
2fa8fdec47
|
@ -12,7 +12,6 @@ FORCE='n'
|
||||||
RUN=''
|
RUN=''
|
||||||
MAKEPKG_ARGS='-s --noconfirm'
|
MAKEPKG_ARGS='-s --noconfirm'
|
||||||
REPACK=''
|
REPACK=''
|
||||||
COPY='copy'
|
|
||||||
WORKDIR=$PWD
|
WORKDIR=$PWD
|
||||||
|
|
||||||
update_first='0'
|
update_first='0'
|
||||||
|
@ -24,6 +23,10 @@ chrootdir=''
|
||||||
|
|
||||||
APPNAME=$(basename "${0}")
|
APPNAME=$(basename "${0}")
|
||||||
|
|
||||||
|
default_copy=$USER
|
||||||
|
[[ -n $SUDO_USER ]] && default_copy=$SUDO_USER
|
||||||
|
[[ -z $default_copy || $default_copy = root ]] && default_copy=copy
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage ${APPNAME} [options] -r <chrootdir> [--] [makepkg args]"
|
echo "usage ${APPNAME} [options] -r <chrootdir> [--] [makepkg args]"
|
||||||
echo ' Run this script in a PKGBUILD dir to build a package inside a'
|
echo ' Run this script in a PKGBUILD dir to build a package inside a'
|
||||||
|
@ -50,7 +53,8 @@ usage() {
|
||||||
echo '-r <dir> The chroot dir to use'
|
echo '-r <dir> The chroot dir to use'
|
||||||
echo '-I <pkg> Install a package into the working copy of the chroot'
|
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 '-l <copy> The directory to use as the working copy of the chroot'
|
||||||
echo ' Useful for maintain multiple copies Default: copy'
|
echo ' Useful for maintaining multiple copies.'
|
||||||
|
echo " Default: $default_copy"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +66,7 @@ while getopts 'hcudr:I:l:' arg; do
|
||||||
d) add_to_db=1 ;;
|
d) add_to_db=1 ;;
|
||||||
r) chrootdir="$OPTARG" ;;
|
r) chrootdir="$OPTARG" ;;
|
||||||
I) install_pkg="$OPTARG" ;;
|
I) install_pkg="$OPTARG" ;;
|
||||||
l) COPY="$OPTARG" ;;
|
l) copy="$OPTARG" ;;
|
||||||
*) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;;
|
*) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -70,7 +74,8 @@ done
|
||||||
# Canonicalize chrootdir, getting rid of trailing /
|
# Canonicalize chrootdir, getting rid of trailing /
|
||||||
chrootdir=$(readlink -e "$chrootdir")
|
chrootdir=$(readlink -e "$chrootdir")
|
||||||
|
|
||||||
copydir="$chrootdir/$COPY"
|
[[ -z $copy ]] && copy=$default_copy
|
||||||
|
copydir="$chrootdir/$copy"
|
||||||
|
|
||||||
# Pass all arguments after -- right to makepkg
|
# Pass all arguments after -- right to makepkg
|
||||||
MAKEPKG_ARGS="$MAKEPKG_ARGS ${*:$OPTIND}"
|
MAKEPKG_ARGS="$MAKEPKG_ARGS ${*:$OPTIND}"
|
||||||
|
|
Loading…
Reference in New Issue