aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-31 19:41:29 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-31 19:41:29 +0000
commit6f7d9ca583cf4422f416418ca06b7a631ae32468 (patch)
tree7f9b204a8519a69c1be112804ebe83cabe9b08ed
parente921564062c9939613f49a85aa80ca35de0d7a76 (diff)
downloadpaludis-6f7d9ca583cf4422f416418ca06b7a631ae32468.tar.gz
paludis-6f7d9ca583cf4422f416418ca06b7a631ae32468.tar.xz
Add a 'prepare' ebuild phase before 'init' to perform non-userpriv cleanup. Fixes: ticket:175
-rw-r--r--paludis/repositories/gentoo/ebuild.cc3
-rw-r--r--paludis/repositories/gentoo/ebuild.se1
-rw-r--r--paludis/repositories/gentoo/ebuild/Makefile.am1
-rw-r--r--paludis/repositories/gentoo/ebuild/builtin_prepare.bash49
-rwxr-xr-xpaludis/repositories/gentoo/ebuild/ebuild.bash5
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.cc6
6 files changed, 62 insertions, 3 deletions
diff --git a/paludis/repositories/gentoo/ebuild.cc b/paludis/repositories/gentoo/ebuild.cc
index bcac3d4..522671d 100644
--- a/paludis/repositories/gentoo/ebuild.cc
+++ b/paludis/repositories/gentoo/ebuild.cc
@@ -313,6 +313,9 @@ EbuildInstallCommand::commands() const
{
switch (install_params.phase)
{
+ case ebuild_ip_prepare:
+ return "prepare";
+
case ebuild_ip_init:
return "init saveenv";
diff --git a/paludis/repositories/gentoo/ebuild.se b/paludis/repositories/gentoo/ebuild.se
index 987b02c..78e206b 100644
--- a/paludis/repositories/gentoo/ebuild.se
+++ b/paludis/repositories/gentoo/ebuild.se
@@ -5,6 +5,7 @@ make_enum_EbuildInstallCommandPhase()
{
prefix ebuild_ip
+ key ebuild_ip_prepare "Prepare the filesystem."
key ebuild_ip_init "Initialise the package."
key ebuild_ip_setup "Set up the package."
key ebuild_ip_build "Build the package."
diff --git a/paludis/repositories/gentoo/ebuild/Makefile.am b/paludis/repositories/gentoo/ebuild/Makefile.am
index a1fe31c..94c4b57 100644
--- a/paludis/repositories/gentoo/ebuild/Makefile.am
+++ b/paludis/repositories/gentoo/ebuild/Makefile.am
@@ -15,6 +15,7 @@ libexecprog_SCRIPTS = \
builtin_loadenv.bash \
builtin_merge.bash \
builtin_metadata.bash \
+ builtin_prepare.bash \
builtin_saveenv.bash \
builtin_strip.bash \
builtin_tidyup.bash \
diff --git a/paludis/repositories/gentoo/ebuild/builtin_prepare.bash b/paludis/repositories/gentoo/ebuild/builtin_prepare.bash
new file mode 100644
index 0000000..4a1195e
--- /dev/null
+++ b/paludis/repositories/gentoo/ebuild/builtin_prepare.bash
@@ -0,0 +1,49 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+#
+# 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_prepare()
+{
+ export ROOT="${ROOT//+(\/)//}"
+
+ local a
+ for a in PF CATEGORY PALUDIS_TMPDIR ; do
+ [[ -z "${!a}" ]] && die "\$${a} unset or empty"
+ done
+
+ if [[ -e "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" ]] ; then
+ if type -p chflags &>/dev/null; then
+ chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" || die "Couldn't remove flags from workdir"
+ fi
+ rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}" || die "Couldn't remove previous work"
+ fi
+}
+
+ebuild_f_prepare()
+{
+ if hasq "prepare" ${RESTRICT} ; then
+ ebuild_section "Skipping builtin_prepare (RESTRICT)"
+ elif hasq "prepare" ${SKIP_FUNCTIONS} ; then
+ ebuild_section "Skipping builtin_prepare (SKIP_FUNCTIONS)"
+ else
+ ebuild_section "Starting builtin_prepare"
+ builtin_prepare
+ ebuild_section "Done builtin_prepare"
+ fi
+}
+
+
diff --git a/paludis/repositories/gentoo/ebuild/ebuild.bash b/paludis/repositories/gentoo/ebuild/ebuild.bash
index 05cb910..0f30cbf 100755
--- a/paludis/repositories/gentoo/ebuild/ebuild.bash
+++ b/paludis/repositories/gentoo/ebuild/ebuild.bash
@@ -303,12 +303,13 @@ ebuild_main()
if [[ ${#@} -ge 2 ]] ; then
ebuild_section "Running ebuild phases $@ as $(id -un ):$(id -gn )..."
elif [[ ${1} != variable ]] && [[ ${1} != metadata ]] ; then
- ebuild_section "Running ebuild phase $@..."
+ ebuild_section "Running ebuild phase $@ as $(id -un ):$(id -gn )..."
fi
for action in $@ ; do
case ${action} in
- metadata|variable|init|fetch|merge|unmerge|tidyup|strip|loadenv|saveenv|fetchbin|initbin|unpackbin)
+ metadata|variable|init|prepare|fetch|merge|unmerge|tidyup|\
+ strip|loadenv|saveenv|fetchbin|initbin|unpackbin)
ebuild_load_module builtin_${action}
;;
diff --git a/paludis/repositories/gentoo/ebuild_entries.cc b/paludis/repositories/gentoo/ebuild_entries.cc
index 1c79675..faf6a8f 100644
--- a/paludis/repositories/gentoo/ebuild_entries.cc
+++ b/paludis/repositories/gentoo/ebuild_entries.cc
@@ -544,7 +544,7 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
EbuildInstallCommandParams install_params(
EbuildInstallCommandParams::create()
- .phase(ebuild_ip_init)
+ .phase(ebuild_ip_prepare)
.use(use)
.a(archives)
.aa(all_archives)
@@ -561,6 +561,10 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
.userpriv(userpriv_ok)
.slot(SlotName(metadata->slot)));
+ EbuildInstallCommand prepare_cmd(command_params, install_params);
+ prepare_cmd();
+
+ install_params.phase = ebuild_ip_init;
EbuildInstallCommand init_cmd(command_params, install_params);
init_cmd();