aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-08 18:47:40 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-08 18:47:40 +0000
commitdf18a075fbe923ad91069d6d4cc8134e25e9e921 (patch)
tree7c15453caa47d6bd613d376879957ee01e859599
parent97950b5096603c92fb4cf3a6e530bc54e4a7031e (diff)
downloadpaludis-df18a075fbe923ad91069d6d4cc8134e25e9e921.tar.gz
paludis-df18a075fbe923ad91069d6d4cc8134e25e9e921.tar.xz
Use our own extractor for .pax binaries
-rw-r--r--.gitignore1
-rw-r--r--paludis/repositories/e/ebuild/pbin-1/builtin_installbin.bash13
-rw-r--r--paludis/repositories/e/ebuild/pbin-1/builtin_pivotbin.bash12
-rw-r--r--paludis/repositories/e/ebuild/utils/Makefile.am10
-rw-r--r--paludis/repositories/e/ebuild/utils/unpaxinate.cc76
5 files changed, 107 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index c4779d1..10b8883 100644
--- a/.gitignore
+++ b/.gitignore
@@ -339,6 +339,7 @@ paludis-*.*.*.tar.bz2
/paludis/repositories/e/ebuild/utils/prepman
/paludis/repositories/e/ebuild/utils/prepstrip
/paludis/repositories/e/ebuild/utils/print_exports
+/paludis/repositories/e/ebuild/utils/unpaxinate
/paludis/repositories/e/exndbam_repository_TEST
/paludis/repositories/e/fetch_visitor_TEST
/paludis/repositories/e/fix_locked_dependencies_TEST
diff --git a/paludis/repositories/e/ebuild/pbin-1/builtin_installbin.bash b/paludis/repositories/e/ebuild/pbin-1/builtin_installbin.bash
index eb20f96..b325e1a 100644
--- a/paludis/repositories/e/ebuild/pbin-1/builtin_installbin.bash
+++ b/paludis/repositories/e/ebuild/pbin-1/builtin_installbin.bash
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# vim: set sw=4 sts=4 et :
-# Copyright (c) 2008 Ciaran McCreesh
+# Copyright (c) 2008, 2010 Ciaran McCreesh
#
# This file is part of the Paludis package manager. Paludis is free software;
# you can redistribute it and/or modify it under the terms of the GNU General
@@ -18,8 +18,15 @@
builtin_installbin()
{
- echo tar jvxpf "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} -C "${IMAGE}"/ --exclude PBIN 1>&2
- tar jvxpf "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} -C "${IMAGE}"/ --exclude PBIN || die "Couldn't extract image"
+ if [[ ${!PALUDIS_ARCHIVES_VAR%.tar.bz2} != ${!PALUDIS_ARCHIVES_VAR} ]] ; then
+ echo tar jvxpf "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} -C "${IMAGE}"/ --exclude PBIN 1>&2
+ tar jvxpf "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} -C "${IMAGE}"/ --exclude PBIN || die "Couldn't extract image"
+ elif [[ ${!PALUDIS_ARCHIVES_VAR%.pax.bz2} != ${!PALUDIS_ARCHIVES_VAR} ]] ; then
+ echo unpaxinate img "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} "${IMAGE}" 1>&2
+ unpaxinate img "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} "${IMAGE}" || die "Couldn't extract image"
+ else
+ die "Unrecognised extension for '${!PALUDIS_ARCHIVES_VAR}'"
+ fi
}
generic_internal_installbin()
diff --git a/paludis/repositories/e/ebuild/pbin-1/builtin_pivotbin.bash b/paludis/repositories/e/ebuild/pbin-1/builtin_pivotbin.bash
index ade8467..5ef87c9 100644
--- a/paludis/repositories/e/ebuild/pbin-1/builtin_pivotbin.bash
+++ b/paludis/repositories/e/ebuild/pbin-1/builtin_pivotbin.bash
@@ -21,8 +21,16 @@ builtin_pivotbin()
[[ ! -d "${!PALUDIS_TEMP_DIR_VAR}" ]] && die "Can't use \${${PALUDIS_TEMP_DIR_VAR}}=${!PALUDIS_TEMP_DIR_VAR}"
ebuild_section "Extracting package environment"
- echo tar jxvf "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} -C "${!PALUDIS_TEMP_DIR_VAR}" --strip-components 1 PBIN/environment 1>&2
- tar jxvf "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} -C "${!PALUDIS_TEMP_DIR_VAR}" --strip-components 1 PBIN/environment || die "Couldn't extract env"
+
+ if [[ ${!PALUDIS_ARCHIVES_VAR%.tar.bz2} != ${!PALUDIS_ARCHIVES_VAR} ]] ; then
+ echo tar jxvf "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} -C "${!PALUDIS_TEMP_DIR_VAR}" --strip-components 1 PBIN/environment 1>&2
+ tar jxvf "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} -C "${!PALUDIS_TEMP_DIR_VAR}" --strip-components 1 PBIN/environment || die "Couldn't extract env"
+ elif [[ ${!PALUDIS_ARCHIVES_VAR%.pax.bz2} != ${!PALUDIS_ARCHIVES_VAR} ]] ; then
+ echo unpaxinate env "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} "${!PALUDIS_TEMP_DIR_VAR}" 1>&2
+ unpaxinate env "${!PALUDIS_BINARY_DISTDIR_VARIABLE}"/${!PALUDIS_ARCHIVES_VAR} "${!PALUDIS_TEMP_DIR_VAR}" || die "Couldn't extract env"
+ else
+ die "Unrecognised extension for '${!PALUDIS_ARCHIVES_VAR}'"
+ fi
ebuild_section "Switching to package environment"
export BINARY_REPOSITORY="${REPOSITORY}"
diff --git a/paludis/repositories/e/ebuild/utils/Makefile.am b/paludis/repositories/e/ebuild/utils/Makefile.am
index 68a55c3..934337a 100644
--- a/paludis/repositories/e/ebuild/utils/Makefile.am
+++ b/paludis/repositories/e/ebuild/utils/Makefile.am
@@ -61,6 +61,16 @@ libexecbin_PROGRAMS = \
print_exports \
locked_pipe_command
+if ENABLE_PBINS
+libexecbin_PROGRAMS += \
+ unpaxinate
+
+unpaxinate_SOURCES = unpaxinate.cc
+unpaxinate_CXXFLAGS = $(AM_CXXFLAGS)
+unpaxinate_LDADD = -larchive
+
+endif
+
print_exports_SOURCES = print_exports.cc
locked_pipe_command_SOURCES = locked_pipe_command.cc
diff --git a/paludis/repositories/e/ebuild/utils/unpaxinate.cc b/paludis/repositories/e/ebuild/utils/unpaxinate.cc
new file mode 100644
index 0000000..4bd9544
--- /dev/null
+++ b/paludis/repositories/e/ebuild/utils/unpaxinate.cc
@@ -0,0 +1,76 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include <iostream>
+#include <string>
+#include <cstdlib>
+
+#include <archive.h>
+#include <archive_entry.h>
+#include <unistd.h>
+
+#include "config.h"
+
+int main(int argc, char *argv[])
+{
+ if (argc != 4)
+ return EXIT_FAILURE;
+
+ bool want_env(false);
+ if (argv[1] == std::string("env"))
+ want_env = true;
+ else if (argv[1] == std::string("img"))
+ want_env = false;
+ else
+ return EXIT_FAILURE;
+
+ std::string archive_file(argv[2]);
+
+ if (0 != chdir(argv[3]))
+ return EXIT_FAILURE;
+
+ archive * archive(archive_read_new());
+ archive_read_support_compression_all(archive);
+ archive_read_support_format_all(archive);
+
+ if (ARCHIVE_OK != archive_read_open_filename(archive, archive_file.c_str(), 10240))
+ {
+ std::cerr << "Could not open '" << archive_file << "'" << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ archive_entry * entry;
+ while (ARCHIVE_OK == archive_read_next_header(archive, &entry))
+ {
+ std::string archive_filename(archive_entry_pathname(entry));
+ std::string out_filename;
+ if (archive_filename == "PBIN/environment" && want_env)
+ out_filename = "environment";
+ else if ((! want_env) && (0 != archive_filename.compare(0, 5, "PBIN/", 0, 5)))
+ out_filename = archive_filename;
+ else
+ {
+ archive_read_data_skip(archive);
+ continue;
+ }
+
+ std::cout << out_filename << std::endl;
+ archive_entry_set_pathname(entry, out_filename.c_str());
+
+ if (ARCHIVE_OK != archive_read_extract(archive, entry, ARCHIVE_EXTRACT_OWNER |
+ ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_ACL |
+ ARCHIVE_EXTRACT_FFLAGS | ARCHIVE_EXTRACT_XATTR | ARCHIVE_EXTRACT_SECURE_NODOTDOT))
+ {
+ std::cerr << "Could not extract '" << out_filename << "' from '" << archive_file << "'" << std::endl;
+ return EXIT_FAILURE;
+ }
+ }
+
+ if (ARCHIVE_OK != archive_read_finish(archive))
+ {
+ std::cerr << "Could not finish reading '" << archive_file << "'" << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
+