Line 5... |
Line 5... |
5 |
buildidx computes an index tsv file for the SvarDOS repository.
|
5 |
buildidx computes an index tsv file for the SvarDOS repository.
|
6 |
it must be executed pointing to a directory that stores packages (zip)
|
6 |
it must be executed pointing to a directory that stores packages (zip)
|
7 |
files. buildidx will generate the index file and save it into the package
|
7 |
files. buildidx will generate the index file and save it into the package
|
8 |
repository.
|
8 |
repository.
|
9 |
|
9 |
|
- |
|
10 |
13 feb 2021: 'title' LSM field is no longer looked after
|
10 |
11 feb 2021: lsm headers are no longer checked, so it is compatible with the simpler lsm format used by SvarDOS
|
11 |
11 feb 2021: lsm headers are no longer checked, so it is compatible with the simpler lsm format used by SvarDOS
|
11 |
13 jan 2021: removed the identification line, changed CRC32 to bsum, not creating the listing.txt file and stopped compressing index
|
12 |
13 jan 2021: removed the identification line, changed CRC32 to bsum, not creating the listing.txt file and stopped compressing index
|
12 |
23 apr 2017: uncompressed index is no longer created, added CRC32 of zib (bin only) files, if present
|
13 |
23 apr 2017: uncompressed index is no longer created, added CRC32 of zib (bin only) files, if present
|
13 |
28 aug 2016: listing.txt is always written inside the repo dir (instead of inside current dir)
|
14 |
28 aug 2016: listing.txt is always written inside the repo dir (instead of inside current dir)
|
14 |
27 aug 2016: accepting full paths to repos (starting with /...)
|
15 |
27 aug 2016: accepting full paths to repos (starting with /...)
|
Line 98... |
Line 99... |
98 |
}
|
99 |
}
|
99 |
if (linelen < maxlen) line[linelen++] = bytebuff;
|
100 |
if (linelen < maxlen) line[linelen++] = bytebuff;
|
100 |
}
|
101 |
}
|
101 |
}
|
102 |
}
|
102 |
|
103 |
|
103 |
static int readlsm(const char *filename, char *version, char *title, char *description) {
|
104 |
static int readlsm(const char *filename, char *version, char *description) {
|
104 |
char linebuff[1024];
|
105 |
char linebuff[1024];
|
105 |
char *valuestr;
|
106 |
char *valuestr;
|
106 |
int x;
|
107 |
int x;
|
107 |
FILE *fd;
|
108 |
FILE *fd;
|
108 |
/* reset fields to be read to empty values */
|
109 |
/* reset fields to be read to empty values */
|
109 |
version[0] = 0;
|
110 |
version[0] = 0;
|
110 |
description[0] = 0;
|
111 |
description[0] = 0;
|
111 |
title[0] = 0;
|
- |
|
112 |
/* open the file */
|
112 |
/* open the file */
|
113 |
fd = fopen(filename, "rb");
|
113 |
fd = fopen(filename, "rb");
|
114 |
if (fd == NULL) return(-1);
|
114 |
if (fd == NULL) return(-1);
|
115 |
/* read the LSM file line by line */
|
115 |
/* read the LSM file line by line */
|
116 |
while (readline_fromfile(fd, linebuff, 127) >= 0) {
|
116 |
while (readline_fromfile(fd, linebuff, 127) >= 0) {
|
Line 126... |
Line 126... |
126 |
linebuff[x] = 0;
|
126 |
linebuff[x] = 0;
|
127 |
valuestr = linebuff + x + 1;
|
127 |
valuestr = linebuff + x + 1;
|
128 |
trim(linebuff);
|
128 |
trim(linebuff);
|
129 |
trim(valuestr);
|
129 |
trim(valuestr);
|
130 |
if (strcasecmp(linebuff, "version") == 0) {
|
130 |
if (strcasecmp(linebuff, "version") == 0) {
|
131 |
sprintf(version, "%s", valuestr);
|
131 |
sprintf(version, "%s", valuestr);
|
132 |
} else if (strcasecmp(linebuff, "title") == 0) {
|
- |
|
133 |
sprintf(title, "%s", valuestr);
|
- |
|
134 |
} else if (strcasecmp(linebuff, "description") == 0) {
|
132 |
} else if (strcasecmp(linebuff, "description") == 0) {
|
135 |
sprintf(description, "%s", valuestr);
|
133 |
sprintf(description, "%s", valuestr);
|
136 |
}
|
134 |
}
|
137 |
}
|
135 |
}
|
138 |
}
|
136 |
}
|
139 |
fclose(fd);
|
137 |
fclose(fd);
|
140 |
return(0);
|
138 |
return(0);
|
Line 148... |
Line 146... |
148 |
return(strcasecmp(* (char * const *) p1, * (char * const *) p2));
|
146 |
return(strcasecmp(* (char * const *) p1, * (char * const *) p2));
|
149 |
}
|
147 |
}
|
150 |
|
148 |
|
151 |
|
149 |
|
152 |
static void GenIndexes(const char *repodir) {
|
150 |
static void GenIndexes(const char *repodir) {
|
153 |
char *LsmFileList[4096];
|
151 |
char *LsmFileList[4096]; /* TODO dynamic sizing, otherwise will crash if there are 4096+ packages */
|
154 |
char tmpbuf[64];
|
152 |
char tmpbuf[64];
|
155 |
char *LsmFile, LSMpackage[64], LSMtitle[128], LSMversion[128], LSMdescription[1024];
|
153 |
char *LsmFile, LSMpackage[64], LSMversion[128], LSMdescription[1024];
|
156 |
int LsmCount = 0, x;
|
154 |
int LsmCount = 0, x;
|
157 |
FILE *idx;
|
155 |
FILE *idx;
|
158 |
DIR *dir;
|
156 |
DIR *dir;
|
159 |
struct dirent *diritem;
|
157 |
struct dirent *diritem;
|
160 |
|
158 |
|
Line 195... |
Line 193... |
195 |
bsum = file2bsum(tmpbuf);
|
193 |
bsum = file2bsum(tmpbuf);
|
196 |
|
194 |
|
197 |
printf("Processing %s... BSUM %04X\n", LsmFile, bsum);
|
195 |
printf("Processing %s... BSUM %04X\n", LsmFile, bsum);
|
198 |
|
196 |
|
199 |
sprintf(tmpbuf, "appinfo/%s", LsmFile);
|
197 |
sprintf(tmpbuf, "appinfo/%s", LsmFile);
|
200 |
readlsm(tmpbuf, LSMversion, LSMtitle, LSMdescription);
|
198 |
readlsm(tmpbuf, LSMversion, LSMdescription);
|
201 |
|
199 |
|
202 |
if (strlen(LSMpackage) > 8) printf("Warning: %s.zip is not in 8.3 format!\n", LSMpackage);
|
200 |
if (strlen(LSMpackage) > 8) printf("Warning: %s.zip is not in 8.3 format!\n", LSMpackage);
|
203 |
if (LSMtitle[0] == 0) printf("Warning: no LSM title for %s.zip\n", LSMpackage);
|
- |
|
204 |
if (LSMversion[0] == 0) printf("Warning: no LSM version for %s.zip!\n", LSMpackage);
|
201 |
if (LSMversion[0] == 0) printf("Warning: no LSM version for %s.zip!\n", LSMpackage);
|
205 |
if (LSMdescription[0] == 0) printf("Warning: no LSM description for %s.zip!\n", LSMpackage);
|
202 |
if (LSMdescription[0] == 0) printf("Warning: no LSM description for %s.zip!\n", LSMpackage);
|
206 |
fprintf(idx, "%s\t%s\t%s\t%u\n", LSMpackage, LSMversion, LSMdescription, bsum);
|
203 |
fprintf(idx, "%s\t%s\t%s\t%u\n", LSMpackage, LSMversion, LSMdescription, bsum);
|
207 |
}
|
204 |
}
|
208 |
fclose(idx);
|
205 |
fclose(idx);
|