From 5f1ef1bd95e2aa1d5b596d929e12e55e8f00f3d2 Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernández Date: Fri, 9 Dec 2011 06:09:22 -0600 Subject: "cleansystem is sorted" --- cleansystem | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'cleansystem') diff --git a/cleansystem b/cleansystem index 8da434b..5aae1df 100644 --- a/cleansystem +++ b/cleansystem @@ -1,13 +1,8 @@ -bzip2 -filesystem -initscripts -licenses-libre -linux-libre -pacman -pacman-mirrorlist-libre -your-freedom +autoconf +automake bash binutils +bison bzip2 coreutils cronie @@ -16,9 +11,13 @@ device-mapper dhcpcd diffutils e2fsprogs +fakeroot file +filesystem findutils +flex gawk +gcc gcc-libs gettext glibc @@ -26,25 +25,36 @@ grep gzip heirloom-mailx inetutils +initscripts iputils jfsutils less libpipeline +libtool +licenses-libre +linux-libre logrotate lvm2 +m4 +make man-db man-pages mdadm nano +pacman +pacman-mirrorlist-libre +patch pciutils pcmciautils perl +pkg-config ppp procps psmisc reiserfsprogs sed shadow +sudo sysfsutils syslog-ng sysvinit @@ -58,15 +68,4 @@ wget which wpa_supplicant xfsprogs -autoconf -automake -bison -fakeroot -flex -gcc -libtool -m4 -make -patch -pkg-config -sudo +your-freedom -- cgit v1.2.3-54-g00ecf From 32b6057b15e4f0872b9ebd51038c72b0d681cb80 Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernández Date: Wed, 21 Dec 2011 13:58:41 -0600 Subject: create cleansystem list every time --- cleansystem | 71 ------------------------------------------------------------ libremakepkg | 4 +++- 2 files changed, 3 insertions(+), 72 deletions(-) delete mode 100644 cleansystem (limited to 'cleansystem') diff --git a/cleansystem b/cleansystem deleted file mode 100644 index 5aae1df..0000000 --- a/cleansystem +++ /dev/null @@ -1,71 +0,0 @@ -autoconf -automake -bash -binutils -bison -bzip2 -coreutils -cronie -cryptsetup -device-mapper -dhcpcd -diffutils -e2fsprogs -fakeroot -file -filesystem -findutils -flex -gawk -gcc -gcc-libs -gettext -glibc -grep -gzip -heirloom-mailx -inetutils -initscripts -iputils -jfsutils -less -libpipeline -libtool -licenses-libre -linux-libre -logrotate -lvm2 -m4 -make -man-db -man-pages -mdadm -nano -pacman -pacman-mirrorlist-libre -patch -pciutils -pcmciautils -perl -pkg-config -ppp -procps -psmisc -reiserfsprogs -sed -shadow -sudo -sysfsutils -syslog-ng -sysvinit -tar -texinfo -udev -usbutils -util-linux -vi -wget -which -wpa_supplicant -xfsprogs -your-freedom 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: 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 --- cleansystem | 119 ++++++++++++++++++++++++++++++++++++++++ librechroot | 127 ++++++++++++++++++++++++++++++++----------- libremakepkg | 174 +++++++++++++++++++---------------------------------------- 3 files changed, 270 insertions(+), 150 deletions(-) create mode 100644 cleansystem (limited to 'cleansystem') diff --git a/cleansystem b/cleansystem new file mode 100644 index 0000000..b91bf86 --- /dev/null +++ b/cleansystem @@ -0,0 +1,119 @@ +acl +attr +autoconf +automake +bash +binutils +bison +bzip2 +cloog +coreutils +cracklib +cronie +cryptsetup +db +dbus-core +device-mapper +dhcpcd +diffutils +e2fsprogs +expat +fakeroot +file +filesystem +findutils +flex +gawk +gcc +gcc-libs +gdbm +gettext +glib2 +glibc +gmp +grep +groff +gzip +heirloom-mailx +iana-etc +inetutils +initscripts +iproute2 +iputils +isl +jfsutils +kbd +keyutils +krb5 +less +libarchive +libcap +libfetch +libffi +libgcrypt +libgpg-error +libgssglue +libldap +libltdl +libmpc +libnl +libpcap +libpipeline +libsasl +libtirpc +libtool +libusb +libusb-compat +licenses-libre +linux-api-headers +linux-libre +logrotate +lvm2 +m4 +make +man-db +man-pages +mdadm +mkinitcpio +mkinitcpio-busybox +module-init-tools +mpfr +nano +ncurses +openssl +pacman +pacman-mirrorlist-libre +pam +patch +pciutils +pcmciautils +pcre +perl +pkg-config +popt +ppl +ppp +procps +psmisc +readline +reiserfsprogs +run-parts +sed +shadow +sudo +sysfsutils +sysvinit +tar +texinfo +tzdata +udev +usbutils +util-linux +vi +wget +which +wpa_supplicant +xfsprogs +xz +your-freedom +zlib diff --git a/librechroot b/librechroot index d3e02f1..31516ac 100755 --- a/librechroot +++ b/librechroot @@ -3,6 +3,7 @@ # Enters a chroot # Copyright 2010 Nicolás Reynolds +# Copyright 2011 Joshua Haase # ---------- GNU General Public License 3 ---------- @@ -21,52 +22,114 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -source /etc/libretools.conf - function usage { - echo "Usage: $0 chrootname" - echo "Change to a chroot in $CHROOTDIR. Use it as root." - 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 "" + } -while getopts 'h' arg; do - case $arg in - h) usage; exit 0 ;; - esac +function clean_chroot { # Clean packages with pacman + + msg "Cleaning chroot: ${CHROOTDIR}/${CHROOTNAME}" + + cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/cleansystem" + (cat < "${CHROOTDIR}/${CHROOTNAME}/clean" -# Enter the chroot copy by default -chrootname=${1:-$CHROOT} -CACHEDIR=${CACHEDIR:-/var/cache/pacman/pkg} + chmod +x "${CHROOTDIR}/${CHROOTNAME}/clean" + mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" -[[ ! -d ${CHROOTDIR}/${chrootname} ]] && { - error "${CHROOTDIR}/${chrootname} is not a dir." - exit 1 + rm "${CHROOTDIR}/${CHROOTNAME}/clean" + rm "${CHROOTDIR}/${CHROOTNAME}/cleansystem" +} + +function clean_repo { + msg "Cleaning repo for chroot: ${CHROOTDIR}/${CHROOTNAME}" + if [ -d "${CHROOTDIR}/${CHROOTNAME}/repo" ]; then + rm -rf "${CHROOTDIR}/${CHROOTNAME}/repo" + fi } +source /etc/libretools.conf -mount -t proc proc ${CHROOTDIR}/${chrootname}/proc/ -mount -t sysfs sys ${CHROOTDIR}/${chrootname}/sys/ -mount -o bind /dev ${CHROOTDIR}/${chrootname}/dev/ +if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then + source "$XDG_CONFIG_HOME/libretools/libretools.conf" +fi -# Share pacman cache -mount -o bind ${CACHEDIR} ${CHROOTDIR}/${chrootname}/var/cache/pacman/pkg +CLEANCHROOT='false' +UPDATE='false' +CLEANREPO='false' +CHROOTNAME="${CHROOT:-${SUDO_USER:-root}}" -cp -L /etc/resolv.conf ${CHROOTDIR}/${chrootname}/etc/resolv.conf +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 -chroot ${CHROOTDIR}/${chrootname} /bin/bash +[[ "$UID" != "0" ]] && { + error "This script must be run as root." + exit 1 +} -umount ${CHROOTDIR}/${chrootname}/proc/ -umount ${CHROOTDIR}/${chrootname}/sys/ -umount ${CHROOTDIR}/${chrootname}/dev/ -umount ${CHROOTDIR}/${chrootname}/var/cache/pacman/pkg +shift $(($OPTIND - 1)) + +if [ $# -eq 1 ]; then + CHROOTNAME="$1" +fi + +if "$CLEANREPO"; then + clean_repo +fi + +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 exit 0 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-54-g00ecf