From 32b6057b15e4f0872b9ebd51038c72b0d681cb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Wed, 21 Dec 2011 13:58:41 -0600 Subject: create cleansystem list every time --- libremakepkg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index 292e4b5..cb71300 100755 --- a/libremakepkg +++ b/libremakepkg @@ -64,7 +64,9 @@ function buildenv { # Mounts *DEST from makepkg.conf function clean_chroot { # Clean packages with pacman plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/" - cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem" + echo "sudo +" > "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem" + pacman -Sgq base base-devel >> "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem" (cat < Date: Thu, 22 Dec 2011 23:27:13 -0300 Subject: Keep base-devel installed. Mount bind to default CacheDir on chroot --- libremakepkg | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index 292e4b5..5a04b4b 100755 --- a/libremakepkg +++ b/libremakepkg @@ -49,15 +49,18 @@ function usage { # Display message and exit function buildenv { # Mounts *DEST from makepkg.conf msg "Building env" - for mp in SRCDEST PKGDEST SRCPKGDEST; do +# for mp in SRCDEST PKGDEST SRCPKGDEST; do # The host system directory - lmp=LOCAL${mp} +# lmp=LOCAL${mp} - msg2 "Binding ${!lmp} to ${CHROOTDIR}/${CHROOT}${!mp}" +# msg2 "Binding ${!lmp} to ${CHROOTDIR}/${CHROOT}${!mp}" - mkdir -p "${CHROOTDIR}/${CHROOT}${!mp}" - mount -o bind ${!lmp} "${CHROOTDIR}/${CHROOT}${!mp}" || exit 1 - done +# mkdir -p "${CHROOTDIR}/${CHROOT}${!mp}" +# mount -o bind ${!lmp} "${CHROOTDIR}/${CHROOT}${!mp}" || exit 1 +# done + + msg2 "Bind ${CACHEDIR} => ${CHROOTDIR}/${CHROOT}/var/cache/pacman/pkg/" + mount -o bind ${CACHEDIR} ${CHROOTDIR}/${CHROOT}/var/cache/pacman/pkg/ } @@ -69,19 +72,14 @@ function clean_chroot { # Clean packages with pacman #!/bin/bash export LANG=C -clean='false' - -while [ "\$clean" = 'false' ]; do - pkgs=(\$(comm -23 <(pacman -Qq | sort) <(sort /root/cleansystem))) if [ \${#pkgs[@]} -gt 0 ]; then pacman --noconfirm -Rcs \${pkgs[@]} + pacman --noconfirm -S --needed base-devel gettext else - clean="true" echo "clean" fi -done EOF ) > "${CHROOTDIR}/${CHROOTNAME}/clean" chmod +x "${CHROOTDIR}/${CHROOTNAME}/clean" -- cgit v1.2.3-2-g168b From 55b66d324fb5b08651606207bec73f4d51525c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Sat, 24 Dec 2011 21:11:03 -0600 Subject: libremakepkg: uses chroot for cleaning librechroot: clean chroot option added (uses pacman) cleansystem: updated list from a clean chroot --- libremakepkg | 174 +++++++++++++++++++---------------------------------------- 1 file changed, 56 insertions(+), 118 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index 2f90cce..7885f1e 100755 --- a/libremakepkg +++ b/libremakepkg @@ -19,97 +19,22 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -source /etc/libretools.conf -source /etc/makepkg.conf - -# Local vars may differ from chroot's -LOCALPKGDEST=${PKGDEST} -LOCALSRCDEST=${SRCDEST} -LOCALSRCPKGDEST=${SRCPKGDEST} - -source ${CHROOTDIR}/${CHROOT}/etc/makepkg.conf - -function usage { # Display message and exit - - echo 'cd to a dir containing a PKGBUILD and run:' - echo '$0 [options] [makepkg args]' - echo 'This script will build your package on a chroot.' - echo - echo 'OPTIONS:' - echo - echo ' -h show this message.' - echo ' -c cleans the chroot before building.' - echo ' -u updates the chroot before building.' - echo ' -n use this dir instead of "${CHROOT}".' - echo ' -M <--arg> passes long args to makepkg, use it as many times as needed.' - echo - exit 1 -} - -function buildenv { # Mounts *DEST from makepkg.conf - - msg "Building env" -# for mp in SRCDEST PKGDEST SRCPKGDEST; do -# The host system directory -# lmp=LOCAL${mp} -# msg2 "Binding ${!lmp} to ${CHROOTDIR}/${CHROOT}${!mp}" - -# mkdir -p "${CHROOTDIR}/${CHROOT}${!mp}" -# mount -o bind ${!lmp} "${CHROOTDIR}/${CHROOT}${!mp}" || exit 1 -# done - - msg2 "Bind ${CACHEDIR} => ${CHROOTDIR}/${CHROOT}/var/cache/pacman/pkg/" - mount -o bind ${CACHEDIR} ${CHROOTDIR}/${CHROOT}/var/cache/pacman/pkg/ - -} - -function clean_chroot { # Clean packages with pacman - - plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/" - echo "sudo -" > "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem" - pacman -Sgq base base-devel >> "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem" - (cat < "${CHROOTDIR}/${CHROOTNAME}/clean" - chmod +x "${CHROOTDIR}/${CHROOTNAME}/clean" - mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" - -} +# set -x # uncomment for debug function copy_log { # copy logs if they exist - if [ "${USE_LOG}" == 'y' ]; then - find ${CHROOTDIR}/${CHROOTNAME}/build/ -name "*\.log" -exec cp {} ./ \; - fi + find "${CHROOTDIR}/${CHROOTNAME}/build/" -name "*\.log" -exec cp {} ./ \; } -function trap_exit { # End inmediately but print a useful message - -# args are treated as part of the message - for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST}; do - umount "${CHROOTDIR}/${CHROOT}${mp}" - done +function trap_exit { # End inmediately but print a useful message copy_log - error "$@" - exit 1 + } # Trap signals from makepkg @@ -118,69 +43,82 @@ 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 -CLEAN_FIRST="n" -CLEAN_CACHE="" -UPDATE_FIRST="n" -USE_LOG='n' -CHROOTNAME=${CHROOT} +source /etc/libretools.conf + +CLEANFIRST="false" +UPDATEFIRST="false" +CHECKNONFREE="true" +LIBRECHROOT_ARGS="" MAKEPKG_ARGS="" -libremakepkgargs='hcuUn:I:M:' # libremakepkg own args -libremakepkgargs+='ACdefiLmop:rRs' # makepkg args +function 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 '' + 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 ${libremakepkgargs} arg ; do +while getopts 'hcud:n:N' arg ; do case "${arg}" in h) usage ;; - c) CLEAN_FIRST="y" ;; - u) UPDATE_FIRST="y" ;; - n) CHROOTNAME="$OPTARG" ;; - M) MAKEPKG_ARGS+=" $OPTARG" ;; - L) MAKEPKG_ARGS+=" -$arg $OPTARG" - USE_LOG='y';; - *) MAKEPKG_ARGS+=" -$arg $OPTARG" ;; + c) CLEANFIRST="true" ;; + u) UPDATEFIRST="true" ;; + d) CHROOTDIR="$OPTARG" + LIBRECHROOT_ARGS='-d "$OPTARG"' ;; + n) CHROOT="$OPTARG" ;; + N) CHECKNONFREE="false" ;; esac done -if [ ${UID} -ne 0 ]; then +# 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 [ ! -r PKGBUILD ]; then # Check if we are actually on a build directory. Do this early. +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 ! pkgbuild-check-nonfree; then - - if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree - error "PKGBUILD contains non-free issues" - exit 15 - else - true +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 -buildenv - -msg "Creating the package" -if [ ! -d "${CHROOTDIR}/${CHROOTNAME}" ]; then # use chroot - mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOT}" # -c option is for cache +if (( CLEANFIRST )); then + librechroot -c "$LIBRECHROOT_ARGS" "$CHROOT" fi -if [ "${CLEAN_FIRST}" = 'y' ]; then - msg "Cleaning" - clean_chroot +if (( UPDATEFIRST )); then + librechroot -u "$LIBRECHROOT_ARGS" "$CHROOT" fi -if [ "${UPDATE_FIRST}" = 'y' ]; then - msg "Updating the chroot in use..." - mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}" # -c option is for cache -fi +unset CLEANFIRST UPDATEFIRST LIBRECHROOT_ARGS -makechrootpkg -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS}" -ev=$? # exit value +makechrootpkg -r "$CHROOTDIR" -l "$CHROOT" "$MAKEPKG_ARGS" +ev="$?" # exit value copy_log -- cgit v1.2.3-2-g168b From fa0b7b6f8e45982f1e2317c386ef0cf49ee840c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Tue, 27 Dec 2011 20:07:08 -0600 Subject: libremakepkg: fixed conditionals toru: -p exit with 1 status if not found --- libremakepkg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index 7885f1e..9af487f 100755 --- a/libremakepkg +++ b/libremakepkg @@ -53,6 +53,7 @@ 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.' @@ -95,7 +96,7 @@ if [ ! -e PKGBUILD ]; then # Check if we are actually on a build directory. Do fi msg "Checking PKGBUILD for non-free issues" -if (( CHECKNONFREE )); then +if "$CHECKNONFREE"; then if ! pkgbuild-check-nonfree; then if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree @@ -107,11 +108,11 @@ if (( CHECKNONFREE )); then fi fi -if (( CLEANFIRST )); then +if "$CLEANFIRST"; then librechroot -c "$LIBRECHROOT_ARGS" "$CHROOT" fi -if (( UPDATEFIRST )); then +if "$UPDATEFIRST"; then librechroot -u "$LIBRECHROOT_ARGS" "$CHROOT" fi -- cgit v1.2.3-2-g168b From cee8f02712f72cb64633ec872a0208995d4c6fc4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 31 Dec 2011 16:39:09 -0500 Subject: Fix renamed variable in libremakepkg (s/CHROOTNAME/CHROOT/) --- libremakepkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index 9af487f..99ab1a4 100755 --- a/libremakepkg +++ b/libremakepkg @@ -24,7 +24,7 @@ function copy_log { # copy logs if they exist - find "${CHROOTDIR}/${CHROOTNAME}/build/" -name "*\.log" -exec cp {} ./ \; + find "${CHROOTDIR}/${CHROOT}/build/" -name "*\.log" -exec cp {} ./ \; } -- cgit v1.2.3-2-g168b