Ignore executing install/remove scripts if XBPS_TARGET_ARCH is set.

Instead a two stage approach is necessary when packages for target arch
are installed:

	- XBPS_TARGET_ARCH=arch xbps-install foo <- only unpack
	- xbps-reconfigure -a <- configure natively or via an emulator
This commit is contained in:
Juan RP 2013-03-07 18:08:12 +01:00
parent fd7153fe5c
commit 5eddf04898
6 changed files with 63 additions and 26 deletions

View File

@ -48,7 +48,7 @@
*/
#define XBPS_PKGINDEX_VERSION "1.7"
#define XBPS_API_VERSION "20130307-1"
#define XBPS_API_VERSION "20130307-2"
#ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET"
@ -544,7 +544,8 @@ struct xbps_handle {
*/
char *cachedir_priv;
char *metadir_priv;
char *un_machine;
char *native_arch;
const char *target_arch;
/*
* @var repository
*

View File

@ -166,7 +166,6 @@ xbps_init(struct xbps_handle *xhp)
struct utsname un;
int rv, cc, cch;
bool syslog_enabled = false;
char *tarch;
assert(xhp != NULL);
@ -246,15 +245,10 @@ xbps_init(struct xbps_handle *xhp)
return ENOMEM;
xhp->metadir = xhp->metadir_priv;
/* Override target arch if XBPS_TARGET_ARCH is set in the environment */
tarch = getenv("XBPS_TARGET_ARCH");
if (tarch != NULL) {
xhp->un_machine = strdup(tarch);
} else {
uname(&un);
xhp->un_machine = strdup(un.machine);
assert(xhp->un_machine);
}
xhp->target_arch = getenv("XBPS_TARGET_ARCH");
uname(&un);
xhp->native_arch = strdup(un.machine);
assert(xhp->native_arch);
if (xhp->cfg == NULL) {
xhp->flags |= XBPS_FLAG_SYSLOG;
@ -283,7 +277,8 @@ xbps_init(struct xbps_handle *xhp)
xbps_dbg_printf(xhp, "FetchCacheconn=%u\n", cc);
xbps_dbg_printf(xhp, "FetchCacheconnHost=%u\n", cch);
xbps_dbg_printf(xhp, "Syslog=%u\n", syslog_enabled);
xbps_dbg_printf(xhp, "Architecture: %s\n", xhp->un_machine);
xbps_dbg_printf(xhp, "Architecture: %s\n", xhp->native_arch);
xbps_dbg_printf(xhp, "Target Architecture: %s\n", xhp->target_arch);
xhp->initialized = true;
@ -307,7 +302,7 @@ xbps_end(struct xbps_handle *xhp)
cfg_free(xhp->cfg);
free(xhp->cachedir_priv);
free(xhp->metadir_priv);
free(xhp->un_machine);
free(xhp->native_arch);
xhp->initialized = false;
xhp = NULL;

View File

@ -48,6 +48,12 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp,
assert(pkgver);
assert(action);
if (xhp->target_arch) {
xbps_dbg_printf(xhp, "%s: not executing %s "
"install/remove action.\n", pkgver, action);
return 0;
}
if (strcmp(xhp->rootdir, "/") == 0) {
tmpdir = getenv("TMPDIR");
if (tmpdir == NULL)

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2009-2012 Juan Romero Pardines.
* Copyright (c) 2009-2013 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -75,7 +75,7 @@ int HIDDEN
xbps_rindex_sync(struct xbps_handle *xhp, const char *uri, const char *plistf)
{
prop_dictionary_t repod;
const char *fetchstr = NULL;
const char *arch, *fetchstr = NULL;
char *rpidx, *lrepodir, *uri_fixedp, *lrepofile;
int rv = 0;
@ -89,10 +89,16 @@ xbps_rindex_sync(struct xbps_handle *xhp, const char *uri, const char *plistf)
uri_fixedp = xbps_get_remote_repo_string(uri);
if (uri_fixedp == NULL)
return -1;
if (xhp->target_arch)
arch = xhp->target_arch;
else
arch = xhp->native_arch;
/*
* Remote repository plist index full URL.
*/
rpidx = xbps_xasprintf("%s/%s-%s", uri, xhp->un_machine, plistf);
rpidx = xbps_xasprintf("%s/%s-%s", uri, arch, plistf);
/*
* Full path to repository directory to store the plist
* index file.
@ -101,8 +107,7 @@ xbps_rindex_sync(struct xbps_handle *xhp, const char *uri, const char *plistf)
/*
* Full path to the local repository index file.
*/
lrepofile = xbps_xasprintf("%s/%s-%s", lrepodir,
xhp->un_machine, plistf);
lrepofile = xbps_xasprintf("%s/%s-%s", lrepodir, arch, plistf);
/*
* Create repodir in metadir.
*/

View File

@ -296,12 +296,16 @@ xbps_transaction_commit(struct xbps_handle *xhp)
goto out;
}
}
prop_object_iterator_reset(iter);
/* if there are no packages to install or update we are done */
if (!update && !install)
goto out;
/* if installing packages for target_arch, don't configure anything */
if (xhp->target_arch && strcmp(xhp->native_arch, xhp->target_arch))
goto out;
prop_object_iterator_reset(iter);
/*
* Configure all unpacked packages.
*/

View File

@ -175,6 +175,7 @@ get_pkg_index_remote_plist(struct xbps_handle *xhp,
const char *uri,
const char *plistf)
{
const char *arch;
char *uri_fixed, *repodir;
assert(uri != NULL);
@ -183,8 +184,13 @@ get_pkg_index_remote_plist(struct xbps_handle *xhp,
if (uri_fixed == NULL)
return NULL;
if (xhp->target_arch)
arch = xhp->target_arch;
else
arch = xhp->native_arch;
repodir = xbps_xasprintf("%s/%s/%s-%s", xhp->metadir,
uri_fixed, xhp->un_machine, plistf);
uri_fixed, arch, plistf);
free(uri_fixed);
return repodir;
}
@ -192,26 +198,39 @@ get_pkg_index_remote_plist(struct xbps_handle *xhp,
char *
xbps_pkg_index_plist(struct xbps_handle *xhp, const char *uri)
{
const char *arch;
assert(xhp);
assert(uri != NULL);
if (xbps_repository_is_remote(uri))
return get_pkg_index_remote_plist(xhp, uri, XBPS_PKGINDEX);
return xbps_xasprintf("%s/%s-%s", uri, xhp->un_machine, XBPS_PKGINDEX);
if (xhp->target_arch)
arch = xhp->target_arch;
else
arch = xhp->native_arch;
return xbps_xasprintf("%s/%s-%s", uri, arch, XBPS_PKGINDEX);
}
char *
xbps_pkg_index_files_plist(struct xbps_handle *xhp, const char *uri)
{
const char *arch;
assert(xhp);
assert(uri != NULL);
if (xbps_repository_is_remote(uri))
return get_pkg_index_remote_plist(xhp, uri, XBPS_PKGINDEX_FILES);
return xbps_xasprintf("%s/%s-%s", uri,
xhp->un_machine, XBPS_PKGINDEX_FILES);
if (xhp->target_arch)
arch = xhp->target_arch;
else
arch = xhp->native_arch;
return xbps_xasprintf("%s/%s-%s", uri, arch, XBPS_PKGINDEX_FILES);
}
char HIDDEN *
@ -270,9 +289,16 @@ xbps_pkg_arch_match(struct xbps_handle *xhp,
const char *orig,
const char *target)
{
const char *arch;
if (xhp->target_arch)
arch = xhp->target_arch;
else
arch = xhp->native_arch;
if (target == NULL) {
if ((strcmp(orig, "noarch") == 0) ||
(strcmp(orig, xhp->un_machine) == 0))
(strcmp(orig, arch) == 0))
return true;
} else {
if ((strcmp(orig, "noarch") == 0) ||