aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2009-02-09 23:42:41 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2009-02-09 23:42:41 +0000
commit0188868f3ec85fa793f57402e044e61e88335c23 (patch)
treee389da4fab89a3d24ed92b299b20d915f6b840b3
parent8772b7a5c74c3254a53e70a922e9e0a2bc1c09c3 (diff)
downloadpaludis-0188868f3ec85fa793f57402e044e61e88335c23.tar.gz
paludis-0188868f3ec85fa793f57402e044e61e88335c23.tar.xz
Refactor unpack, add EAPI-dependent suffixes, add .tar.xz and .xz
Also fix some silly bugs and lha retardedness.
-rw-r--r--paludis/repositories/e/eapi.cc1
-rw-r--r--paludis/repositories/e/eapi.hh2
-rw-r--r--paludis/repositories/e/eapis/0.conf2
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf2
-rw-r--r--paludis/repositories/e/eapis/paludis-1.conf2
-rw-r--r--paludis/repositories/e/ebuild.cc2
-rwxr-xr-xpaludis/repositories/e/ebuild/utils/unpack154
-rw-r--r--paludis/syncers/dotar.in3
8 files changed, 100 insertions, 68 deletions
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index f9af526..4139b36 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -207,6 +207,7 @@ namespace
value_for<n::dosym_mkdir>(destringify_key<bool>(k, "dosym_mkdir")),
value_for<n::failure_is_fatal>(destringify_key<bool>(k, "failure_is_fatal")),
value_for<n::unpack_fix_permissions>(destringify_key<bool>(k, "unpack_fix_permissions")),
+ value_for<n::unpack_suffixes>(k.get("unpack_suffixes")),
value_for<n::unpack_unrecognised_is_fatal>(destringify_key<bool>(k, "unpack_unrecognised_is_fatal"))
)));
}
diff --git a/paludis/repositories/e/eapi.hh b/paludis/repositories/e/eapi.hh
index f1bd57e..254c2e7 100644
--- a/paludis/repositories/e/eapi.hh
+++ b/paludis/repositories/e/eapi.hh
@@ -147,6 +147,7 @@ namespace paludis
struct supported;
struct tools_options;
struct unpack_fix_permissions;
+ struct unpack_suffixes;
struct unpack_unrecognised_is_fatal;
struct upstream_changelog;
struct upstream_documentation;
@@ -369,6 +370,7 @@ namespace paludis
NamedValue<n::dosym_mkdir, bool> dosym_mkdir;
NamedValue<n::failure_is_fatal, bool> failure_is_fatal;
NamedValue<n::unpack_fix_permissions, bool> unpack_fix_permissions;
+ NamedValue<n::unpack_suffixes, std::string> unpack_suffixes;
NamedValue<n::unpack_unrecognised_is_fatal, bool> unpack_unrecognised_is_fatal;
};
diff --git a/paludis/repositories/e/eapis/0.conf b/paludis/repositories/e/eapis/0.conf
index 6ee7489..103bf1e 100644
--- a/paludis/repositories/e/eapis/0.conf
+++ b/paludis/repositories/e/eapis/0.conf
@@ -255,3 +255,5 @@ doman_lang_filenames = false
dosym_mkdir = true
failure_is_fatal = false
+unpack_suffixes = tar tar.gz,tgz,tar.Z tar.bz2,tbz2,tbz zip,ZIP,jar gz,Z,z bz2 rar,RAR lha,LHa,LHA,lzh a,deb tar.lzma lzma 7z,7Z
+
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index e079ebf..e71229f 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -294,6 +294,8 @@ doman_lang_filenames = true
dosym_mkdir = false
failure_is_fatal = true
+unpack_suffixes = tar tar.gz,tgz,tar.Z tar.bz2,tbz2,tbz zip,ZIP,jar gz,Z,z bz2 rar,RAR lha,LHa,LHA,lzh a,deb tar.lzma lzma 7z,7Z tar.xz xz
+
annotations_myoptions_description = description
annotations_myoptions_requires = requires
annotations_myoptions_number_selected = number-selected
diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf
index 989c572..dbf298f 100644
--- a/paludis/repositories/e/eapis/paludis-1.conf
+++ b/paludis/repositories/e/eapis/paludis-1.conf
@@ -268,3 +268,5 @@ doman_lang_filenames = true
dosym_mkdir = false
failure_is_fatal = false
+unpack_suffixes = tar tar.gz,tgz,tar.Z tar.bz2,tbz2,tbz zip,ZIP,jar gz,Z,z bz2 rar,RAR lha,LHa,LHA,lzh a,deb tar.lzma lzma 7z,7Z tar.xz xz
+
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 245232a..bbd275d 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -191,6 +191,8 @@ EbuildCommand::operator() ()
params.package_id()->eapi()->supported()->tools_options()->unpack_unrecognised_is_fatal() ? "yes" : "")
.with_setenv("PALUDIS_UNPACK_FIX_PERMISSIONS",
params.package_id()->eapi()->supported()->tools_options()->unpack_fix_permissions() ? "yes" : "")
+ .with_setenv("PALUDIS_UNPACK_SUFFIXES",
+ params.package_id()->eapi()->supported()->tools_options()->unpack_suffixes())
.with_setenv("PALUDIS_DOMAN_LANG_FILENAMES",
params.package_id()->eapi()->supported()->tools_options()->doman_lang_filenames() ? "yes" : "")
.with_setenv("PALUDIS_DOSYM_NO_MKDIR",
diff --git a/paludis/repositories/e/ebuild/utils/unpack b/paludis/repositories/e/ebuild/utils/unpack
index 486c850..45ff590 100755
--- a/paludis/repositories/e/ebuild/utils/unpack
+++ b/paludis/repositories/e/ebuild/utils/unpack
@@ -36,92 +36,110 @@ assert()
[[ -z "${_pipestatus//[ 0]/}" ]] || die "$@: $_pipestatus"
}
-unpack_one()
-{
- [[ -z "$1" ]] && die "Bad argument for unpack_one"
- [[ -e "$1" ]] || die "${1} doesn't exist"
+unpack_tar() {
+ echo tar xf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" 1>&2
+ tar xf "${1}" --no-same-owner "${TAR_OPTIONS[@]}"
+}
- if [[ -n "${UNPACKONLY}" ]] ; then
- case "${x}" in
- *.tar.bz2|*.tbz2|*.tbz)
- ;;
+unpack_tar.gz() {
+ echo tar zxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" 1>&2
+ tar zxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}"
+}
- *)
- die "Can't use --only with ${x}"
- ;;
- esac
- fi
+unpack_tar.bz2() {
+ echo tar jxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" "${UNPACKONLY}" 1>&2
+ tar jxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" "${UNPACKONLY}"
+}
- case "${x}" in
- *.tar)
- echo tar xf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" 1>&2
- tar xf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" || die "Couldn't unpack ${1}"
- ;;
+unpack_zip() {
+ echo unzip -qo "${1}" 1>&2
+ unzip -qo "${1}"
+}
- *.tar.gz|*.tgz|*.tar.Z)
- echo tar zxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" 1>&2
- tar zxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" || die "Couldn't unpack ${1}"
- ;;
+unpack_gz() {
+ echo gzip -dc "${1}" \> "${UNPACKTODIR}/$(basename "${1%.*}" )" 1>&2
+ gzip -dc "${1}" > "${UNPACKTODIR}/$(basename "${1%.*}" )"
+}
- *.tar.bz2|*.tbz2|*.tbz)
- echo tar jxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" ${UNPACKONLY} 1>&2
- tar jxf "${1}" --no-same-owner "${TAR_OPTIONS[@]}" ${UNPACKONLY} || die "Couldn't unpack ${1}"
- ;;
+unpack_bz2() {
+ echo bzip2 -dc "${1}" \> "${UNPACKTODIR}/$(basename "${1%.*}" )" 1>&2
+ bzip2 -dc "${1}" > "${UNPACKTODIR}/$(basename "${1%.*}" )" || die "Couldn't unpack ${1}"
+}
- *.zip|*.ZIP|*.jar)
- echo unzip -qo "${1}" 1>&2
- unzip -qo "${1}" || die "Couldn't unpack ${1}"
- ;;
+unpack_rar() {
+ echo unrar x -idq "${1}" 1>&2
+ unrar x -idq "${1}"
+}
- *.gz|*.Z|*.z)
- echo gzip -dc "${1}" > ${UNPACKTODIR}/$(basename "${1%.*}" ) 1>&2
- gzip -dc "${1}" > ${UNPACKTODIR}/$(basename "${1%.*}" ) || die "Couldn't unpack ${1}"
- ;;
+unpack_lha() {
+ echo lha xfq "${1}" 1>&2
+ lha xfq "${1}"
+}
- *.bz2)
- echo bzip2 -dc "${1}" > ${UNPACKTODIR}/$(basename "${1%.*}" ) 1>&2
- bzip2 -dc "${1}" > ${UNPACKTODIR}/$(basename "${1%.*}" ) || die "Couldn't unpack ${1}"
- ;;
+unpack_a() {
+ echo ar x "${1}" 1>&2
+ ar x "${1}" 1>&2
+}
- *.rar|*.RAR)
- echo unrar x -idq "${1}" 1>&2
- unrar x -idq "${1}" || die "Couldn't unpack ${1}"
- ;;
+unpack_tar.lzma() {
+ echo lzma -dc "${1}" \| tar xf - --no-same-owner "${TAR_OPTIONS[@]}"
+ lzma -dc "${1}" | tar xf - --no-same-owner "${TAR_OPTIONS[@]}"
+ assert "Couldn't unpack ${1}"
+}
- *.LHa|*.LHA|*.lha|*.lzh)
- echo lha xqf "${1}" 1>&2
- lha xqf "${1}" || die "Couldn't unpack ${1}"
- ;;
+unpack_lzma() {
+ echo lzma -dc "${1}" \> "${UNPACKTODIR}/$(basename "${1%.*}" )" 1>&2
+ lzma -dc "${1}" > "${UNPACKTODIR}/$(basename "${1%.*}" )"
+}
- *.a|*.deb)
- echo ar x "${1}" 1>&2
- ar x "${1}" 1>&2
- ;;
+unpack_7z() {
+ echo 7z x -y "${1}"
+ 7z x -y "${1}"
+}
- *.tar.lzma)
- echo lzma -dc "${1}" \| tar xf - --no-same-owner "${TAR_OPTIONS[@]}"
- lzma -dc "${1}" | tar xf - --no-same-owner "${TAR_OPTIONS[@]}"
- assert "Couldn't unpack ${1}"
- ;;
+unpack_tar.xz() {
+ echo xz -dc "${1}" \| tar xf - --no-same-owner "${TAR_OPTIONS[@]}"
+ xz -dc "${1}" | tar xf - --no-same-owner "${TAR_OPTIONS[@]}"
+ assert "Couldn't unpack ${1}"
+}
+
+unpack_xz() {
+ echo xz -dc "${1}" \> "${UNPACKTODIR}/$(basename "${1%.*}" )" 1>&2
+ xz -dc "${1}" > "${UNPACKTODIR}/$(basename "${1%.*}" )"
+}
+
+unpack_one()
+{
+ [[ -z ${1} ]] && die "Bad argument for unpack_one"
+ [[ -e ${1} ]] || die "${1} doesn't exist"
- *.lzma)
- echo lzma -dc "${1}" > ${UNPACKTODIR}/$(basename "${1%.*}" ) 1>&2
- lzma -dc "${1}" > ${UNPACKTODIR}/$(basename "${1%.*}" ) || die "Couldn't unpack ${1}"
+ if [[ -n "${UNPACKONLY}" ]] ; then
+ case ${1} in
+ *.tar.bz2|*.tbz2|*.tbz)
;;
- *.7z|*.7Z)
- echo 7z x -y "${1}"
- 7z x -y "${1}" || die "Couldn't unpack ${1}"
+ *)
+ die "Can't use --only with ${x}"
;;
+ esac
+ fi
- *)
- if [[ -n "${PALUDIS_UNPACK_UNRECOGNISED_IS_FATAL}" ]] ; then
- die "Don't know how to unpack ${x}"
- else
- echo "Skipping unpack for ${1}"
+ local group split suffix
+ for group in ${PALUDIS_UNPACK_SUFFIXES}; do
+ split=( $(IFS=,; echo ${group} ) )
+ for suffix in ${split[@]}; do
+ if [[ ${1} == *.${suffix} ]]; then
+ unpack_${split[0]} "${1}" || die "Couldn't unpack ${1}"
+ return
fi
- ;;
- esac
+ done
+ done
+
+ if [[ -n "${PALUDIS_UNPACK_UNRECOGNISED_IS_FATAL}" ]] ; then
+ die "Don't know how to unpack ${x}"
+ else
+ echo "Skipping unpack for ${1}"
+ fi
}
export UNPACKFROMDIR="${!PALUDIS_UNPACK_FROM_VAR}"
diff --git a/paludis/syncers/dotar.in b/paludis/syncers/dotar.in
index 45e6f4d..40b112c 100644
--- a/paludis/syncers/dotar.in
+++ b/paludis/syncers/dotar.in
@@ -143,6 +143,9 @@ TARFILE="${URL##*/}"
UNPACKDIR="${TEMP}/repository"
mkdir "${UNPACKDIR}"
+export PALUDIS_UNPACK_SUFFIXES="tar tar.gz,tgz,tar.Z tar.bz2,tbz2,tbz zip,ZIP,jar rar,RAR lha,LHa,LHA,lzh a,deb tar.lzma 7z,7Z tar.xz"
+export PALUDIS_UNPACK_UNRECOGNISED_IS_FATAL=yes
+export PALUDIS_UNPACK_FIX_PERMISSIONS=
( cd "${UNPACKDIR}" && "${PALUDIS_EBUILD_DIR}/utils/unpack" \
"${UNPACK_OPTIONS[@]}" "${TEMP}/${TARFILE}" ) || exit $?