summaryrefslogtreecommitdiffstats
path: root/utils/genhdlist.c
diff options
context:
space:
mode:
authorMatt Wilson <msw@redhat.com>2001-01-17 20:23:45 +0000
committerMatt Wilson <msw@redhat.com>2001-01-17 20:23:45 +0000
commitc4607e4f28095b0d0230f4ca0095a2ae0112139f (patch)
tree5e6362a9a8c810894cf9c3f4b612ed5fb4e5397e /utils/genhdlist.c
parent29cda3d82b4443cb65cb7a5a502f989d199f1214 (diff)
downloadanaconda-c4607e4f28095b0d0230f4ca0095a2ae0112139f.tar.gz
anaconda-c4607e4f28095b0d0230f4ca0095a2ae0112139f.tar.xz
anaconda-c4607e4f28095b0d0230f4ca0095a2ae0112139f.zip
add a tag for ordering
Diffstat (limited to 'utils/genhdlist.c')
-rw-r--r--utils/genhdlist.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/utils/genhdlist.c b/utils/genhdlist.c
index eff2985bd..7f4daface 100644
--- a/utils/genhdlist.c
+++ b/utils/genhdlist.c
@@ -8,6 +8,7 @@
#include <dirent.h>
#include <popt.h>
#include <rpmlib.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
@@ -17,6 +18,7 @@
#define FILENAME_TAG 1000000
#define FILESIZE_TAG 1000001
#define CDNUM_TAG 1000002
+#define ORDER_TAG 1000003
struct onePackageInfo {
char * name;
@@ -37,6 +39,28 @@ int pkgInfoCmp(const void * a, const void * b) {
struct onePackageInfo * pkgList;
int pkgListItems = 0;
int pkgListAlloced = 0;
+char ** depOrder = NULL;
+
+/* mmmm... linear search */
+int getOrder (char * fn)
+{
+ char *p = NULL;
+ int i = 0;
+
+ if (!depOrder || !depOrder[0] || !depOrder[0][0]) {
+ return -1;
+ }
+
+ p = depOrder[i];
+ while (p && *p && strncmp (fn, p, strlen(p))) {
+ p = depOrder[i++];
+ }
+ if (p) {
+ return i;
+ }
+
+ return -1;
+}
int onePass(FD_t outfd, const char * dirName, int cdNum) {
FD_t fd;
@@ -50,6 +74,7 @@ int onePass(FD_t outfd, const char * dirName, int cdNum) {
struct stat sb;
int_32 * fileSizes;
int fileCount;
+ int order = 0;
sprintf(subdir, "%s/RedHat/RPMS", dirName);
@@ -153,6 +178,11 @@ int onePass(FD_t outfd, const char * dirName, int cdNum) {
headerAddEntry(h, CDNUM_TAG, RPM_INT32_TYPE,
&cdNum, 1);
+ if ((order = getOrder (ent->d_name)) > -1) {
+ headerAddEntry(h, ORDER_TAG, RPM_INT32_TYPE,
+ &order, 1);
+ }
+
headerWrite(outfd, h, HEADER_MAGIC_YES);
headerFree(h);
}
@@ -186,10 +216,12 @@ int main(int argc, const char ** argv) {
int rc;
int i;
char * hdListFile = NULL;
+ char * depOrderFile = NULL;
poptContext optCon;
struct poptOption options[] = {
{ "hdlist", '\0', POPT_ARG_STRING, &hdListFile, 0 },
{ "withnumbers", '\0', 0, &doNumber, 0 },
+ { "fileorder", '\0', POPT_ARG_STRING, &depOrderFile, 0 },
{ 0, 0, 0, 0, 0 }
};
@@ -207,6 +239,42 @@ int main(int argc, const char ** argv) {
if (!args || !args[0] || !args[0][0])
usage();
+ if (depOrderFile) {
+ FILE *f;
+ int nalloced = 0;
+ int numpkgs = 0;
+ int len = 0;
+ char buf[80];
+ char *p;
+ int i;
+
+ if (!(f = fopen(depOrderFile, "r")))
+ usage();
+
+ while ((fgets(buf, sizeof(buf) - 1, f))) {
+ if (numpkgs == nalloced) {
+ depOrder = realloc (depOrder, sizeof (char *) * (nalloced += 5));
+ memset (depOrder + numpkgs, '\0', 5);
+ }
+
+ p = buf + strlen(buf);
+ i = 0;
+ /* trim off two '.' worth of data */
+ while (p > buf && i < 2) {
+ p--;
+ if (*p == '.')
+ i++;
+ }
+ *p = '\0';
+
+ len = strlen(buf);
+ depOrder[numpkgs] = malloc (len + 1);
+ /* chomp off \n */
+ strcpy (depOrder[numpkgs], buf);
+ numpkgs++;
+ }
+ }
+
if (!hdListFile) {
strcpy(buf, args[0]);
strcat(buf, "/RedHat/base/hdlist");