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