Added support to replace packages with another one. Package metadata
uses an array of strings that lists the packages that should be removed before new package can be installed. In the build templates one can use: replaces="foo foo-blah foo-libs". --HG-- extra : convert_revision : xtraeme%40gmail.com-20091017022643-rdyrp9kvmx3m0p0h
This commit is contained in:
parent
4ef0fbcada
commit
cacb34147a
@ -341,7 +341,8 @@ static int
|
||||
exec_transaction(struct transaction *trans)
|
||||
{
|
||||
prop_dictionary_t instpkgd;
|
||||
prop_object_t obj;
|
||||
prop_object_t obj, obj2;
|
||||
prop_object_iterator_t replaces_iter;
|
||||
const char *pkgname, *version, *instver, *filename, *tract;
|
||||
int rv = 0;
|
||||
bool essential, isdep, autoinst;
|
||||
@ -384,6 +385,7 @@ exec_transaction(struct transaction *trans)
|
||||
prop_dictionary_get_bool(obj, "essential", &essential);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "filename", &filename);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "trans-action", &tract);
|
||||
replaces_iter = xbps_get_array_iter_from_dict(obj, "replaces");
|
||||
|
||||
if (trans->originpkgname &&
|
||||
strcmp(trans->originpkgname, pkgname))
|
||||
@ -399,6 +401,37 @@ exec_transaction(struct transaction *trans)
|
||||
if (state == XBPS_PKG_STATE_UNPACKED)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* This package replaces other package(s), so we remove
|
||||
* them before upgrading or installing new one.
|
||||
*/
|
||||
if (replaces_iter != NULL) {
|
||||
while ((obj2 =
|
||||
prop_object_iterator_next(replaces_iter))) {
|
||||
printf("Replacing package '%s' with '%s-%s' "
|
||||
"...\n", prop_string_cstring(obj2),
|
||||
pkgname, version);
|
||||
rv = xbps_remove_pkg(prop_string_cstring(obj2),
|
||||
NULL, false);
|
||||
if (rv != 0) {
|
||||
printf("Couldn't remove %s (%s)\n",
|
||||
prop_string_cstring(obj2),
|
||||
strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
rv = xbps_purge_pkg(prop_string_cstring(obj2),
|
||||
false);
|
||||
if (rv != 0) {
|
||||
printf("Couldn't purge %s (%s)\n",
|
||||
prop_string_cstring(obj2),
|
||||
strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_release(replaces_iter);
|
||||
replaces_iter = NULL;
|
||||
}
|
||||
|
||||
if (strcmp(tract, "update") == 0) {
|
||||
instpkgd = xbps_find_pkg_installed_from_plist(pkgname);
|
||||
if (instpkgd == NULL) {
|
||||
|
@ -47,7 +47,7 @@ and install xbps binary packages:
|
||||
* sudo
|
||||
|
||||
Super-user privileges are required as well, because all packages are built
|
||||
in a chroot (except the ones that are included in a virtual package to be
|
||||
in a chroot (except the ones that are included in a meta package to be
|
||||
able to build a minimal system for the chroot).
|
||||
|
||||
PLEASE NOTE THAT fakechroot or fakeroot-ng DO NOT WORK.
|
||||
@ -65,9 +65,6 @@ Once the xbps distfiles are installed into prefix, you can start building
|
||||
packages from source, add local repositories with binary packages, install or
|
||||
remove them, etc.
|
||||
|
||||
If you are only interested in building/using packages from source, see the
|
||||
SRCPKG_INFO file.
|
||||
|
||||
For information about binary packages, see the BINPKG_INFO file.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
@ -311,6 +311,16 @@ _EOF
|
||||
echo "</array>" >> $TMPFPROPS
|
||||
fi
|
||||
|
||||
# Replace package(s).
|
||||
if [ -n "$replaces" ]; then
|
||||
echo "<key>replaces</key>" >> $TMPFPROPS
|
||||
echo "<array>" >> $TMPFPROPS
|
||||
for f in ${replaces}; do
|
||||
echo "<string>$f</string>" >> $TMPFPROPS
|
||||
done
|
||||
echo "</array>" >> $TMPFPROPS
|
||||
fi
|
||||
|
||||
# Terminate the property list file.
|
||||
echo "</dict>" >> $TMPFPROPS
|
||||
echo "</plist>" >> $TMPFPROPS
|
||||
|
@ -76,7 +76,7 @@ reset_tmpl_vars()
|
||||
only_for_archs conf_files keep_libtool_archives \
|
||||
noarch subpackages sourcepkg gtk_iconcache_dirs \
|
||||
abi_depends api_depends triggers openrc_services \
|
||||
XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \
|
||||
replaces XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \
|
||||
XBPS_BUILD_DONE XBPS_INSTALL_DONE FILESDIR DESTDIR \
|
||||
SRCPKGDESTDIR PATCHESDIR"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user