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_PKGINDEX_VERSION "1.7"
#define XBPS_API_VERSION "20130307-1" #define XBPS_API_VERSION "20130307-2"
#ifndef XBPS_VERSION #ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET" #define XBPS_VERSION "UNSET"
@ -544,7 +544,8 @@ struct xbps_handle {
*/ */
char *cachedir_priv; char *cachedir_priv;
char *metadir_priv; char *metadir_priv;
char *un_machine; char *native_arch;
const char *target_arch;
/* /*
* @var repository * @var repository
* *

View File

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

View File

@ -48,6 +48,12 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp,
assert(pkgver); assert(pkgver);
assert(action); 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) { if (strcmp(xhp->rootdir, "/") == 0) {
tmpdir = getenv("TMPDIR"); tmpdir = getenv("TMPDIR");
if (tmpdir == NULL) 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. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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) xbps_rindex_sync(struct xbps_handle *xhp, const char *uri, const char *plistf)
{ {
prop_dictionary_t repod; prop_dictionary_t repod;
const char *fetchstr = NULL; const char *arch, *fetchstr = NULL;
char *rpidx, *lrepodir, *uri_fixedp, *lrepofile; char *rpidx, *lrepodir, *uri_fixedp, *lrepofile;
int rv = 0; 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); uri_fixedp = xbps_get_remote_repo_string(uri);
if (uri_fixedp == NULL) if (uri_fixedp == NULL)
return -1; return -1;
if (xhp->target_arch)
arch = xhp->target_arch;
else
arch = xhp->native_arch;
/* /*
* Remote repository plist index full URL. * 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 * Full path to repository directory to store the plist
* index file. * 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. * Full path to the local repository index file.
*/ */
lrepofile = xbps_xasprintf("%s/%s-%s", lrepodir, lrepofile = xbps_xasprintf("%s/%s-%s", lrepodir, arch, plistf);
xhp->un_machine, plistf);
/* /*
* Create repodir in metadir. * Create repodir in metadir.
*/ */

View File

@ -296,12 +296,16 @@ xbps_transaction_commit(struct xbps_handle *xhp)
goto out; goto out;
} }
} }
prop_object_iterator_reset(iter);
/* if there are no packages to install or update we are done */ /* if there are no packages to install or update we are done */
if (!update && !install) if (!update && !install)
goto out; 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. * Configure all unpacked packages.
*/ */

View File

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