aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-03-06 16:04:20 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-03-06 16:04:20 +0000
commit2592e84abee0edfc7164732b116be430dc822090 (patch)
tree20295a93aec995d9c2462203a593fb71728ea36f
parent5433e9197a10f5bdd170fe70aac503e246c0731b (diff)
downloadpaludis-2592e84abee0edfc7164732b116be430dc822090.tar.gz
paludis-2592e84abee0edfc7164732b116be430dc822090.tar.xz
Replace builtin_strip with a common Stripper class. Support stripping when using importare. Fixes: ticket:424
-rw-r--r--NEWS3
-rw-r--r--paludis/Makefile.am.m47
-rw-r--r--paludis/files.m41
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/e_stripper.cc93
-rw-r--r--paludis/repositories/e/e_stripper.hh59
-rw-r--r--paludis/repositories/e/eapis/0.conf3
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf3
-rw-r--r--paludis/repositories/e/eapis/paludis-1.conf3
-rw-r--r--paludis/repositories/e/ebuild.cc26
-rw-r--r--paludis/repositories/e/ebuild.hh1
-rw-r--r--paludis/repositories/e/ebuild/0/Makefile.am1
-rw-r--r--paludis/repositories/e/ebuild/0/builtin_strip.bash86
-rwxr-xr-xpaludis/repositories/e/ebuild/ebuild.bash2
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/Makefile.am1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/builtin_strip.bash91
-rw-r--r--paludis/repositories/e/ebuild_entries.cc37
-rw-r--r--paludis/repositories/e/vdb_merger.cc2
-rw-r--r--paludis/repositories/unpackaged/Makefile.am2
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc23
-rw-r--r--paludis/repositories/unpackaged/unpackaged_stripper.cc93
-rw-r--r--paludis/repositories/unpackaged/unpackaged_stripper.hh59
-rw-r--r--paludis/stripper-fwd.hh38
-rw-r--r--paludis/stripper.cc178
-rw-r--r--paludis/stripper.hh63
-rw-r--r--paludis/stripper_TEST.cc87
-rw-r--r--paludis/stripper_TEST_binary.cc9
-rwxr-xr-xpaludis/stripper_TEST_cleanup.sh9
-rwxr-xr-xpaludis/stripper_TEST_setup.sh9
-rw-r--r--paludis/util/keys.hh1
30 files changed, 776 insertions, 216 deletions
diff --git a/NEWS b/NEWS
index 5c10e4d..80811ba 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ trunk/:
* paludis --owner now shows matching files when --full-match is not
specified.
+ * importare now does stripping the same way as E repositories, based upon
+ the --debug-build argument.
+
0.26.0_alpha10:
* rsync based syncers (rsync://, file://, tar+http:// and tar+ftp://) now
support --exclude in sync_options, as well as --exclude-from.
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index fe1f880..ebab107 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -81,7 +81,8 @@ DEFS= \
-DPYTHONINSTALLDIR=\"$(PYTHON_INSTALL_DIR)\"
EXTRA_DIST = about.hh.in Makefile.am.m4 paludis.hh.m4 files.m4 \
testscriptlist srlist srcleanlist selist secleanlist \
- repository_blacklist.txt hooker.bash
+ repository_blacklist.txt hooker.bash \
+ stripper_TEST_binary.cc
SUBDIRS = distributions fetchers syncers util selinux . repositories environments args
BUILT_SOURCES = srcleanlist secleanlist
@@ -131,10 +132,12 @@ dep_list_TEST_blockers_CXXFLAGS = -I$(top_srcdir) $(AM_CXXFLAGS)
TESTS = testlist
-check_PROGRAMS = $(TESTS)
+check_PROGRAMS = $(TESTS) stripper_TEST_binary
check_SCRIPTS = testscriptlist
check_LTLIBRARIES = libpaludissohooks_TEST.la
+stripper_TEST_binary_SOURCES = stripper_TEST_binary.cc
+
paludis_datadir = $(datadir)/paludis
paludis_data_DATA = repository_blacklist.txt
diff --git a/paludis/files.m4 b/paludis/files.m4
index bae636f..2ff1307 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -63,6 +63,7 @@ add(`slot_requirement', `hh', `fwd', `cc')
add(`stage_builder_task', `hh', `cc')
add(`stage_options', `sr')
add(`stringify_formatter', `hh', `cc', `fwd', `impl', `test')
+add(`stripper', `hh', `cc', `fwd', `test', `testscript')
add(`syncer', `hh', `cc')
add(`sync_task', `hh', `cc')
add(`tasks_exceptions', `hh', `cc')
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index af44046..d33dbd3 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -58,6 +58,7 @@ paludis_repositories_e_include_HEADERS = \
e_repository_profile.hh \
e_repository_profile_file.hh \
e_repository_sets.hh \
+ e_stripper.hh \
eapi.hh \
eapi-sr.hh \
eapi-fwd.hh \
@@ -115,6 +116,7 @@ libpaludiserepository_la_SOURCES = \
e_repository_profile.cc \
e_repository_profile_file.cc \
e_repository_sets.cc \
+ e_stripper.cc \
eapi.cc \
eapi_phase.cc \
ebuild.cc \
diff --git a/paludis/repositories/e/e_stripper.cc b/paludis/repositories/e/e_stripper.cc
new file mode 100644
index 0000000..1f32d5d
--- /dev/null
+++ b/paludis/repositories/e/e_stripper.cc
@@ -0,0 +1,93 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/e/e_stripper.hh>
+#include <paludis/util/kc.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <iostream>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EStripper>
+ {
+ EStripperOptions options;
+
+ Implementation(const EStripperOptions & o) :
+ options(o)
+ {
+ }
+ };
+}
+
+EStripper::EStripper(const EStripperOptions & options) :
+ Stripper(StripperOptions::named_create()
+ (k::image_dir(), options[k::image_dir()])
+ (k::debug_build(), options[k::debug_build()])
+ (k::debug_dir(), options[k::debug_dir()])
+ ),
+ PrivateImplementationPattern<EStripper>(new Implementation<EStripper>(options)),
+ _imp(PrivateImplementationPattern<EStripper>::_imp)
+{
+}
+
+EStripper::~EStripper()
+{
+}
+
+void
+EStripper::on_strip(const FSEntry & f)
+{
+ std::cout << "str " << f.strip_leading(_imp->options[k::image_dir()]) << std::endl;
+}
+
+void
+EStripper::on_split(const FSEntry & f, const FSEntry & g)
+{
+ std::cout << "spl " << f.strip_leading(_imp->options[k::image_dir()]) <<
+ " -> " << g.strip_leading(_imp->options[k::image_dir()]) << std::endl;
+}
+
+void
+EStripper::on_unknown(const FSEntry & f)
+{
+ std::cout << "--- " << f.strip_leading(_imp->options[k::image_dir()]) << std::endl;
+}
+
+void
+EStripper::on_enter_dir(const FSEntry &)
+{
+}
+
+void
+EStripper::on_leave_dir(const FSEntry &)
+{
+}
+
+void
+EStripper::strip()
+{
+ std::cout << ">>> Stripping inside " << _imp->options[k::image_dir()] << std::endl;
+ Stripper::strip();
+}
+
diff --git a/paludis/repositories/e/e_stripper.hh b/paludis/repositories/e/e_stripper.hh
new file mode 100644
index 0000000..14f97ba
--- /dev/null
+++ b/paludis/repositories/e/e_stripper.hh
@@ -0,0 +1,59 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_STRIPPER_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_STRIPPER_HH 1
+
+#include <paludis/stripper.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ typedef kc::KeyedClass<
+ kc::Field<k::package_id, tr1::shared_ptr<const PackageID> >,
+ kc::Field<k::image_dir, FSEntry>,
+ kc::Field<k::debug_dir, FSEntry>,
+ kc::Field<k::debug_build, InstallActionDebugOption>
+ > EStripperOptions;
+
+ class EStripper :
+ public Stripper,
+ private PrivateImplementationPattern<EStripper>
+ {
+ private:
+ PrivateImplementationPattern<EStripper>::ImpPtr & _imp;
+
+ protected:
+ virtual void on_strip(const FSEntry &);
+ virtual void on_split(const FSEntry &, const FSEntry &);
+ virtual void on_enter_dir(const FSEntry &);
+ virtual void on_leave_dir(const FSEntry &);
+ virtual void on_unknown(const FSEntry &);
+
+ public:
+ EStripper(const EStripperOptions &);
+ ~EStripper();
+
+ virtual void strip();
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/eapis/0.conf b/paludis/repositories/e/eapis/0.conf
index 68040a2..c594351 100644
--- a/paludis/repositories/e/eapis/0.conf
+++ b/paludis/repositories/e/eapis/0.conf
@@ -85,7 +85,8 @@ ebuild_install = \
sandbox userpriv : loadenv unpack compile saveenv ; \
sandbox userpriv checkphase checks=always : loadenv test saveenv ; \
sandbox : loadenv install saveenv ; \
- prepost : loadenv strip preinst saveenv ; \
+ strip : ; \
+ prepost : loadenv preinst saveenv ; \
merge : ; \
prepost : loadenv postinst saveenv ; \
: tidyup
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index 3d466b0..cebc519 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -90,7 +90,8 @@ ebuild_install = \
sandbox userpriv : loadenv unpack prepare configure compile saveenv ; \
sandbox userpriv checkphase checks=default checks=always : loadenv test saveenv ; \
sandbox : loadenv install saveenv ; \
- sandbox : loadenv strip preinst saveenv ; \
+ strip : ; \
+ sandbox : loadenv preinst saveenv ; \
merge : ; \
sandbox : loadenv postinst saveenv ; \
: tidyup
diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf
index d4335db..9b52811 100644
--- a/paludis/repositories/e/eapis/paludis-1.conf
+++ b/paludis/repositories/e/eapis/paludis-1.conf
@@ -91,7 +91,8 @@ ebuild_install = \
sandbox userpriv : loadenv unpack compile saveenv ; \
sandbox userpriv checkphase checks=default checks=always : loadenv test saveenv ; \
sandbox : loadenv install saveenv ; \
- sandbox : loadenv strip preinst saveenv ; \
+ strip : ; \
+ sandbox : loadenv preinst saveenv ; \
merge : ; \
sandbox : loadenv postinst saveenv ; \
: tidyup
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 4e71136..1b09b74 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -556,31 +556,6 @@ EbuildInstallCommand::failure()
Command
EbuildInstallCommand::extend_command(const Command & cmd)
{
- std::string debug_build;
- do
- {
- switch (install_params[k::debug_build()])
- {
- case iado_none:
- debug_build = "none";
- continue;
-
- case iado_split:
- debug_build = "split";
- continue;
-
- case iado_internal:
- debug_build = "internal";
- continue;
-
- case last_iado:
- break;
- }
-
- throw InternalError(PALUDIS_HERE, "Bad debug_build value");
- }
- while (false);
-
Command result(Command(cmd)
.with_setenv("A", install_params[k::a()])
.with_setenv("ROOT", install_params[k::root()])
@@ -589,7 +564,6 @@ EbuildInstallCommand::extend_command(const Command & cmd)
.with_setenv("PALUDIS_CONFIG_PROTECT_MASK", install_params[k::config_protect_mask()])
.with_setenv("PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK",
install_params[k::disable_cfgpro()] ? "/" : "")
- .with_setenv("PALUDIS_DEBUG_BUILD", debug_build)
.with_setenv("PALUDIS_PROFILE_DIR", stringify(*install_params[k::profiles()]->begin()))
.with_setenv("PALUDIS_PROFILE_DIRS", join(install_params[k::profiles()]->begin(),
install_params[k::profiles()]->end(), " "))
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index 012f9cc..d25702b 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -104,7 +104,6 @@ namespace paludis
kc::Field<k::profiles, tr1::shared_ptr<const FSEntrySequence> >,
kc::Field<k::expand_vars, tr1::shared_ptr<const Map<std::string, std::string> > >,
kc::Field<k::disable_cfgpro, bool>,
- kc::Field<k::debug_build, InstallActionDebugOption>,
kc::Field<k::slot, SlotName>,
kc::Field<k::config_protect, std::string>,
kc::Field<k::config_protect_mask, std::string>,
diff --git a/paludis/repositories/e/ebuild/0/Makefile.am b/paludis/repositories/e/ebuild/0/Makefile.am
index 38b4118..4c890d3 100644
--- a/paludis/repositories/e/ebuild/0/Makefile.am
+++ b/paludis/repositories/e/ebuild/0/Makefile.am
@@ -16,7 +16,6 @@ libexecprog0_SCRIPTS = \
builtin_killoldrm.bash \
builtin_killoldmisc.bash \
builtin_saveenv.bash \
- builtin_strip.bash \
builtin_tidyup.bash \
builtin_tidyuprm.bash \
builtin_tidyupmisc.bash \
diff --git a/paludis/repositories/e/ebuild/0/builtin_strip.bash b/paludis/repositories/e/ebuild/0/builtin_strip.bash
deleted file mode 100644
index 183e051..0000000
--- a/paludis/repositories/e/ebuild/0/builtin_strip.bash
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et :
-
-# Copyright (c) 2006 Ciaran McCreesh
-# Copyright (c) 2006 Stephen Bennett
-#
-# 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
-# Public License, version 2, as published by the Free Software Foundation.
-#
-# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-# Place, Suite 330, Boston, MA 02111-1307 USA
-
-builtin_strip()
-{
- STRIP=${STRIP:-${CHOST}-strip}
- if ! type -p -- ${STRIP} >/dev/null; then
- STRIP=strip
- fi
- PALUDIS_STRIP_FLAGS=${PALUDIS_STRIP_FLAGS:---strip-unneeded}
-
- if [[ "${PALUDIS_DEBUG_BUILD}" == "split" ]] ; then
- OBJCOPY=${OBJCOPY:-${CHOST}-objcopy}
- if ! type -p -- "${OBJCOPY}" &>/dev/null ; then
- OBJCOPY=objcopy
- fi
- if ! type -p -- "${OBJCOPY}" &>/dev/null ; then
- die "Can't work out what OBJCOPY should be"
- fi
- fi
-
- if [[ -d "${ROOT}/usr/lib" ]] ; then
- LIBDIR=$(basename "$(canonicalise "${ROOT}/usr/lib")")
- else
- LIBDIR="lib"
- fi
-
- for fn in $(find "${D}" -type f \
- \( -perm -0100 -or -perm -0010 -or -perm -0001 -or -name '*.so' -or -name '*.so.*' \)); do
- local ft=$(file "${fn}")
- if [[ $? != 0 || -z ${ft} ]]; then
- return 1
- fi
-
- if [[ ${ft} == *"current ar archive"* ]]; then
- if [[ "${PALUDIS_DEBUG_BUILD}" != "internal" ]] ; then
- echo ${STRIP} -g "${fn}"
- ${STRIP} -g "${fn}"
- fi
- elif [[ ${ft} == *"SB executable"* || ${ft} == *"SB shared object"* ]]; then
- if [[ "${PALUDIS_DEBUG_BUILD}" == "split" ]] ; then
- local fd="${D}usr/${LIBDIR}/debug/${fn:${#D}}.debug"
- mkdir -p "$(dirname "${fd}" )"
- echo ${OBJCOPY} --only-keep-debug "${fn}" "${fd}"
- ${OBJCOPY} --only-keep-debug "${fn}" "${fd}"
- echo ${OBJCOPY} --add-gnu-debuglink="${fd}" "${fn}"
- ${OBJCOPY} --add-gnu-debuglink="${fd}" "${fn}"
- chmod a-x,o-w "${fd}"
- fi
- if [[ "${PALUDIS_DEBUG_BUILD}" != "internal" ]] ; then
- echo ${STRIP} ${PALUDIS_STRIP_FLAGS} "${fn}"
- ${STRIP} ${PALUDIS_STRIP_FLAGS} "${fn}"
- fi
- fi
- done
-}
-
-ebuild_f_strip()
-{
- if hasq "strip" ${RESTRICT} ; then
- ebuild_section "Skipping builtin_strip (RESTRICT)"
- elif hasq "strip" ${SKIP_FUNCTIONS} ; then
- ebuild_section "Skipping builtin_strip (SKIP_FUNCTIONS)"
- else
- ebuild_section "Starting builtin_strip"
- builtin_strip
- ebuild_section "Done builtin_strip"
- fi
-}
-
diff --git a/paludis/repositories/e/ebuild/ebuild.bash b/paludis/repositories/e/ebuild/ebuild.bash
index 1ec7333..b677759 100755
--- a/paludis/repositories/e/ebuild/ebuild.bash
+++ b/paludis/repositories/e/ebuild/ebuild.bash
@@ -413,7 +413,7 @@ ebuild_main()
for action in $@ ; do
case ${action} in
metadata|variable|init|initmisc|initrm|killold|killoldmisc|killoldrm|merge|\
- unmerge|tidyup|tidyupmisc|tidyuprm|strip|loadenv|saveenv|initbin|\
+ unmerge|tidyup|tidyupmisc|tidyuprm|loadenv|saveenv|initbin|\
unpackbin|infovars|pivotbin|installbin)
ebuild_load_module builtin_${action}
;;
diff --git a/paludis/repositories/e/ebuild/exheres-0/Makefile.am b/paludis/repositories/e/ebuild/exheres-0/Makefile.am
index 3800e3f..e354d85 100644
--- a/paludis/repositories/e/ebuild/exheres-0/Makefile.am
+++ b/paludis/repositories/e/ebuild/exheres-0/Makefile.am
@@ -16,7 +16,6 @@ libexecprogexheres_SCRIPTS = \
builtin_killoldrm.bash \
builtin_killoldmisc.bash \
builtin_saveenv.bash \
- builtin_strip.bash \
builtin_tidyup.bash \
builtin_tidyuprm.bash \
builtin_tidyupmisc.bash \
diff --git a/paludis/repositories/e/ebuild/exheres-0/builtin_strip.bash b/paludis/repositories/e/ebuild/exheres-0/builtin_strip.bash
deleted file mode 100644
index 449e3bd..0000000
--- a/paludis/repositories/e/ebuild/exheres-0/builtin_strip.bash
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et :
-
-# Copyright (c) 2006, 2008 Ciaran McCreesh
-# Copyright (c) 2006 Stephen Bennett
-#
-# 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
-# Public License, version 2, as published by the Free Software Foundation.
-#
-# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-# Place, Suite 330, Boston, MA 02111-1307 USA
-
-builtin_strip()
-{
- STRIP=${STRIP:-${CHOST}-strip}
- if ! type -p -- ${STRIP} >/dev/null; then
- STRIP=strip
- fi
- PALUDIS_STRIP_FLAGS=${PALUDIS_STRIP_FLAGS:---strip-unneeded}
-
- if [[ "${PALUDIS_DEBUG_BUILD}" == "split" ]] ; then
- OBJCOPY=${OBJCOPY:-${CHOST}-objcopy}
- if ! type -p -- "${OBJCOPY}" &>/dev/null ; then
- OBJCOPY=objcopy
- fi
- if ! type -p -- "${OBJCOPY}" &>/dev/null ; then
- die "Can't work out what OBJCOPY should be"
- fi
- fi
-
- if [[ -d "${ROOT}/usr/lib" ]] ; then
- LIBDIR=$(basename "$(canonicalise "${ROOT}/usr/lib")")
- else
- LIBDIR="lib"
- fi
-
- for fn in $(find "${D}" -type f \
- \( -perm -0100 -or -perm -0010 -or -perm -0001 -or -name '*.so' -or -name '*.so.*' \)); do
- local ft=$(file "${fn}")
- if [[ $? != 0 || -z ${ft} ]]; then
- return 1
- fi
-
- if [[ ${ft} == *"current ar archive"* ]]; then
- if [[ "${PALUDIS_DEBUG_BUILD}" != "internal" ]] ; then
- echo ${STRIP} -g "${fn}"
- ${STRIP} -g "${fn}"
- fi
- elif [[ ${ft} == *"SB executable"* || ${ft} == *"SB shared object"* ]]; then
- if [[ "${PALUDIS_DEBUG_BUILD}" == "split" ]] ; then
- local fd="${D}usr/${LIBDIR}/debug/${fn:${#D}}.debug"
- mkdir -p "$(dirname "${fd}" )"
- echo ${OBJCOPY} --only-keep-debug "${fn}" "${fd}"
- ${OBJCOPY} --only-keep-debug "${fn}" "${fd}"
- echo ${OBJCOPY} --add-gnu-debuglink="${fd}" "${fn}"
- ${OBJCOPY} --add-gnu-debuglink="${fd}" "${fn}"
- chmod a-x,o-w "${fd}"
- fi
- if [[ "${PALUDIS_DEBUG_BUILD}" != "internal" ]] ; then
- echo ${STRIP} ${PALUDIS_STRIP_FLAGS} "${fn}"
- ${STRIP} ${PALUDIS_STRIP_FLAGS} "${fn}"
- fi
- fi
- done
-}
-
-exheres_internal_strip()
-{
- if hasq "strip" ${RESTRICT} ; then
- ebuild_section "Skipping builtin_strip (RESTRICT)"
- elif hasq "strip" ${SKIP_FUNCTIONS} ; then
- ebuild_section "Skipping builtin_strip (SKIP_FUNCTIONS)"
- else
- ebuild_section "Starting builtin_strip"
- builtin_strip
- ebuild_section "Done builtin_strip"
- fi
-}
-
-ebuild_f_strip()
-{
- exheres_internal_strip ""
-}
-
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index d21550a..11895e6 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -28,6 +28,7 @@
#include <paludis/repositories/e/fetch_visitor.hh>
#include <paludis/repositories/e/check_fetched_files_visitor.hh>
#include <paludis/repositories/e/aa_visitor.hh>
+#include <paludis/repositories/e/e_stripper.hh>
#include <paludis/action.hh>
#include <paludis/dep_spec_flattener.hh>
@@ -429,7 +430,7 @@ EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id,
Context context("When installing '" + stringify(*id) + "':");
- bool userpriv_restrict;
+ bool userpriv_restrict, strip_restrict;
{
DepSpecFlattener<RestrictSpecTree, PlainTextDepSpec> restricts(_imp->params.environment);
if (id->restrict_key())
@@ -440,6 +441,12 @@ EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id,
tr1::bind(std::equal_to<std::string>(), tr1::bind(tr1::mem_fn(&StringDepSpec::text), _1), "userpriv")) ||
indirect_iterator(restricts.end()) != std::find_if(indirect_iterator(restricts.begin()), indirect_iterator(restricts.end()),
tr1::bind(std::equal_to<std::string>(), tr1::bind(tr1::mem_fn(&StringDepSpec::text), _1), "nouserpriv"));
+
+ strip_restrict =
+ indirect_iterator(restricts.end()) != std::find_if(indirect_iterator(restricts.begin()), indirect_iterator(restricts.end()),
+ tr1::bind(std::equal_to<std::string>(), tr1::bind(tr1::mem_fn(&StringDepSpec::text), _1), "strip")) ||
+ indirect_iterator(restricts.end()) != std::find_if(indirect_iterator(restricts.begin()), indirect_iterator(restricts.end()),
+ tr1::bind(std::equal_to<std::string>(), tr1::bind(tr1::mem_fn(&StringDepSpec::text), _1), "nostrip"));
}
std::string archives, all_archives;
@@ -550,6 +557,33 @@ EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id,
(k::options(), (*(*id->eapi())[k::supported()])[k::merger_options()])
);
}
+ else if (phase->option("strip"))
+ {
+ if (! strip_restrict)
+ {
+ std::string libdir("lib");
+ FSEntry root(o[k::destination()]->installed_root_key() ?
+ stringify(o[k::destination()]->installed_root_key()->value()) : "/");
+ if ((root / "usr" / "lib").is_symbolic_link())
+ {
+ libdir = (root / "usr" / "lib").readlink();
+ if (std::string::npos != libdir.find_first_of("./"))
+ libdir = "lib";
+ }
+
+ Log::get_instance()->message(ll_debug, lc_context) << "Using '" << libdir << "' for libdir";
+
+ EStripper stripper(EStripperOptions::named_create()
+ (k::package_id(), id)
+ (k::image_dir(), _imp->params.builddir / stringify(id->name().category) / (stringify(id->name().package) + "-"
+ + stringify(id->version())) / "image")
+ (k::debug_dir(), _imp->params.builddir / stringify(id->name().category) / (stringify(id->name().package) + "-"
+ + stringify(id->version())) / "image" / "usr" / libdir / "debug")
+ (k::debug_build(), o[k::debug_build()])
+ );
+ stripper.strip();
+ }
+ }
else if ((! phase->option("prepost")) ||
((*o[k::destination()])[k::destination_interface()] &&
(*o[k::destination()])[k::destination_interface()]->want_pre_post_phases()))
@@ -605,7 +639,6 @@ EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id,
stringify(o[k::destination()]->installed_root_key()->value()) : "/")
(k::profiles(), _imp->params.profiles)
(k::disable_cfgpro(), o[k::no_config_protect()])
- (k::debug_build(), o[k::debug_build()])
(k::config_protect(), _imp->e_repository->profile_variable("CONFIG_PROTECT"))
(k::config_protect_mask(), _imp->e_repository->profile_variable("CONFIG_PROTECT_MASK"))
(k::loadsaveenv_dir(), _imp->params.builddir / stringify(id->name().category) / (
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index b4f9d39..b2af472 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -40,8 +40,6 @@
using namespace paludis;
-#include <iostream>
-
namespace paludis
{
template<>
diff --git a/paludis/repositories/unpackaged/Makefile.am b/paludis/repositories/unpackaged/Makefile.am
index 33bd1b9..a3656f9 100644
--- a/paludis/repositories/unpackaged/Makefile.am
+++ b/paludis/repositories/unpackaged/Makefile.am
@@ -27,6 +27,7 @@ paludis_repositories_unpackaged_include_HEADERS = \
unpackaged_repository.hh \
unpackaged_repository-sr.hh \
unpackaged_key.hh \
+ unpackaged_stripper.hh \
installed_repository.hh \
installed_repository-sr.hh \
installed_id.hh
@@ -38,6 +39,7 @@ libpaludisunpackagedrepository_la_SOURCES = \
unpackaged_id.cc \
unpackaged_repository.cc \
unpackaged_key.cc \
+ unpackaged_stripper.cc \
installed_repository.cc \
installed_id.cc \
registration.cc \
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index 594990b..b3032c7 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -19,6 +19,7 @@
#include <paludis/repositories/unpackaged/unpackaged_id.hh>
#include <paludis/repositories/unpackaged/unpackaged_key.hh>
+#include <paludis/repositories/unpackaged/unpackaged_stripper.hh>
#include <paludis/repositories/unpackaged/dep_parser.hh>
#include <paludis/repositories/unpackaged/dep_printer.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
@@ -28,6 +29,7 @@
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/kc.hh>
+#include <paludis/util/log.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/package_database.hh>
@@ -311,6 +313,27 @@ UnpackagedID::perform_action(Action & action) const
+ "' to destination '" + stringify(install_action->options[k::destination()]->name())
+ "' because destination does not provide destination_interface");
+ std::string libdir("lib");
+ FSEntry root(install_action->options[k::destination()]->installed_root_key() ?
+ stringify(install_action->options[k::destination()]->installed_root_key()->value()) : "/");
+ if ((root / "usr" / "lib").is_symbolic_link())
+ {
+ libdir = (root / "usr" / "lib").readlink();
+ if (std::string::npos != libdir.find_first_of("./"))
+ libdir = "lib";
+ }
+
+ Log::get_instance()->message(ll_debug, lc_context) << "Using '" << libdir << "' for libdir";
+
+ UnpackagedStripper stripper(UnpackagedStripperOptions::named_create()
+ (k::image_dir(), fs_location_key()->value())
+ (k::debug_dir(), fs_location_key()->value() / "usr" / libdir / "debug")
+ (k::debug_build(), install_action->options[k::debug_build()])
+ (k::package_id(), shared_from_this())
+ );
+
+ stripper.strip();
+
(*install_action->options[k::destination()])[k::destination_interface()]->merge(
MergeParams::named_create()
(k::package_id(), shared_from_this())
diff --git a/paludis/repositories/unpackaged/unpackaged_stripper.cc b/paludis/repositories/unpackaged/unpackaged_stripper.cc
new file mode 100644
index 0000000..670c237
--- /dev/null
+++ b/paludis/repositories/unpackaged/unpackaged_stripper.cc
@@ -0,0 +1,93 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/unpackaged/unpackaged_stripper.hh>
+#include <paludis/util/kc.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <iostream>
+
+using namespace paludis;
+using namespace paludis::unpackaged_repositories;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<UnpackagedStripper>
+ {
+ UnpackagedStripperOptions options;
+
+ Implementation(const UnpackagedStripperOptions & o) :
+ options(o)
+ {
+ }
+ };
+}
+
+UnpackagedStripper::UnpackagedStripper(const UnpackagedStripperOptions & options) :
+ Stripper(StripperOptions::named_create()
+ (k::image_dir(), options[k::image_dir()])
+ (k::debug_build(), options[k::debug_build()])
+ (k::debug_dir(), options[k::debug_dir()])
+ ),
+ PrivateImplementationPattern<UnpackagedStripper>(new Implementation<UnpackagedStripper>(options)),
+ _imp(PrivateImplementationPattern<UnpackagedStripper>::_imp)
+{
+}
+
+UnpackagedStripper::~UnpackagedStripper()
+{
+}
+
+void
+UnpackagedStripper::on_strip(const FSEntry & f)
+{
+ std::cout << "str " << f.strip_leading(_imp->options[k::image_dir()]) << std::endl;
+}
+
+void
+UnpackagedStripper::on_split(const FSEntry & f, const FSEntry & g)
+{
+ std::cout << "spl " << f.strip_leading(_imp->options[k::image_dir()]) <<
+ " -> " << g.strip_leading(_imp->options[k::image_dir()]) << std::endl;
+}
+
+void
+UnpackagedStripper::on_unknown(const FSEntry & f)
+{
+ std::cout << "--- " << f.strip_leading(_imp->options[k::image_dir()]) << std::endl;
+}
+
+void
+UnpackagedStripper::on_enter_dir(const FSEntry &)
+{
+}
+
+void
+UnpackagedStripper::on_leave_dir(const FSEntry &)
+{
+}
+
+void
+UnpackagedStripper::strip()
+{
+ std::cout << ">>> Stripping inside " << _imp->options[k::image_dir()] << std::endl;
+ Stripper::strip();
+}
+
diff --git a/paludis/repositories/unpackaged/unpackaged_stripper.hh b/paludis/repositories/unpackaged/unpackaged_stripper.hh
new file mode 100644
index 0000000..5cb0474
--- /dev/null
+++ b/paludis/repositories/unpackaged/unpackaged_stripper.hh
@@ -0,0 +1,59 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_UNPACKAGED_STRIPPER_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_UNPACKAGED_STRIPPER_HH 1
+
+#include <paludis/stripper.hh>
+
+namespace paludis
+{
+ namespace unpackaged_repositories
+ {
+ typedef kc::KeyedClass<
+ kc::Field<k::package_id, tr1::shared_ptr<const PackageID> >,
+ kc::Field<k::image_dir, FSEntry>,
+ kc::Field<k::debug_dir, FSEntry>,
+ kc::Field<k::debug_build, InstallActionDebugOption>
+ > UnpackagedStripperOptions;
+
+ class UnpackagedStripper :
+ public Stripper,
+ private PrivateImplementationPattern<UnpackagedStripper>
+ {
+ private:
+ PrivateImplementationPattern<UnpackagedStripper>::ImpPtr & _imp;
+
+ protected:
+ virtual void on_strip(const FSEntry &);
+ virtual void on_split(const FSEntry &, const FSEntry &);
+ virtual void on_enter_dir(const FSEntry &);
+ virtual void on_leave_dir(const FSEntry &);
+ virtual void on_unknown(const FSEntry &);
+
+ public:
+ UnpackagedStripper(const UnpackagedStripperOptions &);
+ ~UnpackagedStripper();
+
+ virtual void strip();
+ };
+ }
+}
+
+#endif
diff --git a/paludis/stripper-fwd.hh b/paludis/stripper-fwd.hh
new file mode 100644
index 0000000..0dd0e3b
--- /dev/null
+++ b/paludis/stripper-fwd.hh
@@ -0,0 +1,38 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_STRIPPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_STRIPPER_FWD_HH 1
+
+#include <paludis/util/kc-fwd.hh>
+#include <paludis/util/keys.hh>
+#include <paludis/action-fwd.hh>
+
+namespace paludis
+{
+ class Stripper;
+
+ typedef kc::KeyedClass<
+ kc::Field<k::image_dir, FSEntry>,
+ kc::Field<k::debug_dir, FSEntry>,
+ kc::Field<k::debug_build, InstallActionDebugOption>
+ > StripperOptions;
+}
+
+#endif
diff --git a/paludis/stripper.cc b/paludis/stripper.cc
new file mode 100644
index 0000000..0a58bee
--- /dev/null
+++ b/paludis/stripper.cc
@@ -0,0 +1,178 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/stripper.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/kc.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/system.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/tr1_functional.hh>
+#include <sstream>
+#include <list>
+#include <algorithm>
+#include <sys/stat.h>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<Stripper>
+ {
+ StripperOptions options;
+
+ Implementation(const StripperOptions & o) :
+ options(o)
+ {
+ }
+ };
+}
+
+Stripper::Stripper(const StripperOptions & options) :
+ PrivateImplementationPattern<Stripper>(new Implementation<Stripper>(options))
+{
+}
+
+Stripper::~Stripper()
+{
+}
+
+void
+Stripper::strip()
+{
+ Context context("When stripping image '" + stringify(_imp->options[k::image_dir()]) + "':");
+
+ if (_imp->options[k::debug_build()] == iado_internal)
+ return;
+
+ do_dir_recursive(_imp->options[k::image_dir()]);
+}
+
+void
+Stripper::do_dir_recursive(const FSEntry & f)
+{
+ Context context("When stripping inside '" + stringify(f) + "':");
+
+ if (f == _imp->options[k::debug_dir()])
+ return;
+
+ on_enter_dir(f);
+
+ for (DirIterator d(f, DirIteratorOptions() + dio_include_dotfiles + dio_inode_sort), d_end ; d != d_end ; ++d)
+ {
+ if (d->is_symbolic_link())
+ continue;
+
+ if (d->is_directory())
+ do_dir_recursive(*d);
+
+ else if (d->is_regular_file())
+ {
+ if (d->has_permission(fs_ug_owner, fs_perm_execute) ||
+ d->has_permission(fs_ug_group, fs_perm_execute) ||
+ d->has_permission(fs_ug_others, fs_perm_execute) ||
+ (std::string::npos != d->basename().find(".so.")) ||
+ (d->basename() != strip_trailing_string(d->basename(), ".so"))
+ )
+ {
+ std::string t(file_type(*d));
+ if (std::string::npos != t.find("SB executable") || std::string::npos != t.find("SB shared object"))
+ {
+ FSEntry target(_imp->options[k::debug_dir()] / d->strip_leading(_imp->options[k::image_dir()]));
+ target = target.dirname() / (target.basename() + ".debug");
+ on_split(*d, target);
+ do_split(*d, target);
+ }
+ else if (std::string::npos != t.find("current ar archive"))
+ {
+ on_strip(*d);
+ do_strip(*d, "-g");
+ }
+ else
+ on_unknown(*d);
+ }
+ }
+ }
+
+ on_leave_dir(f);
+}
+
+std::string
+Stripper::file_type(const FSEntry & f)
+{
+ Context context("When finding the file type of '" + stringify(f) + "':");
+
+ std::stringstream s;
+ if (0 != run_command(Command("file '" + stringify(f) + "'").with_captured_stdout_stream(&s)))
+ Log::get_instance()->message(ll_warning, lc_context) << "Couldn't work out the file type of '" << f << "'";
+
+ return s.str();
+}
+
+void
+Stripper::do_strip(const FSEntry & f, const std::string & options)
+{
+ Context context("When stripping '" + stringify(f) + "':");
+ if (0 != run_command(Command("strip " + options + " '" + stringify(f) + "'")))
+ Log::get_instance()->message(ll_warning, lc_context) << "Couldn't strip '" << f << "'";
+}
+
+void
+Stripper::do_split(const FSEntry & f, const FSEntry & g)
+{
+ Context context("When splitting '" + stringify(f) + "' to '" + stringify(g) + "':");
+
+ switch (_imp->options[k::debug_build()])
+ {
+ case iado_internal:
+ case last_iado:
+ return;
+
+ case iado_none:
+ do_strip(f, "");
+ return;
+
+ case iado_split:
+ break;
+ }
+
+ {
+ std::list<FSEntry> to_make;
+ for (FSEntry d(g.dirname()) ; (! d.exists()) && (d != _imp->options[k::image_dir()]) ; d = d.dirname())
+ to_make.push_front(d);
+
+ using namespace tr1::placeholders;
+ std::for_each(to_make.begin(), to_make.end(), tr1::bind(tr1::mem_fn(&FSEntry::mkdir), _1, 0755));
+ }
+
+ if (0 != run_command(Command("objcopy --only-keep-debug '" + stringify(f) + "' '" + stringify(g) + "'")))
+ Log::get_instance()->message(ll_warning, lc_context) << "Couldn't copy debug information for '" << f << "'";
+ else if (0 != run_command(Command("objcopy --add-gnu-debuglink='" + stringify(g) + "' '" + stringify(f) + "'")))
+ Log::get_instance()->message(ll_warning, lc_context) << "Couldn't add debug link for '" << f << "'";
+ else
+ {
+ FSEntry(g).chmod(g.permissions() & ~(S_IXGRP | S_IXUSR | S_IXOTH | S_IWOTH));
+ do_strip(f, "");
+ }
+}
+
diff --git a/paludis/stripper.hh b/paludis/stripper.hh
new file mode 100644
index 0000000..aef8a2d
--- /dev/null
+++ b/paludis/stripper.hh
@@ -0,0 +1,63 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_STRIPPER_HH
+#define PALUDIS_GUARD_PALUDIS_STRIPPER_HH 1
+
+#include <paludis/stripper-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE Stripper :
+ private PrivateImplementationPattern<Stripper>
+ {
+ protected:
+ virtual void on_enter_dir(const FSEntry &) = 0;
+ virtual void on_leave_dir(const FSEntry &) = 0;
+
+ virtual void on_strip(const FSEntry &) = 0;
+ virtual void on_split(const FSEntry &, const FSEntry &) = 0;
+ virtual void on_unknown(const FSEntry &) = 0;
+
+ virtual void do_dir_recursive(const FSEntry &);
+
+ virtual std::string file_type(const FSEntry &);
+
+ virtual void do_split(const FSEntry &, const FSEntry &);
+ virtual void do_strip(const FSEntry &, const std::string &);
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ Stripper(const StripperOptions &);
+ virtual ~Stripper() = 0;
+
+ ///\}
+
+ /**
+ * Perform the strip.
+ */
+ virtual void strip();
+ };
+}
+
+#endif
diff --git a/paludis/stripper_TEST.cc b/paludis/stripper_TEST.cc
new file mode 100644
index 0000000..81220a5
--- /dev/null
+++ b/paludis/stripper_TEST.cc
@@ -0,0 +1,87 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/stripper.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/kc.hh>
+#include <test/test_runner.hh>
+#include <test/test_framework.hh>
+
+using namespace test;
+using namespace paludis;
+
+namespace
+{
+ struct TestStripper :
+ Stripper
+ {
+ virtual void on_enter_dir(const FSEntry &)
+ {
+ }
+
+ virtual void on_leave_dir(const FSEntry &)
+ {
+ }
+
+
+ virtual void on_strip(const FSEntry &)
+ {
+ }
+
+ virtual void on_split(const FSEntry &, const FSEntry &)
+ {
+ }
+
+ virtual void on_unknown(const FSEntry &)
+ {
+ }
+
+ TestStripper(const StripperOptions & o) :
+ Stripper(o)
+ {
+ }
+ };
+}
+
+namespace test_cases
+{
+ struct StripperTest : TestCase
+ {
+ StripperTest() : TestCase("stripper") { }
+
+ void run()
+ {
+ TestStripper s(StripperOptions::named_create()
+ (k::image_dir(), FSEntry("stripper_TEST_dir/image").realpath())
+ (k::debug_dir(), FSEntry("stripper_TEST_dir/image").realpath() / "usr" / "lib" / "debug")
+ (k::debug_build(), iado_split)
+ );
+ s.strip();
+
+ TEST_CHECK(FSEntry("stripper_TEST_dir/image/usr/lib/debug/usr/bin/stripper_TEST_binary.debug").is_regular_file());
+ }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+ } test_stripper;
+}
+
diff --git a/paludis/stripper_TEST_binary.cc b/paludis/stripper_TEST_binary.cc
new file mode 100644
index 0000000..a5bd21a
--- /dev/null
+++ b/paludis/stripper_TEST_binary.cc
@@ -0,0 +1,9 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include <iostream>
+
+int main(int, char *[])
+{
+ std::cout << "What's this obsession with monkeys anyway?" << std::endl;
+}
+
diff --git a/paludis/stripper_TEST_cleanup.sh b/paludis/stripper_TEST_cleanup.sh
new file mode 100755
index 0000000..7d22786
--- /dev/null
+++ b/paludis/stripper_TEST_cleanup.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d stripper_TEST_dir ] ; then
+ rm -fr stripper_TEST_dir
+else
+ true
+fi
+
diff --git a/paludis/stripper_TEST_setup.sh b/paludis/stripper_TEST_setup.sh
new file mode 100755
index 0000000..f53e2f3
--- /dev/null
+++ b/paludis/stripper_TEST_setup.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir stripper_TEST_dir || exit 2
+cd stripper_TEST_dir || exit 3
+
+mkdir -p image/usr/bin || exit 5
+cp ../stripper_TEST_binary image/usr/bin || exit 6
+
diff --git a/paludis/util/keys.hh b/paludis/util/keys.hh
index 6e08e95..29125e4 100644
--- a/paludis/util/keys.hh
+++ b/paludis/util/keys.hh
@@ -151,6 +151,7 @@ namespace paludis
typedef kc::Key<122> env_portdir;
typedef kc::Key<123> env_distdir;
typedef kc::Key<124> description_use;
+ typedef kc::Key<125> debug_dir;
}
}