Substitute bash builtin >> for touch command.
authorZac Medico <zmedico@gentoo.org>
Mon, 20 Dec 2010 03:33:26 +0000 (19:33 -0800)
committerZac Medico <zmedico@gentoo.org>
Mon, 20 Dec 2010 03:33:26 +0000 (19:33 -0800)
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
bin/ebuild-helpers/ecompressdir
bin/ebuild-helpers/prepstrip
bin/ebuild.sh
bin/misc-functions.sh
pym/portage/package/ebuild/fetch.py

index ed19ffb1b34479bdcfe98d64d379cf823991b508..de81b4484ec7d65c64428283c7a029ef0268c2d2 100755 (executable)
@@ -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
                ;;
index acdb1cd7f135053de9a94c690af4da3eeca5c337..7ed2627e33df755287f88575216eddb787ebc459 100755 (executable)
@@ -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
                ;;
index ceb1ef0476e4db3af06900d77d68011c969ec9f0..8b18ac0c8e3a5c8f4337a5f4f2b01518ec6cde39 100755 (executable)
@@ -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
index 97e3df9f0d8bdd1fb6d69a2eabf69b3b5454bbdd..4daa076104a651b7f70a93967e8f0bd71bc352a0 100755 (executable)
@@ -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
index 79ce4362883b990b8fd1e0a78d309e9632d67721..7ad7c0d52116d4ae9121754d04d66fc9f7b54602 100755 (executable)
@@ -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() {
index f97707fd6c00afe5c61310c67bcce1a4a6602dbd..f1bd2408ab9a45b597af6bc59944a03d096f7bce 100644 (file)
@@ -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):