mirror of
https://github.com/flatcar/scripts.git
synced 2025-10-01 18:42:22 +02:00
eclass/unpacker: Sync with gentoo
It's from gentoo commit 26d0fb5ff1e39889d399621cc8fc796615dc3722.
This commit is contained in:
parent
e7ecc8d32f
commit
1b5ce589f9
@ -1,9 +1,10 @@
|
|||||||
# Copyright 1999-2017 Gentoo Foundation
|
# Copyright 1999-2022 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: unpacker.eclass
|
# @ECLASS: unpacker.eclass
|
||||||
# @MAINTAINER:
|
# @MAINTAINER:
|
||||||
# base-system@gentoo.org
|
# base-system@gentoo.org
|
||||||
|
# @SUPPORTED_EAPIS: 5 6 7 8
|
||||||
# @BLURB: helpers for extraneous file formats and consistent behavior across EAPIs
|
# @BLURB: helpers for extraneous file formats and consistent behavior across EAPIs
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Some extraneous file formats are not part of PMS, or are only in certain
|
# Some extraneous file formats are not part of PMS, or are only in certain
|
||||||
@ -14,10 +15,18 @@
|
|||||||
# - merge rpm unpacking
|
# - merge rpm unpacking
|
||||||
# - support partial unpacks?
|
# - support partial unpacks?
|
||||||
|
|
||||||
|
case ${EAPI:-0} in
|
||||||
|
[5678]) ;;
|
||||||
|
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [[ -z ${_UNPACKER_ECLASS} ]]; then
|
if [[ -z ${_UNPACKER_ECLASS} ]]; then
|
||||||
_UNPACKER_ECLASS=1
|
_UNPACKER_ECLASS=1
|
||||||
|
|
||||||
|
inherit toolchain-funcs
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: UNPACKER_BZ2
|
# @ECLASS-VARIABLE: UNPACKER_BZ2
|
||||||
|
# @USER_VARIABLE
|
||||||
# @DEFAULT_UNSET
|
# @DEFAULT_UNSET
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Utility to use to decompress bzip2 files. Will dynamically pick between
|
# Utility to use to decompress bzip2 files. Will dynamically pick between
|
||||||
@ -25,6 +34,7 @@ _UNPACKER_ECLASS=1
|
|||||||
# Note: this is meant for users to set, not ebuilds.
|
# Note: this is meant for users to set, not ebuilds.
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: UNPACKER_LZIP
|
# @ECLASS-VARIABLE: UNPACKER_LZIP
|
||||||
|
# @USER_VARIABLE
|
||||||
# @DEFAULT_UNSET
|
# @DEFAULT_UNSET
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Utility to use to decompress lzip files. Will dynamically pick between
|
# Utility to use to decompress lzip files. Will dynamically pick between
|
||||||
@ -279,7 +289,7 @@ unpack_deb() {
|
|||||||
done
|
done
|
||||||
} < "${deb}"
|
} < "${deb}"
|
||||||
else
|
else
|
||||||
ar x "${deb}"
|
$(tc-getBUILD_AR) x "${deb}" || die
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unpacker ./data.tar*
|
unpacker ./data.tar*
|
||||||
@ -325,6 +335,47 @@ unpack_zip() {
|
|||||||
[[ $? -le 1 ]] || die "unpacking ${zip} failed (arch=unpack_zip)"
|
[[ $? -le 1 ]] || die "unpacking ${zip} failed (arch=unpack_zip)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# @FUNCTION: unpack_7z
|
||||||
|
# @USAGE: <7z file>
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# Unpack 7z archives.
|
||||||
|
unpack_7z() {
|
||||||
|
[[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} <file>"
|
||||||
|
|
||||||
|
local p7z=$(find_unpackable_file "$1")
|
||||||
|
unpack_banner "${p7z}"
|
||||||
|
local output="$(7z x -y "${p7z}")"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "${output}" >&2
|
||||||
|
die "unpacking ${p7z} failed (arch=unpack_7z)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# @FUNCTION: unpack_rar
|
||||||
|
# @USAGE: <rar file>
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# Unpack RAR archives.
|
||||||
|
unpack_rar() {
|
||||||
|
[[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} <file>"
|
||||||
|
|
||||||
|
local rar=$(find_unpackable_file "$1")
|
||||||
|
unpack_banner "${rar}"
|
||||||
|
unrar x -idq -o+ "${rar}" || die "unpacking ${rar} failed (arch=unpack_rar)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# @FUNCTION: unpack_lha
|
||||||
|
# @USAGE: <lha file>
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# Unpack LHA/LZH archives.
|
||||||
|
unpack_lha() {
|
||||||
|
[[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} <file>"
|
||||||
|
|
||||||
|
local lha=$(find_unpackable_file "$1")
|
||||||
|
unpack_banner "${lha}"
|
||||||
|
lha xfq "${lha}" || die "unpacking ${lha} failed (arch=unpack_lha)"
|
||||||
|
}
|
||||||
|
|
||||||
# @FUNCTION: _unpacker
|
# @FUNCTION: _unpacker
|
||||||
# @USAGE: <one archive to unpack>
|
# @USAGE: <one archive to unpack>
|
||||||
# @INTERNAL
|
# @INTERNAL
|
||||||
@ -354,6 +405,8 @@ _unpacker() {
|
|||||||
*.lz)
|
*.lz)
|
||||||
: ${UNPACKER_LZIP:=$(type -P plzip || type -P pdlzip || type -P lzip)}
|
: ${UNPACKER_LZIP:=$(type -P plzip || type -P pdlzip || type -P lzip)}
|
||||||
comp="${UNPACKER_LZIP} -dc" ;;
|
comp="${UNPACKER_LZIP} -dc" ;;
|
||||||
|
*.zst)
|
||||||
|
comp="zstd -dfc" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# then figure out if there are any archiving aspects
|
# then figure out if there are any archiving aspects
|
||||||
@ -383,6 +436,18 @@ _unpacker() {
|
|||||||
arch="unpack_zip" ;;
|
arch="unpack_zip" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# 7z, rar and lha/lzh are handled by package manager in EAPI < 8
|
||||||
|
if [[ ${EAPI} != [567] ]]; then
|
||||||
|
case ${m} in
|
||||||
|
*.7z)
|
||||||
|
arch="unpack_7z" ;;
|
||||||
|
*.rar|*.RAR)
|
||||||
|
arch="unpack_rar" ;;
|
||||||
|
*.LHA|*.LHa|*.lha|*.lzh)
|
||||||
|
arch="unpack_lha" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
# finally do the unpack
|
# finally do the unpack
|
||||||
if [[ -z ${arch}${comp} ]] ; then
|
if [[ -z ${arch}${comp} ]] ; then
|
||||||
unpack "$1"
|
unpack "$1"
|
||||||
@ -444,9 +509,6 @@ unpacker_src_uri_depends() {
|
|||||||
case ${uri} in
|
case ${uri} in
|
||||||
*.cpio.*|*.cpio)
|
*.cpio.*|*.cpio)
|
||||||
d="app-arch/cpio" ;;
|
d="app-arch/cpio" ;;
|
||||||
*.deb)
|
|
||||||
# platforms like AIX don't have a good ar
|
|
||||||
d="kernel_AIX? ( app-arch/deb2targz )" ;;
|
|
||||||
*.rar|*.RAR)
|
*.rar|*.RAR)
|
||||||
d="app-arch/unrar" ;;
|
d="app-arch/unrar" ;;
|
||||||
*.7z)
|
*.7z)
|
||||||
@ -457,6 +519,10 @@ unpacker_src_uri_depends() {
|
|||||||
d="app-arch/unzip" ;;
|
d="app-arch/unzip" ;;
|
||||||
*.lz)
|
*.lz)
|
||||||
d="|| ( app-arch/plzip app-arch/pdlzip app-arch/lzip )" ;;
|
d="|| ( app-arch/plzip app-arch/pdlzip app-arch/lzip )" ;;
|
||||||
|
*.zst)
|
||||||
|
d="app-arch/zstd" ;;
|
||||||
|
*.LHA|*.LHa|*.lha|*.lzh)
|
||||||
|
d="app-arch/lha" ;;
|
||||||
esac
|
esac
|
||||||
deps+=" ${d}"
|
deps+=" ${d}"
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user