From 92219c39eaaed8d88b715b791dd788c90e8d5dea Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 31 Jan 2007 13:12:43 +0000 Subject: [PATCH] Merged from trunk 5839:5849 For bug #164532, don't rely on ${USERLAND} since the portage tree might be empty. For bug #164617, don't change permissions on ${WORKDIR} with unpack(). Use find + xargs to avoid a potential 'Argument list too long' from bash. Thanks to solar for reporting. add some useful options (SpankMan) try and fix $LastChangedRevision$ (SpankMan) try and fix $Rev$ (SpankMan) svn path=/main/branches/prefix/; revision=5850 --- bin/ebuild.sh | 4 +- bin/emerge-webrsync | 6 ++- bin/quickpkg | 89 ++++++++++++++++++++++++++++++--------------- 3 files changed, 67 insertions(+), 32 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 1a573d859..8fcf28db2 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -606,7 +606,9 @@ unpack() { ;; esac done - chmod -Rf a+rX,u+w,g-w,o-w . + # Do not chmod '.' since it's probably ${WORKDIR} and PORTAGE_WORKDIR_MODE + # should be preserved. + find . -mindepth 1 -print0 | ${XARGS} -0 chmod -f a+rX,u+w,g-w,o-w } strip_duplicate_slashes() { diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index b6d8e130a..f8ae87d63 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -7,7 +7,7 @@ eval $("@PORTAGE_BASE@"/bin/portageq envvar -v FEATURES FETCHCOMMAND \ GENTOO_MIRRORS PORTAGE_INST_UID PORTAGE_INST_GID PORTAGE_NICENESS \ - PORTAGE_TMPDIR PORTDIR USERLAND EPREFIX) + PORTAGE_TMPDIR PORTDIR EPREFIX) DISTDIR="${PORTAGE_TMPDIR}/emerge-webrsync" # If PORTAGE_NICENESS is overriden via the env then it will @@ -94,7 +94,9 @@ while (( $attempts < 40 )) ; do # snapshot (for attempts=1, subtract 1 day from the current UTC time). daysbefore=$(expr $(date -u +"%s") - 86400 \* ${attempts}) DATE_ARGS="-d @${daysbefore}" - [ "${USERLAND}" != "GNU" ] && DATE_ARGS="-r ${daysbefore}" + # ${USERLAND} is unreliable since the portage tree might be empty, so test + # success of the -r option to distinguish between gnu and bsd date. + date -r ${daysbefore} >&/dev/null && DATE_ARGS="-r ${daysbefore}" day=$(date ${DATE_ARGS} -u +"%d") month=$(date ${DATE_ARGS} -u +"%m") year=$(date ${DATE_ARGS} -u +"%Y") diff --git a/bin/quickpkg b/bin/quickpkg index 1309e8502..3524c6565 100755 --- a/bin/quickpkg +++ b/bin/quickpkg @@ -1,5 +1,5 @@ #!@BASH@ -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ @@ -10,7 +10,7 @@ # default is /usr/portage/packages/All/ # not in prefix -#if [ "${UID}" != "0" ] ; then +#if [[ ${UID} != "0" ]] ; then # echo "You must run this as root" # exit 1 #fi @@ -18,43 +18,74 @@ # We need to ensure a sane umask for the packages that will be created. umask 022 +# We need this portage cruft to be before --help output because +# we utilize some of these vars in the usage info :/ eval $(portageq envvar -v NOCOLOR PKGDIR PORTAGE_BIN_PATH PORTAGE_NICENESS \ PORTAGE_PYM_PATH PORTAGE_TMPDIR ROOT) export PKGDIR PORTAGE_TMPDIR ROOT -[ -n "${PORTAGE_NICENESS}" ] && renice $PORTAGE_NICENESS $$ > /dev/null +[[ -n ${PORTAGE_NICENESS} ]] && renice $PORTAGE_NICENESS $$ > /dev/null # Make sure the xpak module is in PYTHONPATH export PYTHONPATH=${PORTAGE_PYM_PATH} export PORTAGE_DB=$(portageq vdb_path) -if [ -z "$1" ] || [ $1 == "-h" ] || [ $1 == "--help" ] ; then - echo "QUICKPKG ver 1.2" - echo "USAGE: quickpkg " - echo " a pkg can be of the form:" - echo " - ${PORTAGE_DB}///" - echo " - single depend-type atom ..." - echo " if portage can emerge it, quickpkg can make a package" - echo " for exact definitions of depend atoms, see ebuild(5)" - echo - echo "EXAMPLE:" - echo " quickpkg ${PORTAGE_DB}/net-www/apache-1.3.27-r1" - echo " package up apache, just version 1.3.27-r1" - echo " quickpkg apache" - echo " package up apache, all versions of apache installed" - echo " quickpkg =apache-1.3.27-r1" - echo " package up apache, just version 1.3.27-r1" - exit 1 -fi +version() { + local svnrev='$Rev$' + svnrev=${svnrev#* } + echo "quickpkg-${svnrev% *}" + exit 0 +} +usage() { + cat <<-EOF + Usage: quickpkg [options] + + Options: + -C, --nocolor Disable color output + -x, --debug Run with shell debug turned on + -V, --version Print version and exit + -h, --help This cruft output + + A pkg can be of the form: + - ${PORTAGE_DB}/// + - single depend-type atom ... + if portage can emerge it, quickpkg can make a package + for exact definitions of depend atoms, see ebuild(5) + + Examples: + quickpkg ${PORTAGE_DB}/net-www/apache-1.3.27-r1 + package up apache, just version 1.3.27-r1 + quickpkg apache + package up apache, all versions of apache installed + quickpkg =apache-1.3.27-r1 + quickpkg =apache-1.3.27-r1 + EOF + if [[ -n $1 ]] ; then + echo "" + echo "Unknown arguments: $*" 1>&2 + exit 1 + else + exit 0 + fi +} + +SET_X="no" +while [[ -n $1 ]] ; do + case $1 in + -C|--nocolor) export NOCOLOR="true";; + -x|--debug) SET_X="yes";; + -V|--version) version;; + -h|--help) usage;; + -*) usage "$1";; + *) break;; + esac + shift +done +[[ ${SET_X} == "yes" ]] && set -x -source "${PORTAGE_BIN_PATH}/isolated-functions.sh" -case "${NOCOLOR:-false}" in - yes|true) - unset_colors - ;; - no|false) - set_colors - ;; +case ${NOCOLOR:-false} in + yes|true) unset_colors;; + no|false) set_colors;; esac # here we make a package given a little info -- 2.26.2