• [gentoo-dev] [PATCH 0/5] unpacker.eclass: makeself improvements + tests

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Wed Sep 28 23:00:01 2022
    Hi,

    Here's a smaller batch for unpacker.eclass. It includes:

    - adding support for makeself 2.4.5, i.e. the only version in ::gentoo
    (which is also pretty easy to support, unlike earlier versions)

    - adding support for all (reasonable) compression methods that makeself
    2.4.5 supports, including base64 encoding (I've omitted gpg, I don't
    think we can reasonably expect that)

    - adding tests for makeself support

    Please review.

    Also as a PR: https://github.com/gentoo/gentoo/pull/27507


    Michał Górny (5):
    unpacker.eclass: Add support for makeself 2.4.5
    unpacker.eclass: Reuse _unpacker_get_decompressor for makeself
    unpacker.eclass: Support all makeself "compression" methods
    eclass/tests/unpacker.sh: Add tests for makeself
    unpacker.eclass: Check makeself compression without a tempfile

    eclass/tests/unpacker.sh | 29 ++++++++++++++++++++++++++++
    eclass/unpacker.eclass | 41 ++++++++++++++++++++++++++++++----------
    2 files changed, 60 insertions(+), 10 deletions(-)

    --
    2.37.3

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Wed Sep 28 23:00:01 2022
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/unpacker.eclass | 18 ++++++++++--------
    1 file changed, 10 insertions(+), 8 deletions(-)

    diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
    index 86641621c949..660cafce5105 100644
    --- a/eclass/unpacker.eclass
    +++ b/eclass/unpacker.eclass
    @@ -243,30 +243,32 @@ unpack_makeself() {
    esac

    # lets grab the first few bytes of the file to figure out what kind of archive it is
    - local filetype tmpfile="${T}/${FUNCNAME}"
    + local decomp= filetype suffix tmpfile="${T}/${FUNCNAME}"
    "${exe[@]}" 2>/dev/null | head -c 512 > "${tmpfile}"
    filetype=$(file -b "${tmpfile}") || die
    case ${filetype} in
    *tar\ archive*)
    - "${exe[@]}" | tar --no-same-owner -xf -
    + decomp=cat
    ;;
    bzip2*)
    - "${exe[@]}" | bzip2 -dc | tar --no-same-owner -xf -
    + suffix=bz2
    ;;
    gzip*)
    - "${exe[@]}" | tar --no-same-owner -xzf -
    + suffix=gz
    ;;
    compress*)
    - "${exe[@]}" | gunzip | tar --no-same-owner -xf -
    + suffix=z
    ;;
    XZ*)
    - "${exe[@]}" | unxz |
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Wed Sep 28 23:10:01 2022
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/unpacker.eclass | 12 ++++++++++++
    1 file changed, 12 insertions(+)

    diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
    index 660cafce5105..dfcb111e00f5 100644
    --- a/eclass/unpacker.eclass
    +++ b/eclass/unpacker.eclass
    @@ -262,6 +262,18 @@ unpack_makeself() {
    XZ*)
    suffix=xz
    ;;
    + Zstandard*)
    + suffix=zst
    + ;;
    + lzop*)
    + suffix=lzo
    + ;;
    + LZ4*)
    + suffix=lz4
    + ;;
    + "ASCII text"*)
    + decomp='base64 -d'
    + ;;
    *)
    die "Unknown filetype \"${filetype}\", for makeself ${src##*/} ('${ver}' +${skip})"
    ;;
    --
    2.37.3

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Wed Sep 28 23:10:01 2022
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/tests/unpacker.sh | 29 +++++++++++++++++++++++++++++
    1 file changed, 29 insertions(+)

    diff --git a/eclass/tests/unpacker.sh b/eclass/tests/unpacker.sh
    index b15953966f65..175975798731 100755
    --- a/eclass/tests/unpacker.sh
    +++ b/eclass/tests/unpacker.sh
    @@ -177,6 +177,25 @@ test_gpkg() {
    "create_gpkg '${suffix}' '${tool_cmd}' \${archive} \${TESTFILE}"
    }

    +create_makeself() {
    + local comp_opt=${1}
    + local archive=${2}
    + local infile=${3}
    +
    + mkdir test || die
    + cp "${infile}" test/ || die
    + makeself --quiet "${comp_opt}" test "${archive}" test : || die
    + rm -rf test || die
    +}
    +
    +test_makeself() {
    + local comp_opt=${1}
    + local tool=${2}
    +
    + test_unpack "makeself-${tool}.sh" test.in "makeself ${tool}" \
    + "create_makeself '${comp_opt}' \${archive} \${TESTFILE}"
    +}
    +
    test_reject_junk() {
    local suffix=${1}
    local archive=test${1}
    @@ -260,6 +279,16 @@ test_gpkg .lzo lzop
    test_gpkg .xz xz
    test_gpkg .zst zstd

    +test_makeself --gzip gzip
    +test_makeself --z
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Wed Sep 28 23:10:01 2022
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/unpacker.eclass | 5 ++---
    1 file changed, 2 insertions(+), 3 deletions(-)

    diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
    index dfcb111e00f5..02000dd5d911 100644
    --- a/eclass/unpacker.eclass
    +++ b/eclass/unpacker.eclass
    @@ -243,9 +243,8 @@ unpack_makeself() {
    esac

    # lets grab the first few bytes of the file to figure out what kind of archive it is
    - local decomp= filetype suffix tmpfile="${T}/${FUNCNAME}"
    - "${exe[@]}" 2>/dev/null | head -c 512 > "${tmpfile}"
    - filetype=$(file -b "${tmpfile}") || die
    + local decomp= filetype suffix
    + filetype=$("${exe[@]}" 2>/dev/null | head -c 512 | file -b -) || die
    case ${filetype} in
    *tar\ archive*)
    decomp=cat
    --
    2.37.3

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Thu Sep 29 12:50:01 2022
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/tests/unpacker.sh | 105 +++++++++++++++++++++++++++++++++++++++
    1 file changed, 105 insertions(+)

    diff --git a/eclass/tests/unpacker.sh b/eclass/tests/unpacker.sh
    index ea9e64d0a4c7..ef17e724a851 100755
    --- a/eclass/tests/unpacker.sh
    +++ b/eclass/tests/unpacker.sh
    @@ -223,6 +223,67 @@ test_reject_junk() {
    rm -f "${archive}" || die
    }

    +test_online() {
    + local url=${1}
    + local b2sum=${2}
    + local unpacked=${3}
    + local unp_b2sum=${4}
    +
    + local filename=${url##*/}
    + local archive=${DISTDIR}/${filename}
    +
    + if [[ ! -f ${archive} ]]; then
    + if [[ ${UNPACKER_TESTS_ONLINE} != 1 ]]; then
    + ewarn "Skipping ${filename} test, distfile not found"
    + return
    + fi
    +
    + if ! wget -O "${archive}" "${url}"; then
    + die "Fetching ${archive} failed"
    + fi
    + fi
    +
    + local real_sum=$(b2sum "${archive}" | cut -d' ' -f1)
    + if [[ ${real_sum} != ${b2sum} ]]; then
    + eerror "Incorrect b2sum on ${filename}"
    + eerror " expected: ${b2sum}"
    + eerror " found: ${real_sum}"
    + di