From 547bd24884bbf044947620330783fcf09d81256b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Fri, 24 Jun 2011 17:10:46 -0500 Subject: Libremakepkg uses new cleaning mode --- libremakepkg | 114 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 84 insertions(+), 30 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index 2226f81..dfcdbe0 100755 --- a/libremakepkg +++ b/libremakepkg @@ -20,30 +20,65 @@ # along with Parabola. If not, see . source /etc/libretools.conf +source /etc/makepkg.conf function usage { - 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 '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 'OPTIONS:' echo - echo " -h : show this message." - echo " -c : cleans CHCOPY before building." - echo " -u : updates CHROOT before building." - echo " -n : use this dir instead of CHCOPY." - echo " -M \"makepkg long arg\" : passes long args to makepkg, use it as many times as needed." - echo " -I pkgname : install this package, use it as many times needed." + 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 "${CHCOPY}".' + echo ' -I install this package, use it as many times needed.' + echo ' -M <--arg> passes long args to makepkg, use it as many times as needed.' echo } -_CLEAN="" +function buildenv { + msg "Building env" + for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do + msg2 "binding /$mp" + mkdir -p "${CHROOTDIR}/${CHCOPY}${mp}" + mount -o bind ${mp} "${CHROOTDIR}/${CHCOPY}${mp}" || exit 1 + done + + for config in etc/makepkg.conf etc/pacman.conf etc/mtab; do + msg2 "copying config /$etc" + cp --remove-destination /$etc $CHROOTDIR/$CHCOPY/$etc || exit 1 + done +} + +# End inmediately but print a useful message +trap_exit() { + + for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do + umount "${CHROOTDIR}/${CHCOPY}${mp}" + done + + error "$@" + + exit 1 +} + +## Trap signals +# From makepkg +set -E +trap 'trap_exit "TERM signal caught. Exiting..."' TERM HUP QUIT +trap 'trap_exit "Aborted by user! Exiting..."' INT +trap 'trap_exit "An unknown error has occurred. Exiting..."' ERR + +CLEAN_FIRST="n" CLEAN_CACHE="" -update_first="n" -use_log='n' -chrootname=${CHCOPY} -_PKGINSTALL="" -_MAKEPKG_ARGS="" +UPDATE_FIRST="n" +USE_LOG='n' +CHROOTNAME=${CHCOPY} +PKGINSTALL="" +MAKEPKG_ARGS="" + #libremakepkg own args libremakepkgargs='hcun:I:M:' #now makepkg args @@ -52,44 +87,63 @@ libremakepkgargs+='ACdefiLmop:rRs' while getopts ${libremakepkgargs} arg ; do case "${arg}" in h) usage; exit 0 ;; - c) _CLEAN="-c" ;; + c) CLEAN_FIRST="y" ;; u) update_first="y" ;; n) chrootname="$OPTARG"; echo $chrootname ;; - I) _PKGINSTALL+="-I $OPTARG " ;; - M) _MAKEPKG_ARGS+=" $OPTARG" ;; - L) _MAKEPKG_ARGS+=" -$arg $OPTARG" + I) PKGINSTALL+="-I $OPTARG " ;; + M) MAKEPKG_ARGS+=" $OPTARG" ;; + L) MAKEPKG_ARGS+=" -$arg $OPTARG" use_log='y';; - *) _MAKEPKG_ARGS+=" -$arg $OPTARG" ;; + *) MAKEPKG_ARGS+=" -$arg $OPTARG" ;; esac done -if [ ! -w / ]; then +if [ ${UID} -ne 0 ]; then error "This script must be run as root" exit 1 fi msg "Checking PKGBUILD for non-free issues" pkgbuild-check-nonfree ||{ -# pkgbuild-check-nonfree uses 15 for nonfree and -# other errors if something failed. - if [[ $? -eq 15 ]]; then + if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree error "PKGBUILD contains non-free issues" exit 15 fi } -if [ $update_first = y ]; then - msg "Updating the main chroot" +if [ "${UPDATE_FIRST}" = y ]; then + msg "Updating the chroot in use" # -c option in mkarchroot indicates cache - mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOT}" + mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}" + +elif [ "${CLEAN_FIRST}" = y ]; then + msg "Cleaning ..." + cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root" + (cat < "${CHROOTDIR}/${CHROOTNAME}/clean" + mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" + +elif [ -n ${PKGINSTALL} ]; then + msg "Installing packages" + makechrootpkg -r ${PKGINSTALL} fi +buildenv msg "Creating the package" -makechrootpkg $_CLEAN -r ${CHROOTDIR} -l "${chrootname}" $_PKGINSTALL -- $_MAKEPKG_ARGS +makechrootpkg -r ${CHROOTDIR} -l "${chrootname}" -- ${MAKEPKG_ARGS} ev=$? # exit value -[ "$use_log" == 'y' -a -e ${CHROOTDIR}/${chrootname}/build/*.log ] && { +[ "${USE_LOG}" == 'y' -a -e ${CHROOTDIR}/${chrootname}/build/*.log ] && { cp ${CHROOTDIR}/${chrootname}/build/*.log ./ } + exit $ev -- cgit v1.2.3-2-g168b From 7499b4f620b052e7ced69972a0ad368cb648f2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Wed, 22 Jun 2011 03:23:26 -0500 Subject: Fixed libremakepkg error --- libremakepkg | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index dfcdbe0..d98d94a 100755 --- a/libremakepkg +++ b/libremakepkg @@ -115,8 +115,9 @@ if [ "${UPDATE_FIRST}" = y ]; then msg "Updating the chroot in use" # -c option in mkarchroot indicates cache mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}" +fi -elif [ "${CLEAN_FIRST}" = y ]; then +if [ "${CLEAN_FIRST}" = y ]; then msg "Cleaning ..." cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root" (cat < "${CHROOTDIR}/${CHROOTNAME}/clean" mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" -elif [ -n ${PKGINSTALL} ]; then +fi + +if [ -n ${PKGINSTALL} ]; then msg "Installing packages" - makechrootpkg -r ${PKGINSTALL} + makechrootpkg -r ${PKGINSTALL} "${CHROOTDIR}/${CHROOTNAME}" fi buildenv -- cgit v1.2.3-2-g168b From 6d9ddde00888d6edbfc9fd1fb56bb9b3709d1356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Wed, 22 Jun 2011 03:34:43 -0500 Subject: libremakepkg anounces error is from it. --- libremakepkg | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index d98d94a..1b0776b 100755 --- a/libremakepkg +++ b/libremakepkg @@ -67,9 +67,9 @@ trap_exit() { ## Trap signals # From makepkg set -E -trap 'trap_exit "TERM signal caught. Exiting..."' TERM HUP QUIT -trap 'trap_exit "Aborted by user! Exiting..."' INT -trap 'trap_exit "An unknown error has occurred. Exiting..."' ERR +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="" @@ -108,6 +108,8 @@ pkgbuild-check-nonfree ||{ if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree error "PKGBUILD contains non-free issues" exit 15 + else + true fi } @@ -119,7 +121,7 @@ fi if [ "${CLEAN_FIRST}" = y ]; then msg "Cleaning ..." - cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root" + cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/" (cat < Date: Wed, 22 Jun 2011 03:51:20 -0500 Subject: eliminated function "install" --- libremakepkg | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index 1b0776b..98adb80 100755 --- a/libremakepkg +++ b/libremakepkg @@ -33,7 +33,6 @@ function usage { echo ' -c cleans the chroot before building.' echo ' -u updates the chroot before building.' echo ' -n use this dir instead of "${CHCOPY}".' - echo ' -I install this package, use it as many times needed.' echo ' -M <--arg> passes long args to makepkg, use it as many times as needed.' echo } @@ -41,14 +40,14 @@ function usage { function buildenv { msg "Building env" for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do - msg2 "binding /$mp" + msg2 "binding ${mp} to ${CHROOTDIR}/${CHCOPY}${mp}" mkdir -p "${CHROOTDIR}/${CHCOPY}${mp}" mount -o bind ${mp} "${CHROOTDIR}/${CHCOPY}${mp}" || exit 1 done for config in etc/makepkg.conf etc/pacman.conf etc/mtab; do - msg2 "copying config /$etc" - cp --remove-destination /$etc $CHROOTDIR/$CHCOPY/$etc || exit 1 + msg2 "copying config /$config to ${CHROOTDIR}/${CHCOPY}/${config}" + cp --remove-destination /${config} ${CHROOTDIR}/${CHCOPY}/${config} || exit 1 done } @@ -76,7 +75,6 @@ CLEAN_CACHE="" UPDATE_FIRST="n" USE_LOG='n' CHROOTNAME=${CHCOPY} -PKGINSTALL="" MAKEPKG_ARGS="" #libremakepkg own args @@ -88,12 +86,11 @@ while getopts ${libremakepkgargs} arg ; do case "${arg}" in h) usage; exit 0 ;; c) CLEAN_FIRST="y" ;; - u) update_first="y" ;; + u) UPDATE_FIRST="y" ;; n) chrootname="$OPTARG"; echo $chrootname ;; - I) PKGINSTALL+="-I $OPTARG " ;; M) MAKEPKG_ARGS+=" $OPTARG" ;; L) MAKEPKG_ARGS+=" -$arg $OPTARG" - use_log='y';; + USE_LOG='y';; *) MAKEPKG_ARGS+=" -$arg $OPTARG" ;; esac done @@ -113,14 +110,17 @@ pkgbuild-check-nonfree ||{ fi } +buildenv + if [ "${UPDATE_FIRST}" = y ]; then - msg "Updating the chroot in use" + msg "Updating the chroot in use..." # -c option in mkarchroot indicates cache mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}" fi if [ "${CLEAN_FIRST}" = y ]; then msg "Cleaning ..." + plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/" cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/" (cat < "${CHROOTDIR}/${CHROOTNAME}/clean" - mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" - -fi + mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" -if [ -n ${PKGINSTALL} ]; then - msg "Installing packages" - makechrootpkg -r ${PKGINSTALL} "${CHROOTDIR}/${CHROOTNAME}" fi -buildenv - msg "Creating the package" makechrootpkg -r ${CHROOTDIR} -l "${chrootname}" -- ${MAKEPKG_ARGS} ev=$? # exit value -- cgit v1.2.3-2-g168b From f54dd21db22dc09f72a67101f3d83d64c21fc404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Wed, 22 Jun 2011 04:00:06 -0500 Subject: *fixed error in making clean script --- libremakepkg | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index 98adb80..babed47 100755 --- a/libremakepkg +++ b/libremakepkg @@ -119,28 +119,29 @@ if [ "${UPDATE_FIRST}" = y ]; then fi if [ "${CLEAN_FIRST}" = y ]; then - msg "Cleaning ..." + msg "Cleaning" plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/" - cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/" + cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem" (cat < "${CHROOTDIR}/${CHROOTNAME}/clean" + echo -n "doing cleanup..." mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" fi msg "Creating the package" -makechrootpkg -r ${CHROOTDIR} -l "${chrootname}" -- ${MAKEPKG_ARGS} +makechrootpkg -r ${CHROOTDIR} -l "${CHROOTNAME}" -- ${MAKEPKG_ARGS} ev=$? # exit value -[ "${USE_LOG}" == 'y' -a -e ${CHROOTDIR}/${chrootname}/build/*.log ] && { +[ "${USE_LOG}" == 'y' -a -e ${CHROOTDIR}/${CHROOTNAME}/build/*.log ] && { cp ${CHROOTDIR}/${chrootname}/build/*.log ./ } -- cgit v1.2.3-2-g168b From 69335b6ff0342a2d3201158b9a18010c57cbcf26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Sun, 26 Jun 2011 18:07:53 -0500 Subject: libremakepkg cleans better rePKGBUILD.proto finds links and delete them --- libremakepkg | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index babed47..e446833 100755 --- a/libremakepkg +++ b/libremakepkg @@ -51,6 +51,32 @@ function buildenv { done } +# Clean packages with pacman +function clean_chroot { + plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/" + cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem" + (cat < "${CHROOTDIR}/${CHROOTNAME}/clean" + mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" +} + # End inmediately but print a useful message trap_exit() { @@ -120,21 +146,7 @@ fi if [ "${CLEAN_FIRST}" = y ]; then msg "Cleaning" - plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/" - cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem" - (cat < "${CHROOTDIR}/${CHROOTNAME}/clean" - echo -n "doing cleanup..." - mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" - + clean_chroot fi msg "Creating the package" -- cgit v1.2.3-2-g168b From 75f8632e677bd11bb88be037aa6aab32a79ab008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Mon, 27 Jun 2011 14:17:50 -0500 Subject: some fixes --- libremakepkg | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index e446833..b8d8c9a 100755 --- a/libremakepkg +++ b/libremakepkg @@ -32,6 +32,7 @@ function usage { echo ' -h show this message.' echo ' -c cleans the chroot before building.' echo ' -u updates the chroot before building.' + echo ' -U copy pacman, makepkg, and mtag config files to the chroot' echo ' -n use this dir instead of "${CHCOPY}".' echo ' -M <--arg> passes long args to makepkg, use it as many times as needed.' echo @@ -44,11 +45,13 @@ function buildenv { mkdir -p "${CHROOTDIR}/${CHCOPY}${mp}" mount -o bind ${mp} "${CHROOTDIR}/${CHCOPY}${mp}" || exit 1 done - - for config in etc/makepkg.conf etc/pacman.conf etc/mtab; do - msg2 "copying config /$config to ${CHROOTDIR}/${CHCOPY}/${config}" - cp --remove-destination /${config} ${CHROOTDIR}/${CHCOPY}/${config} || exit 1 - done + + if [ "$update_config" = 'y']; then + for config in etc/makepkg.conf etc/pacman.conf etc/mtab; do + msg2 "copying config /$config to ${CHROOTDIR}/${CHCOPY}/${config}" + cp --remove-destination /${config} ${CHROOTDIR}/${CHCOPY}/${config} || exit 1 + done + fi } # Clean packages with pacman @@ -74,6 +77,7 @@ while [ "\$clean" = 'false' ]; do done EOF ) > "${CHROOTDIR}/${CHROOTNAME}/clean" + chmod +x "${CHROOTDIR}/${CHROOTNAME}/clean" mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" } @@ -102,9 +106,10 @@ UPDATE_FIRST="n" USE_LOG='n' CHROOTNAME=${CHCOPY} MAKEPKG_ARGS="" +update_config='n' #libremakepkg own args -libremakepkgargs='hcun:I:M:' +libremakepkgargs='hcuUn:I:M:' #now makepkg args libremakepkgargs+='ACdefiLmop:rRs' @@ -113,7 +118,8 @@ while getopts ${libremakepkgargs} arg ; do h) usage; exit 0 ;; c) CLEAN_FIRST="y" ;; u) UPDATE_FIRST="y" ;; - n) chrootname="$OPTARG"; echo $chrootname ;; + U) update_config='y' + n) CHROOTNAME="$OPTARG" ;; M) MAKEPKG_ARGS+=" $OPTARG" ;; L) MAKEPKG_ARGS+=" -$arg $OPTARG" USE_LOG='y';; @@ -150,7 +156,7 @@ if [ "${CLEAN_FIRST}" = y ]; then fi msg "Creating the package" -makechrootpkg -r ${CHROOTDIR} -l "${CHROOTNAME}" -- ${MAKEPKG_ARGS} +makechrootpkg -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS} ev=$? # exit value [ "${USE_LOG}" == 'y' -a -e ${CHROOTDIR}/${CHROOTNAME}/build/*.log ] && { -- cgit v1.2.3-2-g168b From f303abe1eb26dd9037824889dc3c02df74ed9fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Mon, 27 Jun 2011 18:46:24 -0500 Subject: libremakepkg uses find to copy logs and has no trailing space --- libremakepkg | 84 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index b8d8c9a..b2f8aa8 100755 --- a/libremakepkg +++ b/libremakepkg @@ -3,32 +3,32 @@ # 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 . + +# 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 . source /etc/libretools.conf source /etc/makepkg.conf function usage { - echo 'cd to a dir containing a PKGBUILD and run:' + 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 echo ' -h show this message.' echo ' -c cleans the chroot before building.' echo ' -u updates the chroot before building.' @@ -45,8 +45,8 @@ function buildenv { mkdir -p "${CHROOTDIR}/${CHCOPY}${mp}" mount -o bind ${mp} "${CHROOTDIR}/${CHCOPY}${mp}" || exit 1 done - - if [ "$update_config" = 'y']; then + + if [ "$update_config" = 'y' ] ; then for config in etc/makepkg.conf etc/pacman.conf etc/mtab; do msg2 "copying config /$config to ${CHROOTDIR}/${CHCOPY}/${config}" cp --remove-destination /${config} ${CHROOTDIR}/${CHCOPY}/${config} || exit 1 @@ -78,19 +78,19 @@ done EOF ) > "${CHROOTDIR}/${CHROOTNAME}/clean" chmod +x "${CHROOTDIR}/${CHROOTNAME}/clean" - mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" -} + mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" +} # End inmediately but print a useful message trap_exit() { - - for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do - umount "${CHROOTDIR}/${CHCOPY}${mp}" - done - error "$@" + for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do + umount "${CHROOTDIR}/${CHCOPY}${mp}" + done - exit 1 + error "$@" + + exit 1 } ## Trap signals @@ -115,15 +115,15 @@ libremakepkgargs+='ACdefiLmop:rRs' while getopts ${libremakepkgargs} arg ; do case "${arg}" in - h) usage; exit 0 ;; - c) CLEAN_FIRST="y" ;; - u) UPDATE_FIRST="y" ;; - U) update_config='y' - n) CHROOTNAME="$OPTARG" ;; - M) MAKEPKG_ARGS+=" $OPTARG" ;; - L) MAKEPKG_ARGS+=" -$arg $OPTARG" + h) usage; exit 0 ;; + c) CLEAN_FIRST="y" ;; + u) UPDATE_FIRST="y" ;; + U) update_config='y' ;; + n) CHROOTNAME="$OPTARG" ;; + M) MAKEPKG_ARGS+=" $OPTARG" ;; + L) MAKEPKG_ARGS+=" -$arg $OPTARG" USE_LOG='y';; - *) MAKEPKG_ARGS+=" -$arg $OPTARG" ;; + *) MAKEPKG_ARGS+=" -$arg $OPTARG" ;; esac done @@ -135,8 +135,8 @@ fi msg "Checking PKGBUILD for non-free issues" pkgbuild-check-nonfree ||{ if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree - error "PKGBUILD contains non-free issues" - exit 15 + error "PKGBUILD contains non-free issues" + exit 15 else true fi @@ -144,23 +144,23 @@ pkgbuild-check-nonfree ||{ buildenv -if [ "${UPDATE_FIRST}" = y ]; then +if [ "${UPDATE_FIRST}" = 'y' ]; then msg "Updating the chroot in use..." # -c option in mkarchroot indicates cache mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}" fi -if [ "${CLEAN_FIRST}" = y ]; then +if [ "${CLEAN_FIRST}" = 'y' ]; then msg "Cleaning" clean_chroot fi msg "Creating the package" -makechrootpkg -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS} +makechrootpkg -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS}" ev=$? # exit value -[ "${USE_LOG}" == 'y' -a -e ${CHROOTDIR}/${CHROOTNAME}/build/*.log ] && { - cp ${CHROOTDIR}/${chrootname}/build/*.log ./ +if [ "${USE_LOG}" == 'y' ]; then + find ${CHROOTDIR}/${CHROOTNAME}/build/ -name "*\.log" -exec cp {} ./ \; } exit $ev -- cgit v1.2.3-2-g168b From 6633c1d07a2b408dd74ad909326a54f94b2fdfdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Tue, 28 Jun 2011 15:14:32 -0500 Subject: libremakepkg does not update config --- libremakepkg | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index b2f8aa8..0baaed2 100755 --- a/libremakepkg +++ b/libremakepkg @@ -32,7 +32,6 @@ function usage { echo ' -h show this message.' echo ' -c cleans the chroot before building.' echo ' -u updates the chroot before building.' - echo ' -U copy pacman, makepkg, and mtag config files to the chroot' echo ' -n use this dir instead of "${CHCOPY}".' echo ' -M <--arg> passes long args to makepkg, use it as many times as needed.' echo @@ -40,18 +39,11 @@ function usage { function buildenv { msg "Building env" - for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do + for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST}; do msg2 "binding ${mp} to ${CHROOTDIR}/${CHCOPY}${mp}" mkdir -p "${CHROOTDIR}/${CHCOPY}${mp}" mount -o bind ${mp} "${CHROOTDIR}/${CHCOPY}${mp}" || exit 1 done - - if [ "$update_config" = 'y' ] ; then - for config in etc/makepkg.conf etc/pacman.conf etc/mtab; do - msg2 "copying config /$config to ${CHROOTDIR}/${CHCOPY}/${config}" - cp --remove-destination /${config} ${CHROOTDIR}/${CHCOPY}/${config} || exit 1 - done - fi } # Clean packages with pacman @@ -81,6 +73,13 @@ EOF mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" } +copy_log() { + if [ "${USE_LOG}" == 'y' ]; then + find ${CHROOTDIR}/${CHROOTNAME}/build/ -name "*\.log" -exec cp {} ./ \; + fi +} + + # End inmediately but print a useful message trap_exit() { @@ -88,6 +87,8 @@ trap_exit() { umount "${CHROOTDIR}/${CHCOPY}${mp}" done + copy_log + error "$@" exit 1 @@ -106,7 +107,6 @@ UPDATE_FIRST="n" USE_LOG='n' CHROOTNAME=${CHCOPY} MAKEPKG_ARGS="" -update_config='n' #libremakepkg own args libremakepkgargs='hcuUn:I:M:' @@ -118,7 +118,6 @@ while getopts ${libremakepkgargs} arg ; do h) usage; exit 0 ;; c) CLEAN_FIRST="y" ;; u) UPDATE_FIRST="y" ;; - U) update_config='y' ;; n) CHROOTNAME="$OPTARG" ;; M) MAKEPKG_ARGS+=" $OPTARG" ;; L) MAKEPKG_ARGS+=" -$arg $OPTARG" @@ -159,8 +158,6 @@ msg "Creating the package" makechrootpkg -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS}" ev=$? # exit value -if [ "${USE_LOG}" == 'y' ]; then - find ${CHROOTDIR}/${CHROOTNAME}/build/ -name "*\.log" -exec cp {} ./ \; -} +copy_log exit $ev -- cgit v1.2.3-2-g168b From 207a930a564e8157e24c3e7f5fbe987494b73d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Tue, 28 Jun 2011 21:23:49 -0500 Subject: * Cleanup code + arch specific separated --- libremakepkg | 85 +++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 30 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index 0baaed2..13e7617 100755 --- a/libremakepkg +++ b/libremakepkg @@ -22,7 +22,8 @@ source /etc/libretools.conf source /etc/makepkg.conf -function usage { +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.' @@ -35,19 +36,22 @@ function usage { echo ' -n use this dir instead of "${CHCOPY}".' echo ' -M <--arg> passes long args to makepkg, use it as many times as needed.' echo + exit 1 } -function buildenv { +function buildenv { # Mounts *DEST from makepkg.conf + msg "Building env" for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST}; do msg2 "binding ${mp} to ${CHROOTDIR}/${CHCOPY}${mp}" mkdir -p "${CHROOTDIR}/${CHCOPY}${mp}" mount -o bind ${mp} "${CHROOTDIR}/${CHCOPY}${mp}" || exit 1 done + } -# Clean packages with pacman -function clean_chroot { +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" (cat < "${CHROOTDIR}/${CHROOTNAME}/clean" chmod +x "${CHROOTDIR}/${CHROOTNAME}/clean" mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" + } -copy_log() { +function copy_log { # copy logs if they exist + if [ "${USE_LOG}" == 'y' ]; then find ${CHROOTDIR}/${CHROOTNAME}/build/ -name "*\.log" -exec cp {} ./ \; fi + } +function trap_exit { # End inmediately but print a useful message -# End inmediately but print a useful message -trap_exit() { +# args are treated as part of the message - for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do + for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST}; do umount "${CHROOTDIR}/${CHCOPY}${mp}" done @@ -94,8 +101,7 @@ trap_exit() { exit 1 } -## Trap signals -# From makepkg +# 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 @@ -108,14 +114,12 @@ USE_LOG='n' CHROOTNAME=${CHCOPY} MAKEPKG_ARGS="" -#libremakepkg own args -libremakepkgargs='hcuUn:I:M:' -#now makepkg args -libremakepkgargs+='ACdefiLmop:rRs' +libremakepkgargs='hcuUn:I:M:' # libremakepkg own args +libremakepkgargs+='ACdefiLmop:rRs' # makepkg args while getopts ${libremakepkgargs} arg ; do case "${arg}" in - h) usage; exit 0 ;; + h) usage ;; c) CLEAN_FIRST="y" ;; u) UPDATE_FIRST="y" ;; n) CHROOTNAME="$OPTARG" ;; @@ -131,32 +135,53 @@ if [ ${UID} -ne 0 ]; then exit 1 fi +if [ ! -r 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" -pkgbuild-check-nonfree ||{ - if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree +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 fi -} -buildenv - -if [ "${UPDATE_FIRST}" = 'y' ]; then - msg "Updating the chroot in use..." -# -c option in mkarchroot indicates cache - mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}" fi -if [ "${CLEAN_FIRST}" = 'y' ]; then - msg "Cleaning" - clean_chroot -fi +buildenv msg "Creating the package" -makechrootpkg -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS}" -ev=$? # exit value +if [ -d "${CHROOTDIR}/${CHROOTNAME}" ]; then # use chroot + + if [ "${UPDATE_FIRST}" = 'y' ]; then + msg "Updating the chroot in use..." + mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}" # -c option is for cache + fi + + if [ "${CLEAN_FIRST}" = 'y' ]; then + msg "Cleaning" + clean_chroot + fi + + makechrootpkg -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS}" + ev=$? # exit value + +else # build new chroot before using + + if [ "${UPDATE_FIRST}" = 'y' ]; then # update CHROOT + msg "Updating the chroot in use..." + mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOT}" # -c option is for cache + fi + + makechrootpkg -c -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS}" + ev=$? # exit value + +fi copy_log -- cgit v1.2.3-2-g168b