From e9bc885c355babf7851de31db8e1920dde752993 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 7 Nov 2012 00:17:08 -0500 Subject: organize the files --- src/chroot-tools/libremakepkg | 126 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 src/chroot-tools/libremakepkg (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg new file mode 100755 index 0000000..f7924f6 --- /dev/null +++ b/src/chroot-tools/libremakepkg @@ -0,0 +1,126 @@ +#!/bin/bash +# Copyright 2010 - 2011 Nicolás Reynolds +# Copyright 2011 Joshua Ismael Haase Hernández + +# ---------- GNU General Public License 3 ---------- + +# This file is part of Parabola. + +# Parabola is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# Parabola is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with Parabola. If not, see . + + +# set -x # uncomment for debug + +function copy_log { # copy logs if they exist + + find "${CHROOTDIR}/${CHROOT}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; + +} + + +function trap_exit { # End inmediately but print a useful message + + copy_log + error "$@" + exit 1 + +} + +# Trap signals from makepkg +set -E +trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT +trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT +trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR + +source /etc/libretools.conf + +CLEANFIRST="false" +UPDATEFIRST="false" +CHECKNONFREE="true" +LIBRECHROOT_ARGS="" +MAKEPKG_ARGS="" + +function usage { + + echo '' + echo 'cd to a dir containing a PKGBUILD and run:' + echo '$0 [options] [-- makechrootpkg args [-- makepkg args]]' + echo 'This script will build your package on a chroot.' + echo '' + echo 'OPTIONS:' + echo '' + echo ' -h : show this message.' + echo ' -c : clean the chroot before building.' + echo ' -u : update the chroot before building.' + echo ' -d : use this dir instead of "$CHROOTDIR"' + echo ' -n : use this dir instead of "$CHROOT".' + echo ' -N : do not check freedom issues' # As fullpkg-check will do that before + echo '' + exit 1 + +} + +while getopts 'hcud:n:N' arg ; do + case "${arg}" in + h) usage ;; + c) CLEANFIRST="true" ;; + u) UPDATEFIRST="true" ;; + d) CHROOTDIR="$OPTARG" + LIBRECHROOT_ARGS='-d "$OPTARG"' ;; + n) CHROOT="$OPTARG" ;; + N) CHECKNONFREE="false" ;; + esac +done + +# Pass all arguments after -- right to makechrootpkg +MAKEPKG_ARGS="$makepkg_args ${*:$OPTIND}" + +if (( EUID )); then + error "This script must be run as root" + exit 1 +fi + +if [ ! -e PKGBUILD ]; then # Check if we are actually on a build directory. Do this early. + error "This isn't a build directory"; usage +fi + +msg "Checking PKGBUILD for non-free issues" +if "$CHECKNONFREE"; then + if ! pkgbuild-check-nonfree; then + + if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree + error "PKGBUILD contains non-free issues" + exit 15 + else + warning "PKGBUILD couldn't be check aganist non-free issues" + fi + fi +fi + +if "$CLEANFIRST"; then + librechroot -c "$LIBRECHROOT_ARGS" "$CHROOT" +fi + +if "$UPDATEFIRST"; then + librechroot -u "$LIBRECHROOT_ARGS" "$CHROOT" +fi + +unset CLEANFIRST UPDATEFIRST LIBRECHROOT_ARGS + +makechrootpkg -d -r "$CHROOTDIR" -l "$CHROOT" -- $MAKEPKG_ARGS +ev="$?" # exit value + +copy_log + +exit $ev -- cgit v1.2.3-54-g00ecf From 16e41597e98333f6383a3cb9aa6e9371f64522bf Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 17:32:40 -0500 Subject: chroot-tools: clean up, make play nice with new devtools * buildenv: delete; this is done by `mkarchroot` * librechroot: - adopt `archbuild`'s concept of CHROOT and CHROOTCOPY - add `-l` option to set the CHROOTCOPY * libremakepkg: - adopt `archbuild`'s concept of CHROOT and CHROOTCOPY - add `-l` option to set the CHROOTCOPY - pass options to `makechrootpkg` and `makepkg` the way `-h` always said it did * libremkchroot: - adopt `archbuild`'s concept of CHROOT and CHROOTCOPY - remove `-c` option to set the pacman cache - remove `-f` option to force overwrite --- src/chroot-tools/buildenv | 28 ------ src/chroot-tools/librechroot | 160 ++++++++++++++++++--------------- src/chroot-tools/libremakepkg | 195 ++++++++++++++++++++++------------------- src/chroot-tools/libremkchroot | 56 ++++++------ 4 files changed, 222 insertions(+), 217 deletions(-) delete mode 100755 src/chroot-tools/buildenv (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/buildenv b/src/chroot-tools/buildenv deleted file mode 100755 index 84a1fc2..0000000 --- a/src/chroot-tools/buildenv +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -trap "umount_all" 0 ERR TERM KILL - -user=${SUDO_USER:-${1}} - -umount_all() { - for mp in home/pkgdest home/srcdest home/${user}; do - msg "Umounting /$mp" - umount $CHROOTDIR/$CHROOT/$mp || error "Couldn't umount" - done -} - -source /etc/libretools.conf - -for mp in home/pkgdest home/srcdest home/${user} var/lib/toru; do - msg "Binding /$mp" - mount -o bind /$mp $CHROOTDIR/$CHROOT/$mp || exit 1 -done - -for etc in etc/makepkg.conf etc/abs.conf etc/mtab; do - msg "Copying config /$etc" - cp --remove-destination /$etc $CHROOTDIR/$CHROOT/$etc || exit 1 -done - -$(dirname $0)/librechroot $CHROOT - -exit $? diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index c8e02b0..d53448a 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -4,6 +4,7 @@ # Copyright 2010 Nicolás Reynolds # Copyright 2011 Joshua Haase +# Copyright 2012 Luke Shumaker # ---------- GNU General Public License 3 ---------- @@ -22,87 +23,100 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -function usage { - - echo "" - echo "Usage: $0 [options] [chrootname]" - echo "Use it as root." - echo "" - echo "Default chroot name: $CHROOT" - echo "Default chrootdir: $CHROOTDIR" - echo "" - echo "OPTIONS:" - echo "" - echo " -c : clean the chroot using pacman" - echo " only 'base', 'base-devel' and 'sudo' on chroot" - echo " -d : use instead of default" - echo " -r : clean /repo on the chroot" - echo " -h : this message" - echo " -u : update the chroot" - echo "" +. /etc/libretools.conf -} +cmd=${0##*/} -function clean_chroot { # Clean packages with pacman - cp -a "$(dirname $0)/chcleanup" "${CHROOTDIR}/${CHROOTNAME}/clean" +clean_chroot() { # Clean packages with pacman + msg "Cleaning chroot with pacman: ${chroot_path}" - mkarchroot -r "cd /build; /clean" "${CHROOTDIR}/${CHROOTNAME}" -} + cp -a "$(dirname $0)/chcleanup" "${chroot_path}/clean" + mkarchroot -r "cd /build; /clean" "${chroot_path}" -function clean_repo { - msg "Cleaning repo for chroot: ${CHROOTDIR}/${CHROOTNAME}" - if [ -d "${CHROOTDIR}/${CHROOTNAME}/repo" ]; then - find "${CHROOTDIR}/${CHROOTNAME}/repo/" -mindepth 1 -delete - else - mkdir -p "${CHROOTDIR}/${CHROOTNAME}/repo" - fi - bsdtar -czf "${CHROOTDIR}/${CHROOTNAME}/repo/repo.db.tar.gz" -T /dev/null - ln -s "repo.db.tar.gz" "${CHROOTDIR}/${CHROOTNAME}/repo/repo.db" + #mkarchroot "${chroot_path}" base base-devel sudo "${CHROOTEXTRAPKG[@]}" } -source /etc/libretools.conf - -if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then - source "$XDG_CONFIG_HOME/libretools/libretools.conf" -fi - -CLEANCHROOT='false' -UPDATE='false' -CLEANREPO='false' -CHROOTNAME="${CHROOT:-${SUDO_USER:-root}}" - -while getopts 'hrcud:' arg; do - case $arg in - h) usage; exit 0 ;; - c) CLEANCHROOT='true' ;; - u) UPDATE='true' ;; - r) CLEANREPO='true' ;; - d) CHROOTDIR="$(readlink -e $OPTARG)" ;; - esac -done - -[[ "$UID" != "0" ]] && { - error "This script must be run as root." - exit 1 + +clean_repo() { + msg "Cleaning repo for chroot: ${chroot_path}" + + if [ -d "${chroot_path}/repo" ]; then + find "${chroot_path}/repo/" -mindepth 1 -delete + else + mkdir -p "${chroot_path}/repo" + fi + bsdtar -czf "${chroot_path}/repo/repo.db.tar.gz" -T /dev/null + ln -s "repo.db.tar.gz" "${chroot_path}/repo/repo.db" } -shift $(($OPTIND - 1)) +update() { + msg "Updating chroot: ${chroot_path}" + mkarchroot -u "${chroot_path}" +} -if [ $# -eq 1 ]; then - CHROOTNAME="$1" -fi +enter() { + msg "Entering chroot: ${chroot_path}" + mkarchroot -r "bash" "${chroot_path}" +} -if "$CLEANREPO"; then - clean_repo -fi +usage() { + echo "Usage: $cmd [OPTIONS] [CHROOT]" + echo 'Interacts with a chroot.' + echo '' + echo "The default CHROOT is \`${CHROOT}'." + echo '' + echo 'Options:' + echo ' Settings:' + echo " -d Use this dir instead of \`${CHROOTDIR}'" + echo ' -l Use this as the chroot copy instead of basing it' + echo ' on the username' + echo ' Modes:' + echo ' -h Show this message' + echo ' -c Clean the chroot using pacman' + echo ' -r Clean /repo in the chroot' + echo ' -u Update the chroot' +} -if "$CLEANCHROOT"; then - clean_chroot -elif "$UPDATE"; then - msg "Updating chroot: ${CHROOTDIR}/${CHROOTNAME}" - mkarchroot -u "${CHROOTDIR}/${CHROOTNAME}" -else - msg "Entering chroot: ${CHROOTDIR}/${CHROOTNAME}" - mkarchroot -r "bash" "${CHROOTDIR}/${CHROOTNAME}" -fi +main() { + # The logic for setting CHROOTCOPY is mirred from makechrootpkg + CHROOTCOPY=$USER + [[ -n $SUDO_USER ]] && CHROOTCOPY=$SUDO_USER + [[ -z $CHROOTCOPY || $CHROOTCOPY = root ]] && CHROOTCOPY=copy + + local mode=enter + while getopts 'hrcud:l:' arg; do + case $arg in + d) CHROOTDIR=$OPTARG;; + l) CHROOTCOPY=$OPTARG;; + + c) mode=clean_chroot;; + r) mode=clean_repo;; + u) mode=update;; + + h) usage; exit 0;; + *) usage; exit 1;; + esac + done + shift $(($OPTIND - 1)) + case $# in + 0) :;; + 1) CHROOT="$1";; + *) usage; exit 1;; + esac + + # not local + chroot_path="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" + + if (( EUID )); then + error "This script must be run as root." + exit 1 + fi + + case "$mode" in + clean_chroot) clean_chroot; exit $?;; + clean_repo) clean_repo; exit $?;; + update) update; exit $?;; + enter) enter; exit $?;; + esac +} -exit 0 +main "$@" diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index f7924f6..69e8998 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -1,6 +1,10 @@ #!/bin/bash +# libremakepkg +# analogous to devtools' archbuild + # Copyright 2010 - 2011 Nicolás Reynolds # Copyright 2011 Joshua Ismael Haase Hernández +# Copyright 2012 Luke Shumaker # ---------- GNU General Public License 3 ---------- @@ -19,108 +23,117 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . +. /etc/libretools.conf -# set -x # uncomment for debug - -function copy_log { # copy logs if they exist - - find "${CHROOTDIR}/${CHROOT}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; - +## +# copy logs if they exist +## +copy_log() { + find "${chroot_path}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; } - -function trap_exit { # End inmediately but print a useful message - - copy_log - error "$@" - exit 1 - +## +# End inmediately but print a useful message +## +trap_exit() { + copy_log + error "$@" + exit 1 } -# Trap signals from makepkg -set -E -trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT -trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT -trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR - -source /etc/libretools.conf - -CLEANFIRST="false" -UPDATEFIRST="false" -CHECKNONFREE="true" -LIBRECHROOT_ARGS="" -MAKEPKG_ARGS="" - -function usage { - - echo '' +usage() { echo 'cd to a dir containing a PKGBUILD and run:' echo '$0 [options] [-- makechrootpkg args [-- makepkg args]]' - echo 'This script will build your package on a chroot.' + echo 'This script will build your package in a chroot.' echo '' echo 'OPTIONS:' + echo ' -h Show this message' echo '' - echo ' -h : show this message.' - echo ' -c : clean the chroot before building.' - echo ' -u : update the chroot before building.' - echo ' -d : use this dir instead of "$CHROOTDIR"' - echo ' -n : use this dir instead of "$CHROOT".' - echo ' -N : do not check freedom issues' # As fullpkg-check will do that before + echo ' -c Clean the chroot before building' + echo ' -u Update the chroot before building' + echo ' -N Do not check freedom issues (for fullpkg)' echo '' - exit 1 + echo " -d Use this dir instead of \`$CHROOTDIR'" + echo " -n Use this chroot instead of \`$CHROOT'" + echo ' -l Use this chroot copy instead of basing it' + echo ' on the username' +} +main() { + # The logic for setting CHROOTCOPY is mirred from makechrootpkg + CHROOTCOPY=$USER + [[ -n $SUDO_USER ]] && CHROOTCOPY=$SUDO_USER + [[ -z $CHROOTCOPY || $CHROOTCOPY = root ]] && CHROOTCOPY=copy + + CLEANFIRST=false + UPDATEFIRST=false + CHECKNONFREE=true + + makechrootpkg_args=() + + while getopts 'hcuNd:n:l:' arg ; do + case "${arg}" in + c) CLEANFIRST=true;; + u) UPDATEFIRST=true;; + N) CHECKNONFREE=false;; + + d) CHROOTDIR=$OPTARG;; + n) CHROOT=$OPTARG;; + l) CHROOTCOPY=$OPTARG;; + + h) usage; exit 0;; + *) usage; exit 1;; + esac + done + shift $(($OPTIND - 1)) + # Pass all arguments after -- right to makechrootpkg + makechrootpkg_args+=("$@") + + if (( EUID )); then + error "This script must be run as root" + exit 1 + fi + + if [[ ! -e PKGBUILD ]]; then + error "This isn't a build directory" + exit 1 + fi + + # OK, we're starting now ############################################### + + # Trap signals from makepkg + set -E + trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT + trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT + trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR + + if $CHECKNONFREE; then + msg "Checking PKGBUILD for non-free issues" + if ! pkgbuild-check-nonfree; then + if [[ $? -eq 15 ]]; then + # other errors mean fail, not nonfree + error "PKGBUILD contains non-free issues" + exit 15 + else + warning "PKGBUILD couldn't be check aganist non-free issues" + fi + fi + fi + + if $CLEANFIRST; then + librechroot -c -d "$CHROOTDIR" -l "$CHROOTCOPY" "$CHROOT" + fi + + if $UPDATEFIRST; then + librechroot -u -d "$CHROOTDIR" -l "$CHROOTCOPY" "$CHROOT" + fi + + unset CLEANFIRST UPDATEFIRST librechroot_args + + makechrootpkg "${makechrootpkg_args[@]}" -d -r "$CHROOTDIR/${CHROOT}" -l "$CHROOTCOPY" + ev=$? # exit value + copy_log + exit $ev } -while getopts 'hcud:n:N' arg ; do - case "${arg}" in - h) usage ;; - c) CLEANFIRST="true" ;; - u) UPDATEFIRST="true" ;; - d) CHROOTDIR="$OPTARG" - LIBRECHROOT_ARGS='-d "$OPTARG"' ;; - n) CHROOT="$OPTARG" ;; - N) CHECKNONFREE="false" ;; - esac -done - -# Pass all arguments after -- right to makechrootpkg -MAKEPKG_ARGS="$makepkg_args ${*:$OPTIND}" - -if (( EUID )); then - error "This script must be run as root" - exit 1 -fi - -if [ ! -e PKGBUILD ]; then # Check if we are actually on a build directory. Do this early. - error "This isn't a build directory"; usage -fi - -msg "Checking PKGBUILD for non-free issues" -if "$CHECKNONFREE"; then - if ! pkgbuild-check-nonfree; then - - if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree - error "PKGBUILD contains non-free issues" - exit 15 - else - warning "PKGBUILD couldn't be check aganist non-free issues" - fi - fi -fi - -if "$CLEANFIRST"; then - librechroot -c "$LIBRECHROOT_ARGS" "$CHROOT" -fi - -if "$UPDATEFIRST"; then - librechroot -u "$LIBRECHROOT_ARGS" "$CHROOT" -fi - -unset CLEANFIRST UPDATEFIRST LIBRECHROOT_ARGS - -makechrootpkg -d -r "$CHROOTDIR" -l "$CHROOT" -- $MAKEPKG_ARGS -ev="$?" # exit value - -copy_log - -exit $ev +main "$@" diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index b576209..48b255a 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -21,44 +21,50 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -source /etc/libretools.conf - -if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then - source "$XDG_CONFIG_HOME/libretools/libretools.conf" -fi +. /etc/libretools.conf cmd=${0##*/} -function usage { - echo "Usage: $cmd [OPTIONS]" + +usage() { + echo "Usage: $cmd [OPTIONS] [CHROOT]" echo 'This script will create a chroot to build packages in.' echo "Use \`librechroot' to interact with the chroot after it is created." echo '' + echo "The default CHROOT is \`${CHROOT}'." + echo '' echo 'Options:' echo ' -h Show this message' echo '' - echo ' -f Force overwrite of files in the working-dir' - echo '' echo ' -d Use this dir instead of "$CHROOTDIR".' - echo " -c Location of pacman cache. Default: \`/var/cache/pacman/pkg'." echo ' -C Location of pacman config file.' echo ' -M Location of makepkg config file.' } -mkchroot_args=(); -while getopts 'hfd:c:C:M:' arg; do - case "$arg" in - h) usage; exit 0 ;; - f) mkchroot_args+=("-$arg");; - c|C|M) mkchroot_args+=("-$arg" "$OPTARG");; - d) CHROOTDIR=$OPTARG ;; - ?) usage; exit 1 ;; +main() { + mkarchroot_args=(); + while getopts 'hfd:C:M:' arg; do + case "$arg" in + C|M) mkarchroot_args+=("-$arg" "$OPTARG");; + d) CHROOTDIR=$OPTARG;; + + h) usage; exit 0;; + *) usage; exit 1;; + esac + done + shift $(($OPTIND - 1)) + case $# in + 0) :;; + 1) CHROOT="$1";; + *) usage; exit 1;; esac -done -if (( EUID )); then - error "This script must be run as root" - exit 1 -fi + if (( EUID )); then + error "This script must be run as root" + exit 1 + fi + + mkdir -p "${CHROOTDIR}/${CHROOT}" + xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" < /etc/libretools.d/cleansystem +} -mkdir -p "${CHROOTDIR}" -xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/root" < /etc/libretools.d/cleansystem +main "$@" -- cgit v1.2.3-54-g00ecf From 749e8295844160ba96f0a67cab1a0799a5a81a24 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 18:54:52 -0500 Subject: libremakepkg: touch up brackets --- src/chroot-tools/libremakepkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 69e8998..a146627 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -130,7 +130,7 @@ main() { unset CLEANFIRST UPDATEFIRST librechroot_args - makechrootpkg "${makechrootpkg_args[@]}" -d -r "$CHROOTDIR/${CHROOT}" -l "$CHROOTCOPY" + makechrootpkg "${makechrootpkg_args[@]}" -d -r "$CHROOTDIR/$CHROOT" -l "$CHROOTCOPY" ev=$? # exit value copy_log exit $ev -- cgit v1.2.3-54-g00ecf From a7d0da3e7fd7009c28e09f73c32f0a355819f2e6 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 13 Nov 2012 00:07:15 -0500 Subject: libremakepkg: fix copy_log --- src/chroot-tools/libremakepkg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index a146627..3fa2f3d 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -29,7 +29,7 @@ # copy logs if they exist ## copy_log() { - find "${chroot_path}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; + find "${copydir}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; } ## @@ -89,6 +89,10 @@ main() { # Pass all arguments after -- right to makechrootpkg makechrootpkg_args+=("$@") + # not local + rootdir="${CHROOTDIR}/${CHROOT}/root" + copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" + if (( EUID )); then error "This script must be run as root" exit 1 -- cgit v1.2.3-54-g00ecf From 444cc22bc5cda7a4adc26982d3edbcfd1af426ed Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 13 Nov 2012 00:44:38 -0500 Subject: add an '-f' flag to pkgbuild-check-nonfree to let libremakepkg run as root --- src/chroot-tools/libremakepkg | 2 +- src/pkgbuild-check-nonfree | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 3fa2f3d..4593121 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -113,7 +113,7 @@ main() { if $CHECKNONFREE; then msg "Checking PKGBUILD for non-free issues" - if ! pkgbuild-check-nonfree; then + if ! pkgbuild-check-nonfree -f; then if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree error "PKGBUILD contains non-free issues" diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree index fba4b7b..0fd480c 100755 --- a/src/pkgbuild-check-nonfree +++ b/src/pkgbuild-check-nonfree @@ -146,12 +146,15 @@ usage() { echo "If no PKGBUILD is specified, \`./PKGBUILD' is implied" echo "" echo "Options:" + echo " -f Allow running as root user" echo " -h Show this message" } main() { + local asroot=false while getopts 'fh' arg; do case "$arg" in + f) asroot=true;; h) usage; exit 0;; *) usage; exit 1;; esac @@ -162,7 +165,7 @@ main() { pkgbuilds=("`pwd`/PKGBUILD") fi - if [[ -w / ]]; then + if [[ -w / ]] && ! $asroot; then error "Run as normal user" exit 1 fi -- cgit v1.2.3-54-g00ecf From fd1e5a426713715d9c0e3fabbfe0d8a20b629bad Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 15:18:44 -0500 Subject: chroot-tools: disable overriding CHROOTDIR at the command line --- src/chroot-tools/librechroot | 2 -- src/chroot-tools/libremakepkg | 2 -- src/chroot-tools/libremkchroot | 2 -- 3 files changed, 6 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index a5c5728..48e6cdc 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -136,7 +136,6 @@ usage() { echo '' echo 'Options:' echo ' Settings:' - echo " -d Use this dir instead of \`${CHROOTDIR}'" echo ' -l Use this as the chroot copy instead of basing it' echo ' on the username' echo ' Modes:' @@ -156,7 +155,6 @@ main() { local mode=enter while getopts 'hrcud:l:' arg; do case $arg in - d) CHROOTDIR=$OPTARG;; l) CHROOTCOPY=$OPTARG;; c) mode=clean_pacman;; diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 4593121..faa50be 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -53,7 +53,6 @@ usage() { echo ' -u Update the chroot before building' echo ' -N Do not check freedom issues (for fullpkg)' echo '' - echo " -d Use this dir instead of \`$CHROOTDIR'" echo " -n Use this chroot instead of \`$CHROOT'" echo ' -l Use this chroot copy instead of basing it' echo ' on the username' @@ -77,7 +76,6 @@ main() { u) UPDATEFIRST=true;; N) CHECKNONFREE=false;; - d) CHROOTDIR=$OPTARG;; n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index cc5b431..08f69b1 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -35,7 +35,6 @@ usage() { echo 'Options:' echo ' -h Show this message' echo '' - echo ' -d Use this dir instead of "$CHROOTDIR".' echo ' -C Location of pacman config file.' echo ' -M Location of makepkg config file.' } @@ -45,7 +44,6 @@ main() { while getopts 'hfd:C:M:' arg; do case "$arg" in C|M) mkarchroot_args+=("-$arg" "$OPTARG");; - d) CHROOTDIR=$OPTARG;; h) usage; exit 0;; *) usage; exit 1;; -- cgit v1.2.3-54-g00ecf From 259c05c47fc43875415d5ecab9666a46fb4b6d76 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 19:34:19 -0500 Subject: Rewrite libremakepkg to not use makechrootpkg --- src/chroot-tools/libremakepkg | 175 ++++++++++++++++++++++++------------- src/chroot-tools/libremakepkg.gpl2 | 102 +++++++++++++++++++++ 2 files changed, 214 insertions(+), 63 deletions(-) create mode 100755 src/chroot-tools/libremakepkg.gpl2 (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index faa50be..d661714 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -1,141 +1,190 @@ -#!/bin/bash +#!/bin/bash -euE # libremakepkg -# analogous to devtools' archbuild # Copyright 2010 - 2011 Nicolás Reynolds # Copyright 2011 Joshua Ismael Haase Hernández # Copyright 2012 Luke Shumaker - -# ---------- GNU General Public License 3 ---------- - +# # This file is part of Parabola. - +# # Parabola is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. - +# # Parabola is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. - +# # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . . /etc/libretools.conf +shopt -s nullglob + +# This file (libremakepkg) is GPLv3+, but I would like to use some code +# modified from devtools' "makechrootpkg", which is GPLv2. +. "$(dirname "$0")/libremakepkg.gpl2" +# This gives us the functions: +# - chroot_init +# - chroot_extract +# - chroot_build +# - copy_pkgs + +# Boring functions ############################################################# + ## # copy logs if they exist ## -copy_log() { - find "${copydir}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; +copy_logs() { + for l in "$copydir"/build/*.log; do + chown "$LIBREUSER" "$l" + mv "$l" . + done } ## # End inmediately but print a useful message ## trap_exit() { - copy_log - error "$@" + copy_logs + error "$*" exit 1 } +## +# Usage: makepkg_conf_get SETTING [DEFAULT] +## +makepkg_conf_get() { + local setting=$1 + if [[ -f $LIBREHOME/.makepkg.conf ]]; then + eval $(grep "^$setting=" "$LIBREHOME/.makepkg.conf") + fi + if [[ -z ${!setting} ]]; then + eval $(grep "^$setting=" "/etc/makepkg.conf") + fi + if [[ -z ${!setting} && -n ${2} ]]; then + eval "$setting='$2'" + fi +} + +chroot_makepkg_conf_get() { + local setting=$1 + eval $(grep "^$setting=" "$copydir/etc/makepkg.conf") +} + +chroot_makepkg_conf_set() { + local key=$1 + local val=$2 + sed -i "/^$KEY=/d" "$copydir/etc/makepkg.conf" + echo "$key='$val'" >> "$copydir/etc/makepkg.conf" +} + +# Functions that check for issues with the build ############################### + +libre_check_pkgbuild() { + msg "Checking PKGBUILD for issues" + # TODO + if ! pkgbuild-check-nonfree -f; then + if [[ $? -eq 15 ]]; then + # other errors mean fail, not nonfree + error "PKGBUILD contains non-free issues" + exit 15 + else + warning "PKGBUILD couldn't be check aganist non-free issues" + fi + fi +} + +libre_check_src() { + msg "Checking src directory for issues" + # TODO +} + +libre_check_pkg() { + msg "Checking final package for issues" + # TODO +} + + +# The main program ############################################################# + usage() { echo 'cd to a dir containing a PKGBUILD and run:' - echo '$0 [options] [-- makechrootpkg args [-- makepkg args]]' + echo '$0 [options] [-- makepkg args]' echo 'This script will build your package in a chroot.' echo '' echo 'OPTIONS:' echo ' -h Show this message' echo '' - echo ' -c Clean the chroot before building' - echo ' -u Update the chroot before building' - echo ' -N Do not check freedom issues (for fullpkg)' - echo '' + echo " -R Repackage" echo " -n Use this chroot instead of \`$CHROOT'" echo ' -l Use this chroot copy instead of basing it' echo ' on the username' } main() { - # The logic for setting CHROOTCOPY is mirred from makechrootpkg - CHROOTCOPY=$USER - [[ -n $SUDO_USER ]] && CHROOTCOPY=$SUDO_USER - [[ -z $CHROOTCOPY || $CHROOTCOPY = root ]] && CHROOTCOPY=copy - - CLEANFIRST=false - UPDATEFIRST=false - CHECKNONFREE=true + # Parse command line ################################################### - makechrootpkg_args=() + CHROOTCOPY=$LIBREUSER + [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy + makepkg_args=(-s --noconfirm -L) + REPACKAGE=false - while getopts 'hcuNd:n:l:' arg ; do + while getopts 'hRn:l:' arg ; do case "${arg}" in - c) CLEANFIRST=true;; - u) UPDATEFIRST=true;; - N) CHECKNONFREE=false;; - n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; - + R) REPACKAGE=true; makepkg_args+=(-R) ;; h) usage; exit 0;; *) usage; exit 1;; esac done shift $(($OPTIND - 1)) - # Pass all arguments after -- right to makechrootpkg - makechrootpkg_args+=("$@") + # Pass all arguments after -- right to makepkg + makepkg_args+=("$@") - # not local rootdir="${CHROOTDIR}/${CHROOT}/root" copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" + # Init ################################################################# + if (( EUID )); then error "This script must be run as root" exit 1 fi - if [[ ! -e PKGBUILD ]]; then - error "This isn't a build directory" + if [[ ! -f PKGBUILD ]]; then + error "This must be run in a directory containing a PKGBUILD" exit 1 fi - # OK, we're starting now ############################################### - # Trap signals from makepkg - set -E trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR - if $CHECKNONFREE; then - msg "Checking PKGBUILD for non-free issues" - if ! pkgbuild-check-nonfree -f; then - if [[ $? -eq 15 ]]; then - # other errors mean fail, not nonfree - error "PKGBUILD contains non-free issues" - exit 15 - else - warning "PKGBUILD couldn't be check aganist non-free issues" - fi - fi - fi + makepkg_conf_get SRCDEST . + makepkg_conf_get PKGDEST . - if $CLEANFIRST; then - librechroot -c -d "$CHROOTDIR" -l "$CHROOTCOPY" "$CHROOT" - fi + # OK, we're starting now ############################################### - if $UPDATEFIRST; then - librechroot -u -d "$CHROOTDIR" -l "$CHROOTCOPY" "$CHROOT" - fi + lock_open_write 9 "$copydir.lock" "Locking chroot '$copy'" - unset CLEANFIRST UPDATEFIRST librechroot_args + # Set target CARCH as it might be used within the PKGBUILD to select correct sources + chroot_makepkg_conf_get CARCH + export CARCH - makechrootpkg "${makechrootpkg_args[@]}" -d -r "$CHROOTDIR/$CHROOT" -l "$CHROOTCOPY" - ev=$? # exit value - copy_log - exit $ev + chroot_init + libre_check_pkgbuild + $REPACKAGE || chroot_extract + libre_check_src + chroot_build + libre_check_pkg + copy_pkgs + copy_logs } main "$@" diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2 new file mode 100755 index 0000000..8ca60e0 --- /dev/null +++ b/src/chroot-tools/libremakepkg.gpl2 @@ -0,0 +1,102 @@ +#!/bin/bash +# Contains code derived from devtools' "makechrootpkg" + +# Copyright 2011-2012 The Arch Linux Development Team +# Copyright 2012 Luke Shumaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +chroot_init() { + # no-op; make sure the chroot exists + librechroot -n -l "$CHROOTCOPY" "$CHROOT" + + if [[ -r "$LIBREHOME/.gnupg/pubring.gpg" ]]; then + install -D "$HOME/.gnupg/pubring.gpg" "$copydir/build/.gnupg/pubring.gpg" + fi + + mkdir -p "$copydir/pkgdest" + mkdir -p "$copydir/srcdest" + chroot_makepkg_conf_set PKGDEST /pkgdest + chroot_makepkg_conf_set SRCDEST /srcdest + + cat > "$copydir/etc/sudoers.d/nobody-pacman" < "$file" + echo '. /etc/profile' >> "$file" + echo 'export HOME=/build' >> "$file" + echo 'cd /build' >> "$file" + echo "sudo -u nobody ${MAKEPKG:-makepkg} $makepkg_args -o" >> "$file" + chmod 755 "$file" + archroot "$copydir" -r /chrootextract +} + +chroot_build() { + local file="$copydir/chrootbuild" + echo '#!/bin/bash' > "$file" + echo '. /etc/profile' >> "$file" + echo 'export HOME=/build' >> "$file" + echo 'cd /build' >> "$file" + echo "sudo -u nobody ${MAKEPKG:-makepkg} $makepkg_args -e" >> "$file" + chmod 755 "$file" + archroot -N "$copydir" -r /chrootbuild +} + +copy_pkgs() { + for pkgfile in "$copydir"/pkgdest/*.pkg.tar*; do + mkdir -p "$copydir/repo" + pushd "$copydir/repo" >/dev/null + cp "$pkgfile" . + repo-add repo.db.tar.gz "${pkgfile##*/}" + popd >/dev/null + + chown "$LIBREUSER" "$pkgfile" + mv "$pkgfile" "$PKGDEST" + if [[ $PKGDEST != . ]]; then + ln -s "$PKGDEST/${pkgfile##*/}" . + fi + done +} -- cgit v1.2.3-54-g00ecf From 6dd807e109d491458b26d76602ad344b4c025475 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 19:42:08 -0500 Subject: teach libremakepkg "-m" to use a different command than "makepkg" --- src/chroot-tools/libremakepkg | 17 +++++++++++------ src/chroot-tools/libremakepkg.gpl2 | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index d661714..b6c84c1 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -117,12 +117,14 @@ usage() { echo 'This script will build your package in a chroot.' echo '' echo 'OPTIONS:' - echo ' -h Show this message' + echo " -n Use this chroot instead of \`$CHROOT'" + echo ' -l Use this chroot copy instead of basing it' + echo ' on the username' echo '' + echo " -m Use the command MAKEPKG instead of 'makepkg'" echo " -R Repackage" - echo " -n Use this chroot instead of \`$CHROOT'" - echo ' -l Use this chroot copy instead of basing it' - echo ' on the username' + echo '' + echo ' -h Show this message' } main() { @@ -130,14 +132,17 @@ main() { CHROOTCOPY=$LIBREUSER [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy + makepkg_args=(-s --noconfirm -L) REPACKAGE=false + MAKEPKG=makepkg - while getopts 'hRn:l:' arg ; do + while getopts 'n:l:m:Rh' arg ; do case "${arg}" in n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; - R) REPACKAGE=true; makepkg_args+=(-R) ;; + m) MAKEPKG=$OPTARG;; + R) REPACKAGE=true; makepkg_args+=(-R);; h) usage; exit 0;; *) usage; exit 1;; esac diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2 index 8ca60e0..1f2d185 100755 --- a/src/chroot-tools/libremakepkg.gpl2 +++ b/src/chroot-tools/libremakepkg.gpl2 @@ -69,7 +69,7 @@ chroot_extract() { echo '. /etc/profile' >> "$file" echo 'export HOME=/build' >> "$file" echo 'cd /build' >> "$file" - echo "sudo -u nobody ${MAKEPKG:-makepkg} $makepkg_args -o" >> "$file" + echo "sudo -u nobody ${MAKEPKG} $makepkg_args -o" >> "$file" chmod 755 "$file" archroot "$copydir" -r /chrootextract } @@ -80,7 +80,7 @@ chroot_build() { echo '. /etc/profile' >> "$file" echo 'export HOME=/build' >> "$file" echo 'cd /build' >> "$file" - echo "sudo -u nobody ${MAKEPKG:-makepkg} $makepkg_args -e" >> "$file" + echo "sudo -u nobody ${MAKEPKG} $makepkg_args -e" >> "$file" chmod 755 "$file" archroot -N "$copydir" -r /chrootbuild } -- cgit v1.2.3-54-g00ecf From 01d928f223a23f28af04dc1cdfcfd62ed6cc3f61 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 22:08:56 -0500 Subject: improve libremakepkg's help message --- src/chroot-tools/libremakepkg | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index b6c84c1..b9107d8 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -111,20 +111,20 @@ libre_check_pkg() { # The main program ############################################################# +cmd=${0##*/} usage() { - echo 'cd to a dir containing a PKGBUILD and run:' - echo '$0 [options] [-- makepkg args]' - echo 'This script will build your package in a chroot.' + echo "Usage: $cmd [options] [-- makepkg args]" + echo 'This program will build your package.' echo '' echo 'OPTIONS:' - echo " -n Use this chroot instead of \`$CHROOT'" - echo ' -l Use this chroot copy instead of basing it' - echo ' on the username' + echo " -n Use this chroot instead of \`$CHROOT'" + echo ' -l Use this chroot copy instead of basing it' + echo ' on the username' echo '' - echo " -m Use the command MAKEPKG instead of 'makepkg'" - echo " -R Repackage" + echo " -m Use the command MAKEPKG instead of 'makepkg'" + echo " -R Repackage" echo '' - echo ' -h Show this message' + echo ' -h Show this message' } main() { -- cgit v1.2.3-54-g00ecf From 06f10b87d16d4c83016ff3ef21217494f921d93b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 22:10:26 -0500 Subject: many fixes --- src/chroot-tools/librechroot | 14 +++++++++----- src/chroot-tools/libremakepkg | 14 +++++++------- src/chroot-tools/libremakepkg.gpl2 | 1 + src/chroot-tools/libremkchroot | 6 +++--- src/libretools.conf | 4 ++-- 5 files changed, 22 insertions(+), 17 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index e39b105..d43ea2f 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -51,6 +51,7 @@ sync() { lock_close 8 } +cmd=${0##*/} usage() { echo "Usage: $cmd [OPTIONS] [CHROOT] " echo 'Interacts with a chroot.' @@ -80,7 +81,7 @@ main() { [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy local mode=enter - local archroot_args=() + local archroot_args=(-f) local ARG='' while getopts 'l:NCcI:i:nrsuh' arg; do case $arg in @@ -90,7 +91,7 @@ main() { C) mode=clean_repo;; c) mode=clean_pacman;; I) mode=install_file; ARG=$OPTARG;; - I) mode=install_pkg; ARG=$OPTARG;; + i) mode=install_pkg; ARG=$OPTARG;; n) mode=noop;; r) mode=run; ARG=$OPTARG;; s) mode=sync;; @@ -118,7 +119,7 @@ main() { # Keep this lock as long as we are running # Note that '9' is the same FD number as in (mk)archroot - lock_open_write 9 "$copydir" "Locking chroot copy '$copy'" + lock_open_write 9 "$copydir" "Locking chroot copy '$CHROOTCOPY'" if [[ ! -d $rootdir ]]; then libremkchroot "$CHROOT" @@ -139,8 +140,11 @@ main() { clean_pacman) msg "Intelligently cleaning packages" cp -a "$(dirname $0)/chcleanup" "${copydir}/clean" - mkdir -p "$copydir/build" - archroot "${archroot_args[@]}" "${copydir}" -r "cd /build; /clean" + echo '#!/bin/bash' > "${copydir}/cleanstrap" + echo 'mkdir /build' >> "${copydir}/cleanstrap" + echo 'cd /build; /clean' >> "${copydir}/cleanstrap" + chmod 755 "${copydir}/cleanstrap" + archroot "${archroot_args[@]}" "${copydir}" -r /cleanstrap ;; install_file) msg "Installing package file: $ARG" diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index b9107d8..f06bb17 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -62,10 +62,10 @@ makepkg_conf_get() { if [[ -f $LIBREHOME/.makepkg.conf ]]; then eval $(grep "^$setting=" "$LIBREHOME/.makepkg.conf") fi - if [[ -z ${!setting} ]]; then + if [[ -z ${!setting:-} ]]; then eval $(grep "^$setting=" "/etc/makepkg.conf") fi - if [[ -z ${!setting} && -n ${2} ]]; then + if [[ -z ${!setting:-} && -n ${2} ]]; then eval "$setting='$2'" fi } @@ -78,7 +78,7 @@ chroot_makepkg_conf_get() { chroot_makepkg_conf_set() { local key=$1 local val=$2 - sed -i "/^$KEY=/d" "$copydir/etc/makepkg.conf" + sed -i "/^$key=/d" "$copydir/etc/makepkg.conf" echo "$key='$val'" >> "$copydir/etc/makepkg.conf" } @@ -133,7 +133,7 @@ main() { CHROOTCOPY=$LIBREUSER [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy - makepkg_args=(-s --noconfirm -L) + makepkg_args='-s --noconfirm -L ' REPACKAGE=false MAKEPKG=makepkg @@ -142,14 +142,14 @@ main() { n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; m) MAKEPKG=$OPTARG;; - R) REPACKAGE=true; makepkg_args+=(-R);; + R) REPACKAGE=true; makepkg_args+=' -R ';; h) usage; exit 0;; *) usage; exit 1;; esac done shift $(($OPTIND - 1)) # Pass all arguments after -- right to makepkg - makepkg_args+=("$@") + makepkg_args+=" $*" rootdir="${CHROOTDIR}/${CHROOT}/root" copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" @@ -176,7 +176,7 @@ main() { # OK, we're starting now ############################################### - lock_open_write 9 "$copydir.lock" "Locking chroot '$copy'" + lock_open_write 9 "$copydir" "Locking chroot '$CHROOTCOPY'" # Set target CARCH as it might be used within the PKGBUILD to select correct sources chroot_makepkg_conf_get CARCH diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2 index 1f2d185..cd279b8 100755 --- a/src/chroot-tools/libremakepkg.gpl2 +++ b/src/chroot-tools/libremakepkg.gpl2 @@ -37,6 +37,7 @@ chroot_extract() { rm -rf "$copydir"/build/* cp PKGBUILD "$copydir/build/" ( + set +euE source PKGBUILD # Copy source files diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index 992c6e5..d3652a5 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -euE # libremkchroot # Copyright 2011, 2012 Luke Shumaker @@ -37,7 +37,7 @@ usage() { } main() { - archroot_args=(); + archroot_args=(-f); while getopts 'hC:M:' arg; do case "$arg" in C|M) archroot_args+=("-$arg" "$OPTARG");; @@ -59,7 +59,7 @@ main() { fi mkdir -p "${CHROOTDIR}/${CHROOT}" - archroot "${chroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}" + archroot "${archroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}" } main "$@" diff --git a/src/libretools.conf b/src/libretools.conf index 20c7d90..91ec452 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -108,8 +108,8 @@ TORUPATH=/var/lib/libretools/toru ################################################################################ LIBREUSER="${SUDO_USER:-$USER}" -LIBREHOME="$(eval echo ~$SUDO_USER)" -if [[ -z $XDG_CONFIG_HOME ]]; then +LIBREHOME="$(eval echo ~$LIBREUSER)" +if [[ -z ${XDG_CONFIG_HOME:-} ]]; then export XDG_CONFIG_HOME="${LIBREHOME}/.config" fi if [[ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]]; then -- cgit v1.2.3-54-g00ecf From b9dbed0ae6709351dd244c87581c2d558a9d129f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 16:12:37 -0500 Subject: libremakepkg: fix bug in makepkg_conf_get --- src/chroot-tools/libremakepkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index f06bb17..deb26b2 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -65,7 +65,7 @@ makepkg_conf_get() { if [[ -z ${!setting:-} ]]; then eval $(grep "^$setting=" "/etc/makepkg.conf") fi - if [[ -z ${!setting:-} && -n ${2} ]]; then + if [[ -z ${!setting:-} && -n ${2:-} ]]; then eval "$setting='$2'" fi } -- cgit v1.2.3-54-g00ecf From b81efba931aae92fa7cfafb0f2d070ba203a86f2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 16:14:26 -0500 Subject: libremakepkg: forget -R --- src/chroot-tools/libremakepkg | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index deb26b2..4b49931 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -122,7 +122,6 @@ usage() { echo ' on the username' echo '' echo " -m Use the command MAKEPKG instead of 'makepkg'" - echo " -R Repackage" echo '' echo ' -h Show this message' } @@ -134,7 +133,6 @@ main() { [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy makepkg_args='-s --noconfirm -L ' - REPACKAGE=false MAKEPKG=makepkg while getopts 'n:l:m:Rh' arg ; do @@ -142,7 +140,6 @@ main() { n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; m) MAKEPKG=$OPTARG;; - R) REPACKAGE=true; makepkg_args+=' -R ';; h) usage; exit 0;; *) usage; exit 1;; esac @@ -183,11 +180,13 @@ main() { export CARCH chroot_init + libre_check_pkgbuild - $REPACKAGE || chroot_extract + chroot_extract libre_check_src chroot_build libre_check_pkg + copy_pkgs copy_logs } -- cgit v1.2.3-54-g00ecf From de74c8b50e734128f4641a20e3c4812713366f40 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 16:14:49 -0500 Subject: libremakepkg: match makepkg's error message if PKGBUILD does not exist --- src/chroot-tools/libremakepkg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 4b49931..4e810d1 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -159,7 +159,8 @@ main() { fi if [[ ! -f PKGBUILD ]]; then - error "This must be run in a directory containing a PKGBUILD" + # This is the message used by makepkg + error "PKGBUILD does not exist" exit 1 fi -- cgit v1.2.3-54-g00ecf