#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <pkgstrct.h>
#include <pkglocs.h>
#include <locale.h>
#include <libintl.h>
#include <install.h>
#include <pkglib.h>
#include <libadm.h>
#include <libinst.h>
extern int dbchg;
static int client_refer(struct cfextra **ext);
static int server_refer(struct cfextra **ext);
int
sortmap(struct cfextra ***extlist, VFP_T *pkgmapVfp,
PKGserver pkgserver, VFP_T *tmpvfp, char *a_zoneName)
{
int i, n, nparts;
char *db_mrg = "unable to merge package and system information";
if (a_zoneName == (char *)NULL) {
echo(gettext("## Processing package information."));
} else {
echo(gettext("## Processing package information in zone <%s>."),
a_zoneName);
}
if (is_relocatable() && is_an_inst_root())
putparam("BASEDIR", get_info_basedir());
vfpRewind(pkgmapVfp);
*extlist = pkgobjmap(pkgmapVfp, 2, NULL);
if (*extlist == NULL) {
progerr(gettext("unable to process pkgmap"));
quit(99);
}
if (is_an_inst_root()) {
(void) client_refer(*extlist);
}
if (a_zoneName == (char *)NULL) {
echo(gettext("## Processing system information."));
} else {
echo(gettext("## Processing system information in zone <%s>."),
a_zoneName);
}
nparts = 0;
if (is_depend_pkginfo_DB() == B_FALSE) {
for (i = 0; (*extlist)[i]; i++) {
n = (*extlist)[i]->cf_ent.volno;
if (n > nparts)
nparts = n;
}
vfpTruncate(tmpvfp);
dbchg = pkgdbmerg(pkgserver, tmpvfp, *extlist);
if (dbchg < 0) {
progerr(gettext(db_mrg));
quit(99);
}
}
if (is_relocatable() && is_an_inst_root())
putparam("BASEDIR", get_basedir());
if (is_an_inst_root()) {
(void) server_refer(*extlist);
}
return (nparts);
}
static int
client_refer(struct cfextra **ext)
{
int count;
for (count = 0; ext[count] != (struct cfextra *)NULL; count++) {
ext[count]->cf_ent.path = ext[count]->client_path;
ext[count]->cf_ent.ainfo.local = ext[count]->client_local;
}
return (1);
}
static int
server_refer(struct cfextra **ext)
{
int count;
for (count = 0; ext[count] != (struct cfextra *)NULL; count++) {
ext[count]->cf_ent.path = ext[count]->server_path;
ext[count]->cf_ent.ainfo.local = ext[count]->server_local;
}
return (1);
}