diff options
author | 2008-03-04 20:38:15 +0000 | |
---|---|---|
committer | 2008-03-04 20:38:15 +0000 | |
commit | 14b6afbb966443b3fed7a1370773d3160b4d531b (patch) | |
tree | 918bb49e6f185da0db4624628de98f7d68ef9a14 /paludis/repositories | |
parent | e35ba062c861a990f43e92ec6331fc02a09342d7 (diff) | |
download | paludis-14b6afbb966443b3fed7a1370773d3160b4d531b.tar.gz paludis-14b6afbb966443b3fed7a1370773d3160b4d531b.tar.xz |
Add new initrm, killoldrm, tidyuprm phases to the uninstall process. Ensure that T is set to a useful value in pkg_{pre,post}rm.
Diffstat (limited to 'paludis/repositories')
-rw-r--r-- | paludis/repositories/e/e_repository_TEST.cc | 27 | ||||
-rwxr-xr-x | paludis/repositories/e/e_repository_TEST_setup.sh | 2 | ||||
-rw-r--r-- | paludis/repositories/e/eapis/0.conf | 5 | ||||
-rw-r--r-- | paludis/repositories/e/eapis/exheres-0.conf | 6 | ||||
-rw-r--r-- | paludis/repositories/e/eapis/paludis-1.conf | 6 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild/0/Makefile.am | 3 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild/0/builtin_initrm.bash | 79 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild/0/builtin_killoldrm.bash | 47 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild/0/builtin_tidyuprm.bash | 43 | ||||
-rwxr-xr-x | paludis/repositories/e/ebuild/ebuild.bash | 2 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild/exheres-0/Makefile.am | 3 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild/exheres-0/builtin_initrm.bash | 84 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild/exheres-0/builtin_killoldrm.bash | 51 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild/exheres-0/builtin_tidyuprm.bash | 48 | ||||
-rw-r--r-- | paludis/repositories/e/vdb_repository_TEST.cc | 109 | ||||
-rwxr-xr-x | paludis/repositories/e/vdb_repository_TEST_setup.sh | 30 |
16 files changed, 534 insertions, 11 deletions
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc index 53e3f23fc..29b80a146 100644 --- a/paludis/repositories/e/e_repository_TEST.cc +++ b/paludis/repositories/e/e_repository_TEST.cc @@ -67,6 +67,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -90,6 +91,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -113,6 +115,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -136,6 +139,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -168,6 +172,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -202,6 +207,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -242,6 +248,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -286,6 +293,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -339,6 +347,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -371,6 +380,7 @@ namespace test_cases using namespace tr1::placeholders; TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -419,6 +429,7 @@ namespace test_cases using namespace tr1::placeholders; TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -465,6 +476,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -507,6 +519,7 @@ namespace test_cases TestMessageSuffix opass_suffix("opass=" + stringify(opass), true); TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -574,6 +587,7 @@ namespace test_cases TestMessageSuffix opass_suffix("opass=" + stringify(opass), true); TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -634,6 +648,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -669,6 +684,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -717,6 +733,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -754,6 +771,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -788,6 +806,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -862,6 +881,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -906,6 +926,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>); keys->insert("format", "exheres"); keys->insert("names_cache", "/var/empty"); @@ -1010,6 +1031,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -1051,6 +1073,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -1201,6 +1224,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>); keys->insert("format", "ebuild"); keys->insert("names_cache", "/var/empty"); @@ -1254,6 +1278,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>); keys->insert("format", "ebuild"); keys->insert("names_cache", "/var/empty"); @@ -1400,6 +1425,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); @@ -1439,6 +1465,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "ebuild"); diff --git a/paludis/repositories/e/e_repository_TEST_setup.sh b/paludis/repositories/e/e_repository_TEST_setup.sh index dc4c31571..e27259c08 100755 --- a/paludis/repositories/e/e_repository_TEST_setup.sh +++ b/paludis/repositories/e/e_repository_TEST_setup.sh @@ -500,7 +500,6 @@ USERLAND="GNU" KERNEL="linux" LIBC="glibc" CHOST="i286-badger-linux-gnu" -PALUDIS_COMMAND="/bin/false" END mkdir -p "cat/in-ebuild-die" cat <<END > cat/in-ebuild-die/in-ebuild-die-1.ebuild || exit 1 @@ -740,7 +739,6 @@ END echo "cat" >> metadata/categories.conf || exit 1 cat <<END > profiles/profile/make.defaults CHOST="i286-badger-linux-gnu" -PALUDIS_COMMAND="/bin/false" END mkdir -p "packages/cat/in-ebuild-die" cat <<END > packages/cat/in-ebuild-die/in-ebuild-die-1.ebuild || exit 1 diff --git a/paludis/repositories/e/eapis/0.conf b/paludis/repositories/e/eapis/0.conf index 68e6cd01f..884d0cdca 100644 --- a/paludis/repositories/e/eapis/0.conf +++ b/paludis/repositories/e/eapis/0.conf @@ -91,9 +91,10 @@ ebuild_install = \ : tidyup ebuild_uninstall = \ - : prerm saveenv ; \ + : killoldrm ; \ + : initrm prerm saveenv ; \ unmerge : ; \ - : loadenv postrm ; + : loadenv postrm tidyuprm ; ebuild_pretend = diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf index 6daee315b..5e1b805c7 100644 --- a/paludis/repositories/e/eapis/exheres-0.conf +++ b/paludis/repositories/e/eapis/exheres-0.conf @@ -95,9 +95,11 @@ ebuild_install = \ : tidyup ebuild_uninstall = \ - sandbox : prerm saveenv ; \ + : killoldrm ; \ + sandbox : initrm prerm saveenv ; \ unmerge : ; \ - sandbox : loadenv postrm + sandbox : loadenv postrm ; \ + : tidyuprm ebuild_pretend = \ sandbox userpriv : pretend diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf index 6da1c74b2..d45696b7a 100644 --- a/paludis/repositories/e/eapis/paludis-1.conf +++ b/paludis/repositories/e/eapis/paludis-1.conf @@ -96,9 +96,11 @@ ebuild_install = \ : tidyup ebuild_uninstall = \ - sandbox : prerm saveenv ; \ + : killoldrm ; \ + sandbox : initrm prerm saveenv ; \ unmerge : ; \ - sandbox : loadenv postrm + sandbox : loadenv postrm ; \ + : tidyuprm ebuild_pretend = \ sandbox userpriv : pretend diff --git a/paludis/repositories/e/ebuild/0/Makefile.am b/paludis/repositories/e/ebuild/0/Makefile.am index 2af44484f..b8ff8fb3e 100644 --- a/paludis/repositories/e/ebuild/0/Makefile.am +++ b/paludis/repositories/e/ebuild/0/Makefile.am @@ -8,12 +8,15 @@ libexecprog0_SCRIPTS = \ build_functions.bash \ builtin_infovars.bash \ builtin_init.bash \ + builtin_initrm.bash \ builtin_loadenv.bash \ builtin_metadata.bash \ builtin_killold.bash \ + builtin_killoldrm.bash \ builtin_saveenv.bash \ builtin_strip.bash \ builtin_tidyup.bash \ + builtin_tidyuprm.bash \ builtin_variable.bash \ conditional_functions.bash \ eclass_functions.bash \ diff --git a/paludis/repositories/e/ebuild/0/builtin_initrm.bash b/paludis/repositories/e/ebuild/0/builtin_initrm.bash new file mode 100644 index 000000000..be51bf90f --- /dev/null +++ b/paludis/repositories/e/ebuild/0/builtin_initrm.bash @@ -0,0 +1,79 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007, 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 + +builtin_initrm() +{ + local a + for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do + [[ -z "${!a}" ]] && die "\$${a} unset or empty" + declare -r ${a}="${!a}" + done + + for a in ${PALUDIS_DIRECTORY_VARIABLES} ; do + [[ -d "${!a}" ]] || die "\$${a} (\"${!a}\") not a directory" + done + + for a in ${PALUDIS_DIRECTORY_IF_EXISTS_VARIABLES} ; do + [[ -e "${!a}" ]] && [[ ! -d "${!a}" ]] && \ + die "\$${a} (\"${!a}\") exists but is not a directory" + done + + for a in PALUDIS_TMPDIR ; do + if ! [[ -d "${!a}" ]] ; then + PALUDIS_EXTRA_DIE_MESSAGE=" +!!! '${!a}' should be a directory, but does not exist. For, +!!! security reasons, Paludis will not try to create this directory +!!! automatically. Please create it by hand and give it appropriate +!!! permissions. Typically you should use: +!!! mkdir ${!a} +!!! chgrp ${PALUDIS_REDUCED_GID} ${!a} +!!! chmod g+rwx ${!a} +!!! chmod +s ${!a} +!!! although other values may be more appropriate for your system. +" + die "\$${a} (\"${!a}\") not a directory" + fi + done + + if [[ -e "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" ]] ; then + if type -p chflags &>/dev/null; then + chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove flags from workdir" + fi + rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove previous work" + fi + + export T="${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall/temp/" + mkdir -p "${T}" || die "Couldn't create \$T (\"${T}\")" + declare -r T="${T}" + export HOME="${T}" + export TMPDIR="${T}" +} + +ebuild_f_initrm() +{ + if hasq "initrm" ${RESTRICT} ; then + ebuild_section "Skipping builtin_initrm (RESTRICT)" + elif hasq "initrm" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_initrm (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_initrm" + builtin_initrm + ebuild_section "Done builtin_initrm" + fi +} + diff --git a/paludis/repositories/e/ebuild/0/builtin_killoldrm.bash b/paludis/repositories/e/ebuild/0/builtin_killoldrm.bash new file mode 100644 index 000000000..a5e5669e1 --- /dev/null +++ b/paludis/repositories/e/ebuild/0/builtin_killoldrm.bash @@ -0,0 +1,47 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007, 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 + +builtin_killoldrm() +{ + local a + for a in PF CATEGORY PALUDIS_TMPDIR ; do + [[ -z "${!a}" ]] && die "\$${a} unset or empty" + done + + if [[ -e "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" ]] ; then + if type -p chflags &>/dev/null; then + chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove flags from workdir" + fi + rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove previous work" + fi +} + +ebuild_f_killoldrm() +{ + if hasq "killoldrm" ${RESTRICT} ; then + ebuild_section "Skipping builtin_killoldrm (RESTRICT)" + elif hasq "killoldrm" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_killoldrm (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_killoldrm" + builtin_killoldrm + ebuild_section "Done builtin_killoldrm" + fi +} + + diff --git a/paludis/repositories/e/ebuild/0/builtin_tidyuprm.bash b/paludis/repositories/e/ebuild/0/builtin_tidyuprm.bash new file mode 100644 index 000000000..ba4127679 --- /dev/null +++ b/paludis/repositories/e/ebuild/0/builtin_tidyuprm.bash @@ -0,0 +1,43 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 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 + +builtin_tidyuprm() +{ + if [[ -e "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" ]] ; then + if type -p chflags &>/dev/null; then + echo chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" 1>&2 + chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove flags from workdir" + fi + echo rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" 1>&2 + rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove work" + fi +} + +ebuild_f_tidyuprm() +{ + if hasq "tidyuprm" ${RESTRICT} ; then + ebuild_section "Skipping builtin_tidyuprm (RESTRICT)" + elif hasq "tidyuprm" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_tidyuprm (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_tidyuprm" + builtin_tidyuprm + ebuild_section "Done builtin_tidyuprm" + fi +} + diff --git a/paludis/repositories/e/ebuild/ebuild.bash b/paludis/repositories/e/ebuild/ebuild.bash index f56d8d74f..c950b72d8 100755 --- a/paludis/repositories/e/ebuild/ebuild.bash +++ b/paludis/repositories/e/ebuild/ebuild.bash @@ -411,7 +411,7 @@ ebuild_main() for action in $@ ; do case ${action} in - metadata|variable|init|killold|merge|unmerge|tidyup|\ + metadata|variable|init|initrm|killold|killoldrm|merge|unmerge|tidyup|tidyuprm|\ strip|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 9cccca8bd..49c0d9627 100644 --- a/paludis/repositories/e/ebuild/exheres-0/Makefile.am +++ b/paludis/repositories/e/ebuild/exheres-0/Makefile.am @@ -8,12 +8,15 @@ libexecprogexheres_SCRIPTS = \ build_functions.bash \ builtin_infovars.bash \ builtin_init.bash \ + builtin_initrm.bash \ builtin_loadenv.bash \ builtin_metadata.bash \ builtin_killold.bash \ + builtin_killoldrm.bash \ builtin_saveenv.bash \ builtin_strip.bash \ builtin_tidyup.bash \ + builtin_tidyuprm.bash \ builtin_variable.bash \ conditional_functions.bash \ eclass_functions.bash \ diff --git a/paludis/repositories/e/ebuild/exheres-0/builtin_initrm.bash b/paludis/repositories/e/ebuild/exheres-0/builtin_initrm.bash new file mode 100644 index 000000000..b4a594249 --- /dev/null +++ b/paludis/repositories/e/ebuild/exheres-0/builtin_initrm.bash @@ -0,0 +1,84 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007, 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 + +builtin_initrm() +{ + local a + for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do + [[ -z "${!a}" ]] && die "\$${a} unset or empty" + declare -r ${a}="${!a}" + done + + for a in ${PALUDIS_DIRECTORY_VARIABLES} ; do + [[ -d "${!a}" ]] || die "\$${a} (\"${!a}\") not a directory" + done + + for a in ${PALUDIS_DIRECTORY_IF_EXISTS_VARIABLES} ; do + [[ -e "${!a}" ]] && [[ ! -d "${!a}" ]] && \ + die "\$${a} (\"${!a}\") exists but is not a directory" + done + + for a in PALUDIS_TMPDIR ; do + if ! [[ -d "${!a}" ]] ; then + PALUDIS_EXTRA_DIE_MESSAGE=" +!!! '${!a}' should be a directory, but does not exist. For, +!!! security reasons, Paludis will not try to create this directory +!!! automatically. Please create it by hand and give it appropriate +!!! permissions. Typically you should use: +!!! mkdir ${!a} +!!! chgrp ${PALUDIS_REDUCED_GID} ${!a} +!!! chmod g+rwx ${!a} +!!! chmod +s ${!a} +!!! although other values may be more appropriate for your system. +" + die "\$${a} (\"${!a}\") not a directory" + fi + done + + if [[ -e "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" ]] ; then + if type -p chflags &>/dev/null; then + chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove flags from workdir" + fi + rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove previous work" + fi + + export T="${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall/temp/" + mkdir -p "${T}" || die "Couldn't create \$T (\"${T}\")" + declare -r T="${T}" + export HOME="${T}" + export TMPDIR="${T}" +} + +exheres_internal_initrm() +{ + if hasq "initrm" ${RESTRICT} ; then + ebuild_section "Skipping builtin_initrm (RESTRICT)" + elif hasq "initrm" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_initrm (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_initrm" + builtin_initrm + ebuild_section "Done builtin_initrm" + fi +} + +ebuild_f_initrm() +{ + exheres_internal_initrm "" +} + diff --git a/paludis/repositories/e/ebuild/exheres-0/builtin_killoldrm.bash b/paludis/repositories/e/ebuild/exheres-0/builtin_killoldrm.bash new file mode 100644 index 000000000..ad88396e2 --- /dev/null +++ b/paludis/repositories/e/ebuild/exheres-0/builtin_killoldrm.bash @@ -0,0 +1,51 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 2007, 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 + +builtin_killoldrm() +{ + local a + for a in PF CATEGORY PALUDIS_TMPDIR ; do + [[ -z "${!a}" ]] && die "\$${a} unset or empty" + done + + if [[ -e "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" ]] ; then + if type -p chflags &>/dev/null; then + chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove flags from workdir" + fi + rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove previous work" + fi +} + +exheres_internal_killoldrm() +{ + if hasq "killoldrm" ${RESTRICT} ; then + ebuild_section "Skipping builtin_killoldrm (RESTRICT)" + elif hasq "killoldrm" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_killoldrm (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_killoldrm" + builtin_killoldrm + ebuild_section "Done builtin_killoldrm" + fi +} + +ebuild_f_killoldrm() +{ + exheres_internal_killoldrm "" +} + diff --git a/paludis/repositories/e/ebuild/exheres-0/builtin_tidyuprm.bash b/paludis/repositories/e/ebuild/exheres-0/builtin_tidyuprm.bash new file mode 100644 index 000000000..3d1ae75c5 --- /dev/null +++ b/paludis/repositories/e/ebuild/exheres-0/builtin_tidyuprm.bash @@ -0,0 +1,48 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2006, 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 + +builtin_tidyuprm() +{ + if [[ -e "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" ]] ; then + if type -p chflags &>/dev/null; then + echo chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" 1>&2 + chflags -R 0 "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove flags from workdir" + fi + echo rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" 1>&2 + rm -fr "${PALUDIS_TMPDIR}/${CATEGORY}/${PF}-uninstall" || die "Couldn't remove work" + fi +} + +exheres_internal_tidyuprm() +{ + if hasq "tidyuprm" ${RESTRICT} ; then + ebuild_section "Skipping builtin_tidyuprm (RESTRICT)" + elif hasq "tidyuprm" ${SKIP_FUNCTIONS} ; then + ebuild_section "Skipping builtin_tidyuprm (SKIP_FUNCTIONS)" + else + ebuild_section "Starting builtin_tidyuprm" + builtin_tidyuprm + ebuild_section "Done builtin_tidyuprm" + fi +} + +ebuild_f_tidyuprm() +{ + exheres_internal_tidyuprm "" +} + diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc index 191d47313..85d50d082 100644 --- a/paludis/repositories/e/vdb_repository_TEST.cc +++ b/paludis/repositories/e/vdb_repository_TEST.cc @@ -57,11 +57,13 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>); keys->insert("format", "vdb"); keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo1"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env, keys)); TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "installed"); } @@ -78,12 +80,14 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "vdb"); keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo1"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository( &env, keys)); @@ -104,12 +108,14 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "vdb"); keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo1"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env, keys)); env.package_database()->add_repository(1, repo); @@ -133,12 +139,14 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "vdb"); keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo1"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); keys->insert("world", "vdb_repository_TEST_dir/world-new-file"); tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository( &env, keys)); @@ -159,12 +167,14 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "vdb"); keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo1"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); keys->insert("world", "vdb_repository_TEST_dir/world-empty"); tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository( &env, keys)); @@ -185,12 +195,14 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "vdb"); keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo1"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); keys->insert("world", "vdb_repository_TEST_dir/world-no-match"); tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository( &env, keys)); @@ -211,12 +223,14 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "vdb"); keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo1"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); keys->insert("world", "vdb_repository_TEST_dir/world-match"); tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository( &env, keys)); @@ -237,11 +251,13 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>); keys->insert("format", "vdb"); keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo1"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); keys->insert("world", "vdb_repository_TEST_dir/world-no-match-no-eol"); tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository( &env, keys)); @@ -312,11 +328,13 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>); keys->insert("format", "vdb"); keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo1"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); keys->insert("world", "vdb_repository_TEST_dir/world-no-match-no-eol"); tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository( &env, keys)); @@ -365,12 +383,14 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys( new Map<std::string, std::string>); keys->insert("format", "vdb"); keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo2"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository( &env, keys)); env.package_database()->add_repository(1, repo); @@ -416,6 +436,7 @@ namespace test_cases void run() { TestEnvironment env; + env.set_paludis_command("/bin/false"); tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>); keys->insert("format", "ebuild"); keys->insert("names_cache", "/var/empty"); @@ -436,6 +457,7 @@ namespace test_cases keys->insert("names_cache", "/var/empty"); keys->insert("provides_cache", "/var/empty"); keys->insert("location", "vdb_repository_TEST_dir/repo3"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); keys->insert("root", "vdb_repository_TEST_dir/root"); tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env, keys)); env.package_database()->add_repository(0, vdb_repo); @@ -483,5 +505,92 @@ namespace test_cases } } } test_vdb_install_reinstall_uninstall; + + struct VarsTest : TestCase + { + VarsTest() : TestCase("vars") { } + + unsigned max_run_time() const + { + return 3000; + } + + bool repeatable() const + { + return false; + } + + void run() + { + TestEnvironment env; + env.set_paludis_command("/bin/false"); + tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>); + keys->insert("format", "ebuild"); + keys->insert("names_cache", "/var/empty"); + keys->insert("location", "vdb_repository_TEST_dir/srcrepo"); + keys->insert("profiles", "vdb_repository_TEST_dir/srcrepo/profiles/profile"); + keys->insert("layout", "traditional"); + keys->insert("eapi_when_unknown", "0"); + keys->insert("eapi_when_unspecified", "0"); + keys->insert("profile_eapi", "0"); + keys->insert("distdir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "distdir")); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); + keys->insert("root", "vdb_repository_TEST_dir/root"); + tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env, keys)); + env.package_database()->add_repository(1, repo); + + keys.reset(new Map<std::string, std::string>); + keys->insert("format", "vdb"); + keys->insert("names_cache", "/var/empty"); + keys->insert("provides_cache", "/var/empty"); + keys->insert("location", "vdb_repository_TEST_dir/repo3"); + keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build")); + keys->insert("root", "vdb_repository_TEST_dir/root"); + tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env, keys)); + env.package_database()->add_repository(0, vdb_repo); + + InstallAction install_action(InstallActionOptions::named_create() + (k::debug_build(), iado_none) + (k::checks(), iaco_default) + (k::no_config_protect(), false) + (k::destination(), vdb_repo) + ); + + UninstallAction uninstall_action(UninstallActionOptions::named_create() + (k::no_config_protect(), false) + ); + + { + TestMessageSuffix suffix("vars", true); + const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/vars-1::srcrepo", + UserPackageDepSpecOptions()))), qo_require_exactly_one)->last()); + TEST_CHECK(id); + id->perform_action(install_action); + } + + vdb_repo->invalidate(); + + { + TestMessageSuffix suffix("reinstall", true); + const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/vars-1::srcrepo", + UserPackageDepSpecOptions()))), qo_require_exactly_one)->last()); + TEST_CHECK(id); + id->perform_action(install_action); + } + + vdb_repo->invalidate(); + + { + TestMessageSuffix suffix("uninstall", true); + const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/vars-1::installed", + UserPackageDepSpecOptions()))), qo_require_exactly_one)->last()); + TEST_CHECK(id); + id->perform_action(uninstall_action); + } + } + } test_vdb_vars; } diff --git a/paludis/repositories/e/vdb_repository_TEST_setup.sh b/paludis/repositories/e/vdb_repository_TEST_setup.sh index ca9791042..bec42e3eb 100755 --- a/paludis/repositories/e/vdb_repository_TEST_setup.sh +++ b/paludis/repositories/e/vdb_repository_TEST_setup.sh @@ -82,13 +82,12 @@ echo "cat/pkg1 build: cat/pkg2 build,run: cat/pkg3 suggested: cat/pkg4 post: cat mkdir -p repo3 -mkdir -p srcrepo/{profiles/profile,cat/target,eclass} +mkdir -p srcrepo/{profiles/profile,cat/{target,vars},eclass} cat <<END > srcrepo/profiles/profile/make.defaults ARCH=test USERLAND="GNU" KERNEL="linux" CHOST="i286-badger-linux-gnu" -PALUDIS_COMMAND="/bin/false" END echo "srcrepo" > srcrepo/profiles/repo_name || exit 1 @@ -107,3 +106,30 @@ src_install() { } END +cat <<'END' > srcrepo/cat/vars/vars-1.ebuild +DESCRIPTION="The Description" +HOMEPAGE="http://example.com/" +SRC_URI="" +SLOT="0" +IUSE="" +LICENSE="GPL-2" +KEYWORDS="test" +DEPEND="foo/bar" + +pkg_setup() { + [[ -d "${T}" ]] || die "T not a dir" +} + +src_compile() { + [[ -d "${T}" ]] || die "T not a dir" +} + +pkg_preinst() { + [[ -d "${T}" ]] || die "T not a dir" +} + +pkg_prerm() { + [[ -d "${T}" ]] || die "T not a dir" +} +END + |