From 667325267984c5fe7a11fa907a6ec239c0a61d5a Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 26 Apr 2010 02:51:48 +0200 Subject: [PATCH] Infrastructure changes to simplify the conf file. * Removed the following vars from the conf file: XBPS_BUILDDIR, XBPS_PACKAGESDIR and XBPS_SRCDISTDIR. They are always relative to XBPS_MASTERDIR and cannot be changed. * Removed XBPS_INSTALLDIR, it was unused in the code. * Prepend /tools/bin in PATH for the chroot. * Don't register a repo in the chroot if the XBPS_PREFER_BINPKG_DEPS is not set. --HG-- extra : convert_revision : 4df03ffa64f0bbf81cd1dd0baf38f1b7e4f47549 --- xbps-src/etc/Makefile | 3 --- xbps-src/etc/xbps-src.conf.in | 23 ------------------- xbps-src/libexec/xbps-src-chroot-helper.sh.in | 12 +++------- xbps-src/shutils/chroot.sh.in | 20 ++++++++++------ xbps-src/shutils/init_funcs.sh.in | 14 +++++++---- xbps-src/xbps-src.sh.in | 19 ++++++--------- 6 files changed, 32 insertions(+), 59 deletions(-) diff --git a/xbps-src/etc/Makefile b/xbps-src/etc/Makefile index dffa0f4bfd..60d5be0fb1 100644 --- a/xbps-src/etc/Makefile +++ b/xbps-src/etc/Makefile @@ -4,12 +4,9 @@ CONF_FILE = xbps-src.conf .PHONY: all all: - sed -e "s|@@XBPS_INSTALL_PREFIX@@|$(PREFIX)|g" \ - $(CONF_FILE).in > $(CONF_FILE) .PHONY: clean clean: - -rm -f $(CONF_FILE) .PHONY: install install: diff --git a/xbps-src/etc/xbps-src.conf.in b/xbps-src/etc/xbps-src.conf.in index b4404b024f..b73bad0bf6 100644 --- a/xbps-src/etc/xbps-src.conf.in +++ b/xbps-src/etc/xbps-src.conf.in @@ -2,12 +2,6 @@ # Configuration file for xbps-src. # -# -# Directory where xbps-src has been installed. By default /usr/local. -# Usually you don't have to change this one, it's set by "make install". -# -XBPS_INSTALLDIR=@@XBPS_INSTALL_PREFIX@@ - # # Directory where the xbps-src GIT repository is stored. This is # required to be mounted in the chroot. @@ -19,23 +13,6 @@ XBPS_DISTRIBUTIONDIR=$HOME/xbps-templates # XBPS_MASTERDIR=$XBPS_DISTRIBUTIONDIR/masterdir -# -# Directory where a local binary package repository is available -# (or will be created from). Packages will be stored here. -# -XBPS_PACKAGESDIR=$XBPS_DISTRIBUTIONDIR/packages - -# -# Directory where source files will be extracted to and build object -# files will live on. -# -XBPS_BUILDDIR=$XBPS_DISTRIBUTIONDIR/builddir - -# -# Directory where source distribution files are stored. -# -XBPS_SRCDISTDIR=$XBPS_DISTRIBUTIONDIR/srcdistdir - # # Compilation flags for cc and c++. # diff --git a/xbps-src/libexec/xbps-src-chroot-helper.sh.in b/xbps-src/libexec/xbps-src-chroot-helper.sh.in index d08118b020..ed301dae44 100644 --- a/xbps-src/libexec/xbps-src-chroot-helper.sh.in +++ b/xbps-src/libexec/xbps-src-chroot-helper.sh.in @@ -31,8 +31,7 @@ HANDLER="$1" . @@XBPS_INSTALL_ETCDIR@@/xbps-src.conf -EXTDIRS="xbps xbps_builddir xbps_packagesdir xbps_srcdistdir" -REQFS="sys proc dev ${EXTDIRS}" +REQFS="sys proc dev xbps" mount_chroot_fs() { @@ -46,9 +45,6 @@ mount_chroot_fs() fi case ${f} in xbps) blah=${XBPS_DISTRIBUTIONDIR};; - xbps_builddir) blah=${XBPS_BUILDDIR};; - xbps_srcdistdir) blah=${XBPS_SRCDISTDIR};; - xbps_packagesdir) blah=${XBPS_PACKAGESDIR};; *) blah=/${f};; esac [ ! -d ${blah} ] && echo "failed." && continue @@ -91,10 +87,8 @@ umount_chroot_fs() done # Remove created dirs - for dir in ${EXTDIRS}; do - [ -f ${XBPS_MASTERDIR}/.${dir}_mount_bind_done ] && continue - [ -d ${XBPS_MASTERDIR}/${dir} ] && rmdir ${XBPS_MASTERDIR}/${dir} - done + [ -f ${XBPS_MASTERDIR}/.xbps_mount_bind_done ] && continue + [ -d ${XBPS_MASTERDIR}/xbps ] && rmdir ${XBPS_MASTERDIR}/xbps } if [ $# -ne 1 ]; then diff --git a/xbps-src/shutils/chroot.sh.in b/xbps-src/shutils/chroot.sh.in index c777048b63..0d36023fcc 100644 --- a/xbps-src/shutils/chroot.sh.in +++ b/xbps-src/shutils/chroot.sh.in @@ -60,9 +60,6 @@ XBPSSRC_CF=$XBPS_MASTERDIR/usr/local/etc/xbps-src.conf echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPSSRC_CF echo "XBPS_MASTERDIR=/" >> $XBPSSRC_CF -echo "XBPS_PACKAGESDIR=/xbps_packagesdir" >> $XBPSSRC_CF -echo "XBPS_BUILDDIR=/xbps_builddir" >> $XBPSSRC_CF -echo "XBPS_SRCDISTDIR=/xbps_srcdistdir" >> $XBPSSRC_CF echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $XBPSSRC_CF echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPSSRC_CF echo "XBPS_FETCH_CMD='xbps-uhelper.static fetch'" >> $XBPSSRC_CF @@ -141,12 +138,18 @@ ff02::2 ip6-allrouters ff02::3 ip6-allhosts _EOF - # Create /bin/sh symlink to bash - cd $XBPS_MASTERDIR/bin && ln -sf bash sh + create_binsh_symlink touch $XBPS_MASTERDIR/.xbps_perms_done } +create_binsh_symlink() +{ + if [ ! -h $XBPS_MASTERDIR/bin/sh ]; then + cd $XBPS_MASTERDIR/bin && ln -sf bash sh + fi +} + prepare_binpkg_repos() { if [ ! -f "$XBPS_MASTERDIR/.xbps_added_local_repo" ]; then @@ -206,7 +209,7 @@ xbps_chroot_handler() local pkg="$2" local only_destdir="$3" local norm_builddir="$4" - local path="/usr/local/sbin:/bin::/sbin:/usr/bin:/usr/sbin:/usr/local/bin" + local path="/tools/bin:/usr/local/sbin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin" [ -z "$action" -o -z "$pkg" ] && return 1 [ "$action" != "configure" -a "$action" != "build" -a \ @@ -218,11 +221,14 @@ xbps_chroot_handler() echo "done." fi + create_binsh_symlink create_busybox_links install_xbps_utils ${sudo_cmd} @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper mount [ $? -ne 0 ] && return $? - prepare_binpkg_repos + if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then + prepare_binpkg_repos + fi # Reinstall xbps-src in the chroot if [ ! -f $XBPS_MASTERDIR/usr/local/sbin/xbps-src ]; then diff --git a/xbps-src/shutils/init_funcs.sh.in b/xbps-src/shutils/init_funcs.sh.in index e6015558db..e6bca739f8 100644 --- a/xbps-src/shutils/init_funcs.sh.in +++ b/xbps-src/shutils/init_funcs.sh.in @@ -37,11 +37,15 @@ set_defvars() : ${XBPS_META_PATH:=$XBPS_DBDIR/} : ${XBPS_PKGMETADIR:=$XBPS_DBDIR/metadata} : ${XBPS_SRCPKGDIR:=$XBPS_DISTRIBUTIONDIR/srcpkgs} - if [ -n "$in_chroot" ]; then - : ${XBPS_DESTDIR:=/pkg-destdir} - else - : ${XBPS_DESTDIR:=$XBPS_MASTERDIR/pkg-destdir} - fi + : ${XBPS_DESTDIR:=$XBPS_MASTERDIR/pkg-destdir} + : ${XBPS_PACKAGESDIR:=$XBPS_MASTERDIR/pkg-binpkgs} + : ${XBPS_BUILDDIR:=$XBPS_MASTERDIR/pkg-builddir} + : ${XBPS_SRCDISTDIR:=$XBPS_MASTERDIR/pkg-srcdistdir} + + for i in DESTDIR PACKAGESDIR BUILDDIR SRCDISTDIR; do + eval val="\$XBPS_$i" + [ ! -d "$val" ] && mkdir -p $val + done DDIRS="XBPS_TRIGGERSDIR XBPS_HELPERSDIR" DDIRS="$DDIRS XBPS_COMMONVARSDIR XBPS_SHUTILSDIR" diff --git a/xbps-src/xbps-src.sh.in b/xbps-src/xbps-src.sh.in index 5dace06d52..cb76542540 100644 --- a/xbps-src/xbps-src.sh.in +++ b/xbps-src/xbps-src.sh.in @@ -99,7 +99,7 @@ run_file() check_config_vars() { - local cffound f + local val cffound f if [ -z "$config_file_specified" ]; then config_file_paths="$XBPS_CONFIG_FILE ./etc/xbps-src.conf" @@ -117,17 +117,12 @@ check_config_vars() msg_error "cannot find configuration file: $XBPS_CONFIG_FILE" fi - local XBPS_VARS="XBPS_MASTERDIR XBPS_BUILDDIR XBPS_SRCDISTDIR \ - XBPS_PACKAGESDIR" - for f in ${XBPS_VARS}; do - eval val="\$$f" - [ -z "$val" ] && msg_error "'$f' not set in configuration file" - - if [ ! -d "$val" ]; then - mkdir "$val" - [ $? -ne 0 ] && msg_error "couldn't create '$f' directory" - fi - done + eval val="\$XBPS_MASTERDIR" + [ -z "$val" ] && msg_error "'XBPS_MASTERDIR' not set in configuration file" + if [ ! -d "$val" ]; then + mkdir "$val" + [ $? -ne 0 ] && msg_error "couldn't create 'XBPS_MASTERDIR' directory" + fi export PATH="@@XBPS_INSTALL_PREFIX@@/sbin:$PATH" }