aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-03 23:25:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-03 23:25:30 +0000
commit5e6eb3ebfeb87e79cb9bfa81c17127603a034d0c (patch)
tree4c11a0ca5433a20723a70eb2fd3fcb7ba13f436c
parentd07464be296b336cbf2f97a5e894d6482631c1c0 (diff)
downloadpaludis-5e6eb3ebfeb87e79cb9bfa81c17127603a034d0c.tar.gz
paludis-5e6eb3ebfeb87e79cb9bfa81c17127603a034d0c.tar.xz
Switch to VDB_FORMAT paludis-2. Use Portage compatible environment saving. Save the repository whence a package originated. Add buildroot configure option for VDB repositories. Add tests for environment behaviour
-rw-r--r--ebuild/builtin_merge.bash24
-rw-r--r--ebuild/builtin_unmerge.bash14
-rwxr-xr-xebuild/ebuild.bash32
-rw-r--r--ebuild/eclass_functions.bash2
-rw-r--r--paludis/ebuild.cc6
-rw-r--r--paludis/ebuild.hh4
-rw-r--r--paludis/vdb_repository.cc78
-rw-r--r--paludis/vdb_repository.hh4
-rwxr-xr-xsrc/upgrade_TEST_setup.sh28
9 files changed, 143 insertions, 49 deletions
diff --git a/ebuild/builtin_merge.bash b/ebuild/builtin_merge.bash
index 31f4e6e..6859cb7 100644
--- a/ebuild/builtin_merge.bash
+++ b/ebuild/builtin_merge.bash
@@ -30,13 +30,19 @@ builtin_merge()
install -d "${dbdir}" || die "couldn't make pkg db directory (\"${dbdir}\")"
install -d "${ROOT%/}"/var/db/pkg/.cache || die "couldn't make pkg db cache"
- local v VDB_FORMAT="paludis-1"
- for v in CATEGORY CBUILD CFLAGS CHOST CXXFLAGS DEPEND DESCRIPTION EAPI \
+ local v VDB_FORMAT="paludis-2"
+ for v in CATEGORY CBUILD CHOST DEPEND DESCRIPTION EAPI \
FEATURES HOMEPAGE INHERITED IUSE KEYWORDS LICENSE PDEPEND PF \
PROVIDE RDEPEND SLOT SRC_URI USE CONFIG_PROTECT CONFIG_PROTECT_MASK \
VDB_FORMAT ; do
echo "${!v}" > "${dbdir}"/${v} || die "pkg db write ${v} failed"
done
+ for v in ASFLAGS CBUILD CC CFLAGS CHOST CTARGET CXX CXXFLAGS \
+ EXTRA_ECONF EXTRA_EINSTALL EXTRA_EMAKE LDFLAGS LIBCXXFLAGS \
+ REPOSITORY ; do
+ [[ -z "${!v}" ]] && continue
+ echo "${!v}" > "${dbdir}"/${v} || die "pkg db write ${v} failed"
+ done
if [[ -n ${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT} ]]; then
CONFIG_PROTECT=${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT}
@@ -49,18 +55,6 @@ builtin_merge()
export CONFIG_PROTECT_MASK="${CONFIG_PROTECT_MASK}"
[[ -f "${EBUILD}" ]] && cp "${EBUILD}" ${dbdir}/
- local x e ee=
- for e in ${ECLASSDIRS:-${ECLASSDIR}} ; do
- ee="${e} ${ee}"
- done
- for i in ${INHERITED} ; do
- for e in ${ee} ; do
- if [[ -f "${e}/${i}".eclass ]] ; then
- cp "${e}/${i}".eclass "${dbdir}/" || die "save eclass ${i} failed"
- break
- fi
- done
- done
local reinstall=
if [[ -f "${dbdir}/CONTENTS" ]] ; then
@@ -68,7 +62,7 @@ builtin_merge()
reinstall="yes"
fi
- env | bzip2 > ${dbdir}/environment.bz2
+ ( set ; export -p | sed 's:^declare -rx:declare -x:' ) | bzip2 > ${dbdir}/environment.bz2
> ${dbdir}/CONTENTS
if [[ -n "${D}" ]] && [[ -d "${D}" ]] ; then
diff --git a/ebuild/builtin_unmerge.bash b/ebuild/builtin_unmerge.bash
index 607513d..c965b33 100644
--- a/ebuild/builtin_unmerge.bash
+++ b/ebuild/builtin_unmerge.bash
@@ -22,10 +22,17 @@ builtin_unmerge()
local dbdir="${ROOT}"/var/db/pkg/"${CATEGORY}/${PF}" entry
[[ -d "${dbdir}" ]] || die "couldn't find pkg db directory (\"${dbdir}\")"
- for v in CATEGORY CBUILD CFLAGS CHOST CXXFLAGS DEPEND DESCRIPTION EAPI \
+ for v in CATEGORY CBUILD CHOST DEPEND DESCRIPTION EAPI \
FEATURES HOMEPAGE INHERITED IUSE KEYWORDS LICENSE PDEPEND PF \
- PROVIDE RDEPEND SLOT SRC_URI USE ; do
- eval "${v}=\$(< ${dbdir}/${v} ) || die \"Load key ${v} failed\""
+ PROVIDE RDEPEND SLOT SRC_URI USE CONFIG_PROTECT CONFIG_PROTECT_MASK \
+ VDB_FORMAT ASFLAGS CBUILD CC CFLAGS CHOST CTARGET CXX CXXFLAGS \
+ EXTRA_ECONF EXTRA_EINSTALL EXTRA_EMAKE LDFLAGS LIBCXXFLAGS \
+ REPOSITORY ; do
+ if [[ -f "${dbdir}/${v}" ]] ; then
+ eval "${v}=\$(< ${dbdir}/${v} ) || die \"Load key ${v} failed\""
+ else
+ eval "${v}="
+ fi
done
if [[ -f ${dbdir}/CONFIG_PROTECT ]]; then
@@ -35,6 +42,7 @@ builtin_unmerge()
fi
else
eval $(bzcat "${dbdir}/environment.bz2" | while read line; do
+ line=${line//\'}
if [[ ${line%%=*} == CONFIG_PROTECT ]]; then
echo "CONFIG_PROTECT='${line#*=} ${CONFIG_PROTECT}'"
elif [[ ${line%%=*} == CONFIG_PROTECT_MASK ]]; then
diff --git a/ebuild/ebuild.bash b/ebuild/ebuild.bash
index 8e3eed8..70b336d 100755
--- a/ebuild/ebuild.bash
+++ b/ebuild/ebuild.bash
@@ -133,15 +133,47 @@ done
ebuild_load_ebuild()
{
+ ebuild_section "Loading ebuild"
+
+ if [[ -n "${PALUDIS_LOAD_ENVIRONMENT}" ]] ; then
+ bunzip2 < "${PALUDIS_LOAD_ENVIRONMENT}" > ${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF} \
+ || die "Can't extract ${PALUDIS_LOAD_ENVIRONMENT}"
+
+ sed -i \
+ -e '/^diefunc ()/,/^}/d' \
+ -e '/^perform_hook ()/,/^}/d' \
+ -e '/^ROOTPATH=/d' \
+ -e '/^PATH=/d' \
+ -e '/^T=/d' \
+ -e '/^PALUDIS_TMPDIR=/d' \
+ -e '/^PALUDIS_EBUILD_LOG_LEVEL=/d' \
+ -e '/^PORTDIR=/d' \
+ -e '/^FILESDIR=/d' \
+ -e '/^ECLASSDIR=/d' \
+ -e '/^DISTDIR=/d' \
+ -e '/^PALUDIS_EBUILD_DIR=/d' \
+ -e '/^PALUDIS_COMMAND=/d' \
+ -e '/^ROOT=/d' \
+ "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}"
+
+ source "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}" &>/dev/null \
+ || die "Can't load saved environment"
+
+ echo rm "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}" 1>&2
+ rm "${PALUDIS_TMPDIR}/environment-${CATEGORY}-${PF}"
+ fi
+
export EBUILD="${1}"
if [[ "${CATEGORY}" == "virtual" ]] ; then
if [[ -f "${1}" ]] ; then
+ echo source ${1} 1>&2
source ${1} || die "Error sourcing ebuild '${1}'"
elif [[ -e "${1}" ]] ; then
die "'${1}' exists but is not a regular file"
fi
else
[[ -f "${1}" ]] || die "Ebuild '${1}' is not a file"
+ echo source ${1} 1>&2
source ${1} || die "Error sourcing ebuild '${1}'"
fi
[[ ${RDEPEND-unset} == "unset" ]] && RDEPEND="${DEPEND}"
diff --git a/ebuild/eclass_functions.bash b/ebuild/eclass_functions.bash
index 5ec15cf..1c742e6 100644
--- a/ebuild/eclass_functions.bash
+++ b/ebuild/eclass_functions.bash
@@ -46,6 +46,8 @@ EXPORT_FUNCTIONS()
inherit()
{
+ [[ -n "${PALUDIS_SKIP_INHERIT}" ]] && return
+
local e ee location=
for e in "$@" ; do
for ee in ${ECLASSDIRS:-${ECLASSDIR}} ; do
diff --git a/paludis/ebuild.cc b/paludis/ebuild.cc
index 23ca571..050bac9 100644
--- a/paludis/ebuild.cc
+++ b/paludis/ebuild.cc
@@ -86,6 +86,7 @@ EbuildCommand::operator() ()
("PF", stringify(params.get<ecpk_db_entry>()->get<pde_name>().get<qpn_package>()) + "-" +
stringify(params.get<ecpk_db_entry>()->get<pde_version>()))
("CATEGORY", stringify(params.get<ecpk_db_entry>()->get<pde_name>().get<qpn_category>()))
+ ("REPOSITORY", stringify(params.get<ecpk_db_entry>()->get<pde_repository>()))
("FILESDIR", stringify(params.get<ecpk_files_dir>()))
("ECLASSDIR", stringify(*params.get<ecpk_eclassdirs>()->begin()))
("ECLASSDIRS", join(params.get<ecpk_eclassdirs>()->begin(),
@@ -354,6 +355,11 @@ EbuildUninstallCommand::extend_command(const MakeEnvCommand & cmd)
("PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK",
uninstall_params.get<ecupk_disable_cfgpro>() ? "/" : ""));
+ if (uninstall_params.get<ecupk_load_environment>())
+ result = result
+ ("PALUDIS_LOAD_ENVIRONMENT", stringify(*uninstall_params.get<ecupk_load_environment>()))
+ ("PALUDIS_SKIP_INHERIT", "yes");
+
return result;
}
diff --git a/paludis/ebuild.hh b/paludis/ebuild.hh
index 584de8a..b960ec4 100644
--- a/paludis/ebuild.hh
+++ b/paludis/ebuild.hh
@@ -401,6 +401,7 @@ namespace paludis
ecupk_root,
ecupk_disable_cfgpro,
ecupk_unmerge_only,
+ ecupk_load_environment,
last_ecupk
};
@@ -416,7 +417,8 @@ namespace paludis
SmartRecordKeys<EbuildUninstallCommandParamsKeys, last_ecupk>,
SmartRecordKey<ecupk_root, std::string>,
SmartRecordKey<ecupk_disable_cfgpro, bool>,
- SmartRecordKey<ecupk_unmerge_only, bool>
+ SmartRecordKey<ecupk_unmerge_only, bool>,
+ SmartRecordKey<ecupk_load_environment, const FSEntry * const>
{
};
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index 6fea778..a94f4bc 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -158,6 +158,34 @@ namespace
}
};
};
+
+ /**
+ * Figure out the format of environment.bz2. If VDB_FORMAT is "paludis-1",
+ * or if there's no VDB_FORMAT and there're no lines with () and no =, it's
+ * an env dump. Otherwise it's a source file.
+ *
+ * \ingroup grpvdbrepository
+ */
+ bool is_full_env(const FSEntry & vdb_dir)
+ {
+ bool result(false);
+
+ if ((vdb_dir / "VDB_FORMAT").is_regular_file())
+ {
+ std::ifstream f(stringify(vdb_dir / "VDB_FORMAT").c_str());
+ if (! f)
+ throw EnvironmentVariableActionError("Could not read '" +
+ stringify(vdb_dir / "VDB_FORMAT") + "'");
+ result = ("paludis-1" != strip_trailing_string(std::string(
+ (std::istreambuf_iterator<char>(f)),
+ std::istreambuf_iterator<char>()), "\n"));
+ }
+ else if (0 == run_command("bunzip2 < " + stringify(vdb_dir / "environment.bz2") +
+ " | grep -q '^[^=]\\+()'"))
+ result = true;
+
+ return result;
+ }
}
namespace paludis
@@ -223,7 +251,7 @@ Implementation<VDBRepository>::Implementation(const VDBRepositoryParams & p) :
env(p.get<vdbrpk_environment>()),
location(p.get<vdbrpk_location>()),
root(p.get<vdbrpk_root>()),
- buildroot("/var/tmp/paludis"),
+ buildroot(p.get<vdbrpk_buildroot>()),
world_file(p.get<vdbrpk_world>()),
entries_valid(false),
has_provide_map(false)
@@ -377,6 +405,7 @@ VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
_info.insert(std::make_pair(std::string("root"), stringify(_imp->root)));
_info.insert(std::make_pair(std::string("format"), std::string("vdb")));
_info.insert(std::make_pair(std::string("world"), stringify(_imp->world_file)));
+ _info.insert(std::make_pair(std::string("buildroot"), stringify(_imp->buildroot)));
}
VDBRepository::~VDBRepository()
@@ -655,12 +684,17 @@ VDBRepository::make_vdb_repository(
if (m.end() == m.find("world") || ((world = m.find("world")->second)).empty())
world = location + "/world";
+ std::string buildroot;
+ if (m.end() == m.find("buildroot") || ((buildroot = m.find("buildroot")->second)).empty())
+ buildroot = "/var/tmp/paludis";
+
return CountedPtr<Repository>(new VDBRepository(VDBRepositoryParams::create((
param<vdbrpk_environment>(env),
param<vdbrpk_package_database>(db),
param<vdbrpk_location>(location),
param<vdbrpk_root>(root),
- param<vdbrpk_world>(world)))));
+ param<vdbrpk_world>(world),
+ param<vdbrpk_buildroot>(buildroot)))));
}
VDBRepositoryConfigurationError::VDBRepositoryConfigurationError(
@@ -722,23 +756,28 @@ VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec &
eclassdirs->append(FSEntry(_imp->location / stringify(q.get<qpn_category>()) /
(stringify(q.get<qpn_package>()) + "-" + stringify(v))));
+ FSEntry pkg_dir(_imp->location / stringify(q.get<qpn_category>()) /
+ (stringify(q.get<qpn_package>()) + "-" + stringify(v)));
+
+ CountedPtr<FSEntry, count_policy::ExternalCountTag> load_env(0);
+ if (is_full_env(pkg_dir))
+ load_env.assign(new FSEntry(pkg_dir / "environment.bz2"));
+
EbuildUninstallCommand uninstall_cmd(EbuildCommandParams::create((
param<ecpk_environment>(_imp->env),
param<ecpk_db_entry>(&e),
- param<ecpk_ebuild_dir>(_imp->location / stringify(q.get<qpn_category>()) /
- (stringify(q.get<qpn_package>()) + "-" + stringify(v))),
- param<ecpk_files_dir>(_imp->location / stringify(q.get<qpn_category>()) /
- (stringify(q.get<qpn_package>()) + "-" + stringify(v))),
+ param<ecpk_ebuild_dir>(pkg_dir),
+ param<ecpk_files_dir>(pkg_dir),
param<ecpk_eclassdirs>(eclassdirs),
param<ecpk_portdir>(_imp->location),
- param<ecpk_distdir>(_imp->location / stringify(q.get<qpn_category>()) /
- (stringify(q.get<qpn_package>()) + "-" + stringify(v))),
+ param<ecpk_distdir>(pkg_dir),
param<ecpk_buildroot>(_imp->buildroot)
)),
EbuildUninstallCommandParams::create((
param<ecupk_root>(stringify(_imp->root) + "/"),
param<ecupk_disable_cfgpro>(o.get<io_noconfigprotect>()),
- param<ecupk_unmerge_only>(! metadata->get_ebuild_interface()->get<evm_virtual>().empty())
+ param<ecupk_unmerge_only>(! metadata->get_ebuild_interface()->get<evm_virtual>().empty()),
+ param<ecupk_load_environment>(load_env.raw_pointer())
)));
uninstall_cmd();
@@ -968,26 +1007,7 @@ VDBRepository::get_environment_variable(
}
else if ((vdb_dir / "environment.bz2").is_regular_file())
{
- /* Figure out the format of environment.bz2. If VDB_FORMAT is "paludis-1",
- * or if there's no VDB_FORMAT and there're no lines with () and no =,
- * it's an env dump. Otherwise it's a source file. */
- bool is_source_file(false);
-
- if ((vdb_dir / "VDB_FORMAT").is_regular_file())
- {
- std::ifstream f(stringify(vdb_dir / "VDB_FORMAT").c_str());
- if (! f)
- throw EnvironmentVariableActionError("Could not read '" +
- stringify(vdb_dir / "VDB_FORMAT") + "'");
- is_source_file = ("paludis-1" != strip_trailing_string(std::string(
- (std::istreambuf_iterator<char>(f)),
- std::istreambuf_iterator<char>()), "\n"));
- }
- else if (0 == run_command("bunzip2 < " + stringify(vdb_dir / "environment.bz2") +
- " | grep -q '^[^=]\\+()'"))
- is_source_file = true;
-
- if (is_source_file)
+ if (is_full_env(vdb_dir))
{
PStream p("bash -c '( bunzip2 < " + stringify(vdb_dir / "environment.bz2" ) +
" ; echo echo \\$" + var + " ) | bash 2>/dev/null'");
diff --git a/paludis/vdb_repository.hh b/paludis/vdb_repository.hh
index a35f201..8980204 100644
--- a/paludis/vdb_repository.hh
+++ b/paludis/vdb_repository.hh
@@ -47,6 +47,7 @@ namespace paludis
vdbrpk_location,
vdbrpk_root,
vdbrpk_world,
+ vdbrpk_buildroot,
last_vdbrpk
};
@@ -63,7 +64,8 @@ namespace paludis
SmartRecordKey<vdbrpk_package_database, const PackageDatabase *>,
SmartRecordKey<vdbrpk_location, const FSEntry>,
SmartRecordKey<vdbrpk_root, const FSEntry>,
- SmartRecordKey<vdbrpk_world, const FSEntry>
+ SmartRecordKey<vdbrpk_world, const FSEntry>,
+ SmartRecordKey<vdbrpk_buildroot, const FSEntry>
{
};
diff --git a/src/upgrade_TEST_setup.sh b/src/upgrade_TEST_setup.sh
index efc72e2..eb69c95 100755
--- a/src/upgrade_TEST_setup.sh
+++ b/src/upgrade_TEST_setup.sh
@@ -39,6 +39,7 @@ END
cat <<END > root/${SYSCONFDIR}/paludis/repositories/installed.conf
location = \${ROOT}/var/db/pkg
format = vdb
+buildroot = `pwd`/build
END
mkdir -p root/tmp
@@ -92,7 +93,16 @@ USERLAND=test
KERNEL=test
END
+cat <<"END" > eclass/myeclass.eclass || exit 1
+the_eclass_works()
+{
+ true
+}
+END
+
cat <<"END" > test-category/target/target-1.ebuild || exit 1
+inherit myeclass
+
DESCRIPTION="Test target"
HOMEPAGE="http://paludis.berlios.de/"
SRC_URI="http://invalid.domain/${P}.tar.gz"
@@ -101,10 +111,28 @@ IUSE=""
LICENSE="GPL-2"
KEYWORDS="test"
+pkg_setup() {
+ export VAR1=yes
+ VAR2=yes
+ local VAR3=yes
+}
+
src_install() {
+ [[ "${VAR1}" == yes ]] || die
+ [[ "${VAR2}" == yes ]] || die
+ [[ "${VAR3}" == yes ]] && die
+
dobin testbin
dobin testbin${PV}
}
+
+pkg_prerm() {
+ [[ "${VAR1}" == yes ]] || die
+ [[ "${VAR2}" == yes ]] || die
+ [[ "${VAR3}" == yes ]] && die
+
+ the_eclass_works || die
+}
END
cat <<"END" > test-category/target/target-2.ebuild || exit 1