[gentoo-portage-dev] [PATCH v2] f{owners,perms}: Warn when using relative path
--- bin/ebuild-helpers/fowners | 15 +++ bin/ebuild-helpers/fperms | 15 +++ 2 files changed, 30 insertions(+) diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners index 68004210b..0eda73e58 100755 --- a/bin/ebuild-helpers/fowners +++ b/bin/ebuild-helpers/fowners @@ -8,6 +8,21 @@ if ! ___eapi_has_prefix_variables; then EPREFIX= ED=${D} fi +got_owner= +for arg; do + [[ ${arg} == -* ]] && continue + if [[ ! ${got_owner} ]]; then + got_owner=1 + continue + fi + if [[ ${arg} != /* ]]; then + eqawarn "Relative path passed to '${0##*/}': ${arg}" + eqawarn "This is unsupported. Please use 'chown' when you need to work on files" + eqawarn "outside the installation image (\${ED})." + fi +done + + # we can't prefix all arguments because # chown takes random options slash="/" diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms index c63a6abc3..f98560039 100755 --- a/bin/ebuild-helpers/fperms +++ b/bin/ebuild-helpers/fperms @@ -8,6 +8,21 @@ if ! ___eapi_has_prefix_variables; then ED=${D} fi +got_mode= +for arg; do + # - can either be an option or a mode string + [[ ${arg} == -* && ${arg} != -[ugorwxXst] ]] && continue + if [[ ! ${got_mode} ]]; then + got_mode=1 + continue + fi + if [[ ${arg} != /* ]]; then + eqawarn "Relative path passed to '${0##*/}': ${arg}" + eqawarn "This is unsupported. Please use 'chmod' when you need to work on files" + eqawarn "outside the installation image (\${ED})." + fi +done + # we can't prefix all arguments because # chmod takes random options slash="/" -- 2.19.0
Re: [gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path
On Mon, 2018-09-17 at 12:42 -0400, Michael Orlitzky wrote: > On 09/17/2018 02:52 AM, Michał Górny wrote: > > > > --- a/bin/ebuild-helpers/fowners > > +++ b/bin/ebuild-helpers/fowners > > ... > > + eqawarn "This is unsupported. Please use 'chmod' when you need > > to work on files" > > This one should be 'chown' instead of 'chmod'. Good catch, thanks! > > (Calling chown on the live filesystem is often also a dangerous mistake, > but this probably isn't the place to fuss about it.) > I think this is more likely to be triggered on chown-ing stuff inside ${S}. -- Best regards, Michał Górny signature.asc Description: This is a digitally signed message part
[gentoo-portage-dev] [PATCH 2/2] ecompress: Replace with implementation from portage[mgorny]
Replace the old ecompress/ecompressdir implementation with the one used in portage[mgorny]. This is a squashed version of a long series of commits that gutted off parts of old logic, introduced the new code, fixed ongoing bugs and finally restored the missing features. Given the scale of changes, it is easier to review it as completely new code. The duplicate model of ecompress/ecompressdir (both not exactly par on features) has been replaced by a single helper that compresses everything uniformly. Instead of complex path-wise processing, a mark-file logic is used -- the same as in estrip. Additionally, the functions are moved out of ebuild path to clearly indicate they are internal API (they were not used in any ebuilds). The new implementation is par on features with the old one. It supports exclusion suffix lists, automatic decompression of already-compressed files (with eqawarn-ing about its unreliability), lower bound for compressed file size, hardlink breaking and symlink fixing. In other words, there should be no regression upon replacing it. --- bin/ebuild-helpers/ecompress | 161 bin/ebuild-helpers/ecompressdir| 226 - bin/ecompress | 147 +++ bin/ecompress-file | 67 + bin/misc-functions.sh | 127 +--- lib/portage/tests/bin/setup_env.py | 2 +- 6 files changed, 220 insertions(+), 510 deletions(-) delete mode 100755 bin/ebuild-helpers/ecompress delete mode 100755 bin/ebuild-helpers/ecompressdir create mode 100755 bin/ecompress create mode 100755 bin/ecompress-file diff --git a/bin/ebuild-helpers/ecompress b/bin/ebuild-helpers/ecompress deleted file mode 100755 index 50ee81129..0 --- a/bin/ebuild-helpers/ecompress +++ /dev/null @@ -1,161 +0,0 @@ -#!/bin/bash -# Copyright 1999-2010 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1 - -if [[ -z $1 ]] ; then - __helpers_die "${0##*/}: at least one argument needed" - exit 1 -fi - -# setup compression stuff -PORTAGE_COMPRESS=${PORTAGE_COMPRESS-bzip2} -[[ -z ${PORTAGE_COMPRESS} ]] && exit 0 - -if [[ ${PORTAGE_COMPRESS_FLAGS+set} != "set" ]] ; then - case ${PORTAGE_COMPRESS} in - bzip2|gzip) PORTAGE_COMPRESS_FLAGS="-9";; - esac -fi - -# decompress_args(suffix, binary) -# - suffix: the compression suffix to work with -# - binary: the program to execute that'll compress/decompress -# new_args: global array used to return revised arguments -decompress_args() { - local suffix=$1 binary=$2 - shift 2 - - # Initialize the global new_args array. - new_args=() - declare -a decompress_args=() - local x i=0 decompress_count=0 - for x in "$@" ; do - if [[ ${x%$suffix} = $x ]] ; then - new_args[$i]=$x - else - new_args[$i]=${x%$suffix} - decompress_args[$decompress_count]=$x - ((decompress_count++)) - fi - ((i++)) - done - - if [ $decompress_count -gt 0 ] ; then - ${binary} "${decompress_args[@]}" - if [ $? -ne 0 ] ; then - # Apparently decompression failed for one or more files, so - # drop those since we don't want to compress them twice. - new_args=() - local x i=0 - for x in "$@" ; do - if [[ ${x%$suffix} = $x ]] ; then - new_args[$i]=$x - ((i++)) - elif [[ -f ${x%$suffix} ]] ; then - new_args[$i]=${x%$suffix} - ((i++)) - else - # Apparently decompression failed for this one, so drop - # it since we don't want to compress it twice. - true - fi - done - fi - fi -} - -case $1 in - --suffix) - [[ -n $2 ]] && __vecho "${0##*/}: --suffix takes no additional arguments" 1>&2 - - if [[ ! -e ${T}/.ecompress.suffix ]] ; then - set -e - tmpdir="${T}"/.ecompress$$.${RANDOM} - mkdir "${tmpdir}" - cd "${tmpdir}" - # we have to fill the file enough so that there is something - # to compress as some programs will refuse to do compression - # if it cannot actually compress the file - echo {0..1000} >
[gentoo-portage-dev] [PATCH 1/2] Replace implicit doc compression with dir compression in old EAPIs
Unify the documentation compression methods in all EAPIs to compress per-directory rather than implicitly compress files installed by dodoc, doinfo and doman. Old EAPIs don't provide docompress to control which directories are compressed but they don't say anything about dodoc etc. compressing anything either. --- bin/ebuild-helpers/dodoc| 3 +-- bin/ebuild-helpers/prepinfo | 3 +-- bin/ebuild-helpers/prepman | 35 ++- bin/misc-functions.sh | 8 +--- 4 files changed, 5 insertions(+), 44 deletions(-) diff --git a/bin/ebuild-helpers/dodoc b/bin/ebuild-helpers/dodoc index 84936e400..e83091045 100755 --- a/bin/ebuild-helpers/dodoc +++ b/bin/ebuild-helpers/dodoc @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1 @@ -28,7 +28,6 @@ for x in "$@" ; do eqawarn "QA Notice: dodoc argument '${x}' is a directory" elif [ -s "${x}" ] ; then install -m0644 "${x}" "${dir}" || { ((ret|=1)); continue; } - ecompress --queue "${dir}/${x##*/}" elif [ ! -e "${x}" ] ; then echo "!!! ${0##*/}: $x does not exist" 1>&2 ((ret|=1)) diff --git a/bin/ebuild-helpers/prepinfo b/bin/ebuild-helpers/prepinfo index eb1b6a7e3..9d33e6e9a 100755 --- a/bin/ebuild-helpers/prepinfo +++ b/bin/ebuild-helpers/prepinfo @@ -34,5 +34,4 @@ find "${ED%/}/${infodir#/}" -type d -print0 | while read -r -d $'\0' x ; do rm -f "${x}"/dir{,.info}{,.gz,.bz2} done -___eapi_has_docompress && exit 0 -exec ecompressdir --queue "${infodir}" +exit 0 diff --git a/bin/ebuild-helpers/prepman b/bin/ebuild-helpers/prepman index 5e9fe45b6..4c6d47bb2 100755 --- a/bin/ebuild-helpers/prepman +++ b/bin/ebuild-helpers/prepman @@ -2,38 +2,7 @@ # Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# Do not compress man pages which are smaller than this (in bytes). #169260 -SIZE_LIMIT='128' - -source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1 - -if ! ___eapi_has_prefix_variables; then - ED=${D} -fi - -if [[ -z $1 ]] ; then - mandir="${ED%/}/usr/share/man" -else - mandir="${ED%/}/${1#/}/man" -fi - -if [[ ! -d ${mandir} ]] ; then - eqawarn "QA Notice: prepman called with non-existent dir '${mandir#${ED%/}}'" - exit 0 -fi - -# replaced by controllable compression in EAPI 4 -___eapi_has_docompress && exit 0 - -shopt -s nullglob - -really_is_mandir=0 - -# use some heuristics to test if this is a real mandir -for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do - [[ -d ${subdir} ]] && really_is_mandir=1 && break -done - -[[ ${really_is_mandir} == 1 ]] && exec ecompressdir --limit ${SIZE_LIMIT} --queue "${mandir#${ED%/}}" +# Note: this really does nothing these days. It's going to be banned +# when the last consumers are gone. exit 0 diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index d25bc8498..ed66e90ca 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -171,12 +171,6 @@ __prepall() { chflags -R nosunlnk,nouunlnk "${ED}" 2>/dev/null fi - if ! ___eapi_has_docompress; then - while IFS= read -r -d '' mandir ; do - mandir=${mandir#${ED}} - prepman "${mandir%/man}" - done < <(find "${ED}" -type d -name man -print0) - fi [[ -d ${ED%/}/usr/share/info ]] && prepinfo ___eapi_has_dostrip || prepallstrip @@ -245,7 +239,7 @@ install_qa_check() { export STRIP_MASK __prepall - ___eapi_has_docompress && prepcompress + prepcompress ecompressdir --dequeue ecompress --dequeue -- 2.19.0
Re: [gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path
On 09/17/2018 02:52 AM, Michał Górny wrote: > > --- a/bin/ebuild-helpers/fowners > +++ b/bin/ebuild-helpers/fowners > ... > + eqawarn "This is unsupported. Please use 'chmod' when you need > to work on files" This one should be 'chown' instead of 'chmod'. (Calling chown on the live filesystem is often also a dangerous mistake, but this probably isn't the place to fuss about it.)
[gentoo-portage-dev] [PATCH] estrip: Use find -delete instead of manual rm
--- bin/estrip | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/estrip b/bin/estrip index 5709b862c..3ee4b01ac 100755 --- a/bin/estrip +++ b/bin/estrip @@ -363,10 +363,9 @@ done < <( ) else while IFS= read -d '' -r x ; do - rm -f "${x}" || die inode_link=$(get_inode_number "${x%.estrip}") || die "stat failed unexpectedly" echo "${x%.estrip}" >> "${inode_link}" || die "echo failed unexpectedly" -done < <(find "${ED}" -name '*.estrip' -print0) +done < <(find "${ED}" -name '*.estrip' -delete -print0) fi # Now we look for unstripped binaries. -- 2.19.0
[gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path
--- bin/ebuild-helpers/fowners | 15 +++ bin/ebuild-helpers/fperms | 15 +++ 2 files changed, 30 insertions(+) diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners index 68004210b..70297c6e6 100755 --- a/bin/ebuild-helpers/fowners +++ b/bin/ebuild-helpers/fowners @@ -8,6 +8,21 @@ if ! ___eapi_has_prefix_variables; then EPREFIX= ED=${D} fi +got_owner= +for arg; do + [[ ${arg} == -* ]] && continue + if [[ ! ${got_owner} ]]; then + got_owner=1 + continue + fi + if [[ ${arg} != /* ]]; then + eqawarn "Relative path passed to '${0##*/}': ${arg}" + eqawarn "This is unsupported. Please use 'chmod' when you need to work on files" + eqawarn "outside the installation image (\${ED})." + fi +done + + # we can't prefix all arguments because # chown takes random options slash="/" diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms index c63a6abc3..f98560039 100755 --- a/bin/ebuild-helpers/fperms +++ b/bin/ebuild-helpers/fperms @@ -8,6 +8,21 @@ if ! ___eapi_has_prefix_variables; then ED=${D} fi +got_mode= +for arg; do + # - can either be an option or a mode string + [[ ${arg} == -* && ${arg} != -[ugorwxXst] ]] && continue + if [[ ! ${got_mode} ]]; then + got_mode=1 + continue + fi + if [[ ${arg} != /* ]]; then + eqawarn "Relative path passed to '${0##*/}': ${arg}" + eqawarn "This is unsupported. Please use 'chmod' when you need to work on files" + eqawarn "outside the installation image (\${ED})." + fi +done + # we can't prefix all arguments because # chmod takes random options slash="/" -- 2.19.0
Re: [gentoo-portage-dev] [PATCH v2 4/4] Ban prepall in ebuild scope
On Sun, 2018-09-16 at 16:09 -0700, Zac Medico wrote: > On 09/15/2018 06:45 AM, Michał Górny wrote: > > --- > > bin/ebuild-helpers/prepall | 28 ++-- > > bin/misc-functions.sh | 27 ++- > > 2 files changed, 28 insertions(+), 27 deletions(-) > > > > Changed in v2: > > - fixed calling prepallstrip in EAPI 7 > > This series looks good. Please merge. Thanks for the review. Merged now. -- Best regards, Michał Górny signature.asc Description: This is a digitally signed message part