From 70f53f46aba6e0193f61a6e3bf9dbbaa3b9908e0 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 19 Dec 2010 19:33:26 -0800 Subject: [PATCH] Substitute bash builtin >> for touch command. It should be faster to use the bash builtin, and also allows us to avoid issues with touch breakage (like in bug #348640). --- bin/ebuild-helpers/ecompress | 7 +++-- bin/ebuild-helpers/ecompressdir | 9 ++++--- bin/ebuild-helpers/prepstrip | 2 +- bin/ebuild.sh | 40 ++++++++++++++++++----------- bin/misc-functions.sh | 3 ++- pym/portage/package/ebuild/fetch.py | 2 +- 6 files changed, 40 insertions(+), 23 deletions(-) diff --git a/bin/ebuild-helpers/ecompress b/bin/ebuild-helpers/ecompress index ed19ffb1b..de81b4484 100755 --- a/bin/ebuild-helpers/ecompress +++ b/bin/ebuild-helpers/ecompress @@ -95,8 +95,11 @@ case $1 in ;; --queue) shift - touch "${@/%/.ecompress.file}" - ret=$? + ret=0 + for x in "${@/%/.ecompress.file}" ; do + >> "$x" + ((ret|=$?)) + done [[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" exit $ret ;; diff --git a/bin/ebuild-helpers/ecompressdir b/bin/ebuild-helpers/ecompressdir index acdb1cd7f..7ed2627e3 100755 --- a/bin/ebuild-helpers/ecompressdir +++ b/bin/ebuild-helpers/ecompressdir @@ -14,7 +14,7 @@ case $1 in shift for skip in "$@" ; do [[ -d ${D}${skip} || -f ${D}${skip} ]] \ - && touch "${D}${skip}.ecompress.skip" + && >> "${D}${skip}.ecompress.skip" done exit 0 ;; @@ -22,8 +22,11 @@ case $1 in shift set -- "${@/%/.ecompress.dir}" set -- "${@/#/${D}}" - touch "$@" - ret=$? + ret=0 + for x in "$@" ; do + >> "$x" + ((ret|=$?)) + done [[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" exit $ret ;; diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip index ceb1ef047..8b18ac0c8 100755 --- a/bin/ebuild-helpers/prepstrip +++ b/bin/ebuild-helpers/prepstrip @@ -188,6 +188,6 @@ then # https://bugzilla.redhat.com/show_bug.cgi?id=444310 while read -r -d $'\0' emptydir do - touch "$emptydir"/.keepdir + >> "$emptydir"/.keepdir done < <(find "${D}${prepstrip_sources_dir}/" -type d -empty -print0) fi diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 97e3df9f0..4daa07610 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -326,11 +326,14 @@ keepdir() { if [ "$1" == "-R" ] || [ "$1" == "-r" ]; then shift find "$@" -type d -printf "${D}%p/.keep_${CATEGORY}_${PN}-${SLOT}\n" \ - | tr "\n" "\0" | ${XARGS} -0 -n100 touch || \ - die "Failed to recursively create .keep files" + | tr "\n" "\0" | \ + while read -r -d $'\0' ; do + >> "$REPLY" || \ + die "Failed to recursively create .keep files" + done else for x in "$@"; do - touch "${D}${x}/.keep_${CATEGORY}_${PN}-${SLOT}" || \ + >> "${D}${x}/.keep_${CATEGORY}_${PN}-${SLOT}" || \ die "Failed to create .keep in ${D}${x}" done fi @@ -692,7 +695,8 @@ dyn_pretend() { fi ebuild_phase pre_pkg_pretend ebuild_phase pkg_pretend - > "$PORTAGE_BUILDDIR"/.pretended + >> "$PORTAGE_BUILDDIR/.pretended" || \ + die "Failed to create $PORTAGE_BUILDDIR/.pretended" ebuild_phase post_pkg_pretend } @@ -704,7 +708,8 @@ dyn_setup() { fi ebuild_phase pre_pkg_setup ebuild_phase pkg_setup - > "$PORTAGE_BUILDDIR"/.setuped + >> "$PORTAGE_BUILDDIR/.setuped" || \ + die "Failed to create $PORTAGE_BUILDDIR/.setuped" ebuild_phase post_pkg_setup } @@ -751,7 +756,8 @@ dyn_unpack() { ebuild_phase pre_src_unpack vecho ">>> Unpacking source..." ebuild_phase src_unpack - touch "${PORTAGE_BUILDDIR}/.unpacked" || die "IO Failure -- Failed 'touch .unpacked' in ${PORTAGE_BUILDDIR}" + >> "$PORTAGE_BUILDDIR/.unpacked" || \ + die "Failed to create $PORTAGE_BUILDDIR/.unpacked" vecho ">>> Source unpacked in ${WORKDIR}" ebuild_phase post_src_unpack } @@ -996,7 +1002,8 @@ dyn_prepare() { ebuild_phase pre_src_prepare vecho ">>> Preparing source in $PWD ..." ebuild_phase src_prepare - touch "$PORTAGE_BUILDDIR"/.prepared + >> "$PORTAGE_BUILDDIR/.prepared" || \ + die "Failed to create $PORTAGE_BUILDDIR/.prepared" vecho ">>> Source prepared." ebuild_phase post_src_prepare @@ -1027,7 +1034,8 @@ dyn_configure() { vecho ">>> Configuring source in $PWD ..." ebuild_phase src_configure - touch "$PORTAGE_BUILDDIR"/.configured + >> "$PORTAGE_BUILDDIR/.configured" || \ + die "Failed to create $PORTAGE_BUILDDIR/.configured" vecho ">>> Source configured." ebuild_phase post_src_configure @@ -1059,7 +1067,8 @@ dyn_compile() { vecho ">>> Compiling source in $PWD ..." ebuild_phase src_compile - touch "$PORTAGE_BUILDDIR"/.compiled + >> "$PORTAGE_BUILDDIR/.compiled" || \ + die "Failed to create $PORTAGE_BUILDDIR/.compiled" vecho ">>> Source compiled." ebuild_phase post_src_compile @@ -1098,8 +1107,8 @@ dyn_test() { addpredict / ebuild_phase pre_src_test ebuild_phase src_test - touch "$PORTAGE_BUILDDIR/.tested" || \ - die "Failed to 'touch .tested' in $PORTAGE_BUILDDIR" + >> "$PORTAGE_BUILDDIR/.tested" || \ + die "Failed to create $PORTAGE_BUILDDIR/.tested" ebuild_phase post_src_test SANDBOX_PREDICT=${save_sp} fi @@ -1148,7 +1157,8 @@ dyn_install() { export _E_DOCDESTTREE_="" ebuild_phase src_install - touch "${PORTAGE_BUILDDIR}/.installed" + >> "$PORTAGE_BUILDDIR/.installed" || \ + die "Failed to create $PORTAGE_BUILDDIR/.installed" vecho ">>> Completed installing ${PF} into ${D}" vecho ebuild_phase post_src_install @@ -1187,7 +1197,7 @@ dyn_install() { [ -n "${PORTAGE_REPO_NAME}" ] && echo "${PORTAGE_REPO_NAME}" > repository if hasq nostrip ${FEATURES} ${RESTRICT} || hasq strip ${RESTRICT} then - touch DEBUGBUILD + >> DEBUGBUILD fi trap - SIGINT SIGQUIT } @@ -1820,7 +1830,7 @@ preprocess_ebuild_env() { _portage_filter_opts+=" --filter-features --filter-locale --filter-path --filter-sandbox" fi filter_readonly_variables $_portage_filter_opts < "${T}"/environment \ - > "${T}"/environment.filtered || return $? + >> "$T/environment.filtered" || return $? unset _portage_filter_opts mv "${T}"/environment.filtered "${T}"/environment || return $? rm -f "${T}/environment.success" || return $? @@ -1846,7 +1856,7 @@ preprocess_ebuild_env() { # Rely on save_ebuild_env() to filter out any remaining variables # and functions that could interfere with the current environment. save_ebuild_env || exit $? - touch "${T}/environment.success" || exit $? + >> "$T/environment.success" || exit $? ) > "${T}/environment.filtered" local retval if [ -e "${T}/environment.success" ] ; then diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index 79ce43628..7ad7c0d52 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -901,7 +901,8 @@ dyn_package() { echo ${md5_hash} > "${PORTAGE_BUILDDIR}"/build-info/BINPKGMD5 vecho ">>> Done." cd "${PORTAGE_BUILDDIR}" - touch .packaged || die "Failed to 'touch .packaged' in ${PORTAGE_BUILDDIR}" + >> "$PORTAGE_BUILDDIR/.packaged" || \ + die "Failed to create $PORTAGE_BUILDDIR/.packaged" } dyn_spec() { diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py index f97707fd6..f1bd2408a 100644 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@ -97,7 +97,7 @@ def _spawn_fetch(settings, args, **kwargs): return rval _userpriv_test_write_file_cache = {} -_userpriv_test_write_cmd_script = "touch %(file_path)s 2>/dev/null ; rval=$? ; " + \ +_userpriv_test_write_cmd_script = ">> %(file_path)s 2>/dev/null ; rval=$? ; " + \ "rm -f %(file_path)s ; exit $rval" def _userpriv_test_write_file(settings, file_path): -- 2.26.2