From 1802997b0b3974e22389043d568c28809380fc52 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 16 Feb 2009 17:36:21 +0100 Subject: [PATCH] xbps-src: require sudo to build packages. The reason is that fakeroot can't read files that have restrictive perms and you'd have to change them before the src installation, and restoring them at binpkg pre-installation. I prefer to avoid all this and build the pkg with appropiate perms. --HG-- extra : convert_revision : 8a5086049ab575962913eda0cb2ace0c211b97f1 --- doc/BINPKG_INFO | 2 +- doc/README | 1 + doc/SRCPKG_INFO | 5 ++--- doc/TODO | 2 -- shutils/binpkg.sh | 2 +- shutils/common_funcs.sh | 9 ++++++++- shutils/install_funcs.sh | 2 +- templates/sudo/template | 4 ---- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/doc/BINPKG_INFO b/doc/BINPKG_INFO index e507d05fb6..cf2f06d004 100644 --- a/doc/BINPKG_INFO +++ b/doc/BINPKG_INFO @@ -76,7 +76,7 @@ To install binary packages, firstly a repository must be created as well as some binary packages for it. The flow for this task is: 1- xbps-src install - 2- xbps-src build-pkg all + 2- xbps-src build-pkg all [requires sudo access] 3- xbps-src genindex 4- xbps-repo add $XBPS_PACKAGES 5- xbps-bin install -r /rootdir diff --git a/doc/README b/doc/README index bcc7c3722b..6fdab5f850 100644 --- a/doc/README +++ b/doc/README @@ -43,6 +43,7 @@ xbps binary/source packages: * wget * libarchive (development package) * perl + * sudo Super-user privileges are required as well, because all packages are built in a chroot (except the ones that are included in a virtual package to be diff --git a/doc/SRCPKG_INFO b/doc/SRCPKG_INFO index 7de79770f7..b95fae91b5 100644 --- a/doc/SRCPKG_INFO +++ b/doc/SRCPKG_INFO @@ -2,7 +2,8 @@ REQUIREMENTS ----------------------------------------------------------------------------- -To be able to build packages the following software is required: +To be able to build packages from source the following software is required +in the host system: * GNU Binutils * GNU Bison @@ -20,8 +21,6 @@ Super-user privileges are required as well, because all packages are built in a chroot (except the ones that are included in a virtual package to be able to build a minimal system for the chroot). -PLEASE NOTE THAT fakechroot or fakeroot-ng DO NOT WORK. - ------------------------------------------------------------------------------ HOW TO BUILD/HANDLE PACKAGES FROM SOURCE ------------------------------------------------------------------------------ diff --git a/doc/TODO b/doc/TODO index eb9cf0af8e..d4e0af0c7b 100644 --- a/doc/TODO +++ b/doc/TODO @@ -16,8 +16,6 @@ xbps-cmpver: Packages: * fix mpfr hardcoded rpath for gmp. - * Fix sudo permissions for /etc/sudoers. This must be 644 to be able to - build the binary package. xbps-bin: * Add support to handle conf_files and keep_dirs from package metadata. diff --git a/shutils/binpkg.sh b/shutils/binpkg.sh index 9c92eb1e2c..e52437c6c5 100644 --- a/shutils/binpkg.sh +++ b/shutils/binpkg.sh @@ -165,7 +165,7 @@ xbps_make_binpkg() binpkg=$pkgname-$version.$arch.xbps pkgdir=$XBPS_PACKAGESDIR/$arch - run_rootcmd tar cfjp $XBPS_DESTDIR/$binpkg . + run_rootcmd yes tar cfjp $XBPS_DESTDIR/$binpkg . if [ $? -eq 0 ]; then [ ! -d $pkgdir ] && mkdir -p $pkgdir mv -f $XBPS_DESTDIR/$binpkg $pkgdir diff --git a/shutils/common_funcs.sh b/shutils/common_funcs.sh index e14a773654..c01814d0cd 100644 --- a/shutils/common_funcs.sh +++ b/shutils/common_funcs.sh @@ -39,12 +39,19 @@ run_func() run_rootcmd() { local lenv= + local usesudo="$1" [ -n "$in_chroot" ] && unset fakeroot_cmd lenv="XBPS_DESTDIR=$XBPS_DESTDIR" lenv="XBPS_DISTRIBUTIONDIR=$XBPS_DISTRIBUTIONDIR $lenv" - env ${lenv} ${fakeroot_cmd} $@ + + shift + if [ -n "$usesudo" -a -z "$in_chroot" ]; then + sudo env ${lenv} $@ + else + env ${lenv} ${fakeroot_cmd} $@ + fi } msg_error() diff --git a/shutils/install_funcs.sh b/shutils/install_funcs.sh index e139a62e00..ccf146c5e5 100644 --- a/shutils/install_funcs.sh +++ b/shutils/install_funcs.sh @@ -106,7 +106,7 @@ make_install() # # Install package via make. # - run_rootcmd ${make_cmd} ${make_install_target} ${make_install_args} + run_rootcmd no ${make_cmd} ${make_install_target} ${make_install_args} if [ "$?" -ne 0 ]; then msg_error "installing $pkgname-$version." exit 1 diff --git a/templates/sudo/template b/templates/sudo/template index b4cf6beaf0..16cbdf4d4b 100644 --- a/templates/sudo/template +++ b/templates/sudo/template @@ -32,8 +32,4 @@ session optional pam_xauth.so session required pam_env.so session required pam_unix.so _EOF - chmod 644 $destdir/etc/pam.d/sudo - chmod 644 $destdir/usr/libexec/sudo/sudo_noexec.so - chmod 755 $destdir/usr/bin/sudo* $destdir/usr/sbin/visudo - chmod 644 $destdir/etc/sudoers }