Commit 93936cac50e393cefd8733351f8036d93059a034

Authored by Silvan Calarco
1 parent fac5730549
Exists in master

handleObsoletedPackages(): fix: prevent upper repositories packages to obsolete …

…packages in current repository; code formatting fixes

Showing 3 changed files with 135 additions and 137 deletions Inline Diff

1 1.5.0 1 1.5.0.1
src/backend-sqlite3.c
1 /* 1 /*
2 * distromatic - tool for RPM based repositories 2 * distromatic - tool for RPM based repositories
3 * 3 *
4 * Copyright (C) 2013-2020 by Silvan Calarco <silvan.calarco@mambasoft.it> 4 * Copyright (C) 2013-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it under 6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of version 2 of the GNU General Public License as published by the 7 * the terms of version 2 of the GNU General Public License as published by the
8 * Free Software Foundation. 8 * Free Software Foundation.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY, to the extent permitted by law; without even the implied 11 * ANY WARRANTY, to the extent permitted by law; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details. 13 * See the GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License along with 15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 */ 18 */
19 19
20 #include <sqlite3.h> 20 #include <sqlite3.h>
21 #include "headerlist.h" 21 #include "headerlist.h"
22 #include "changelog.h" 22 #include "changelog.h"
23 #include "backend-sqlite3.h" 23 #include "backend-sqlite3.h"
24 #include "functions.h" 24 #include "functions.h"
25 25
26 char sqlite3_query[PATH_MAX]; 26 char sqlite3_query[PATH_MAX];
27 sqlite3_stmt *stmt; 27 sqlite3_stmt *stmt;
28 28
29 #define sqlite3_transaction_maxsize 10485760 29 #define sqlite3_transaction_maxsize 10485760
30 long sqlite3_transaction_size; 30 long sqlite3_transaction_size;
31 31
32 int SQLite_init_table(sqlite3 *db, const char* table_name, const char* table_query) { 32 int SQLite_init_table(sqlite3 *db, const char* table_name, const char* table_query) {
33 33
34 char myquery[PATH_MAX]; 34 char myquery[PATH_MAX];
35 35
36 snprintf(myquery, PATH_MAX, "CREATE TABLE IF NOT EXISTS %s(%s)", table_name, table_query); 36 snprintf(myquery, PATH_MAX, "CREATE TABLE IF NOT EXISTS %s(%s)", table_name, table_query);
37 37
38 if (sqlite3_exec(db, myquery, 0, 0, 0)) { 38 if (sqlite3_exec(db, myquery, 0, 0, 0)) {
39 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", myquery, sqlite3_errmsg(db)); 39 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", myquery, sqlite3_errmsg(db));
40 return 2; 40 return 2;
41 } 41 }
42 return 0; 42 return 0;
43 } 43 }
44 44
45 int SQLite_begin_transaction(sqlite3 *db) { 45 int SQLite_begin_transaction(sqlite3 *db) {
46 46
47 if (sqlite3_exec(db, "BEGIN TRANSACTION;", 0, 0, 0)) { 47 if (sqlite3_exec(db, "BEGIN TRANSACTION;", 0, 0, 0)) {
48 fprintf(stderr, "ERROR: SQLite: (BEGIN TRANSACTION) %s\n", sqlite3_errmsg(db)); 48 fprintf(stderr, "ERROR: SQLite: (BEGIN TRANSACTION) %s\n", sqlite3_errmsg(db));
49 return 1; 49 return 1;
50 } 50 }
51 51
52 sqlite3_transaction_size = 0; 52 sqlite3_transaction_size = 0;
53 return 0; 53 return 0;
54 } 54 }
55 55
56 int SQLite_commit_transaction(sqlite3 *db) { 56 int SQLite_commit_transaction(sqlite3 *db) {
57 if (sqlite3_exec(db, "COMMIT;", 0, 0, 0)) { 57 if (sqlite3_exec(db, "COMMIT;", 0, 0, 0)) {
58 fprintf(stderr, "ERROR: SQLite: (COMMIT) %s\n", sqlite3_errmsg(db)); 58 fprintf(stderr, "ERROR: SQLite: (COMMIT) %s\n", sqlite3_errmsg(db));
59 return 1; 59 return 1;
60 } 60 }
61 sqlite3_transaction_size = 0; 61 sqlite3_transaction_size = 0;
62 return 0; 62 return 0;
63 } 63 }
64 64
65 int SQLite_print_contents_subtree(sqlite3 *db, 65 int SQLite_print_contents_subtree(sqlite3 *db,
66 struct fileTree* ft, 66 struct fileTree* ft,
67 struct configTag* ct, 67 struct configTag* ct,
68 int arch) { 68 int arch) {
69 69
70 int thisrep, i; 70 int thisrep, i;
71 71
72 while (ft) { 72 while (ft) {
73 i = 0; 73 i = 0;
74 thisrep = 0; 74 thisrep = 0;
75 for (i = 0; i < ft->numproviders; i++) { 75 for (i = 0; i < ft->numproviders; i++) {
76 if (ft->provider[i]->altrepository == ct->repository_level) { 76 if (ft->provider[i]->altrepository == ct->repository_level) {
77 thisrep = 1; 77 thisrep = 1;
78 break; 78 break;
79 } 79 }
80 } 80 }
81 if (thisrep) { 81 if (thisrep) {
82 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO files VALUES(%ld,?,%ld,%ld,%ld,%d);", 82 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO files VALUES(%ld,?,%ld,%ld,%ld,%d);",
83 ft->id, 83 ft->id,
84 (ft->firstchild?ft->firstchild->id:-1), 84 (ft->firstchild?ft->firstchild->id:-1),
85 (ft->next?ft->next->id:-1), 85 (ft->next?ft->next->id:-1),
86 (ft->parent?ft->parent->id:-1), 86 (ft->parent?ft->parent->id:-1),
87 ft->numproviders); 87 ft->numproviders);
88 sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL); 88 sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL);
89 sqlite3_bind_text(stmt, 1, ft->name, -1, SQLITE_STATIC); 89 sqlite3_bind_text(stmt, 1, ft->name, -1, SQLITE_STATIC);
90 if (sqlite3_step(stmt) != SQLITE_DONE) { 90 if (sqlite3_step(stmt) != SQLITE_DONE) {
91 fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query); 91 fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
92 return 1; 92 return 1;
93 } 93 }
94 sqlite3_finalize(stmt); 94 sqlite3_finalize(stmt);
95 95
96 sqlite3_transaction_size += strlen(sqlite3_query); 96 sqlite3_transaction_size += strlen(sqlite3_query);
97 if (sqlite3_transaction_size >= sqlite3_transaction_maxsize) { 97 if (sqlite3_transaction_size >= sqlite3_transaction_maxsize) {
98 SQLite_commit_transaction(db); 98 SQLite_commit_transaction(db);
99 SQLite_begin_transaction(db); 99 SQLite_begin_transaction(db);
100 } 100 }
101 101
102 if (ft->firstchild) { 102 if (ft->firstchild) {
103 if (SQLite_print_contents_subtree(db, ft->firstchild, ct, arch)) return 1; 103 if (SQLite_print_contents_subtree(db, ft->firstchild, ct, arch)) return 1;
104 } 104 }
105 } 105 }
106 ft=ft->next; 106 ft=ft->next;
107 } 107 }
108 return 0; 108 return 0;
109 } 109 }
110 110
111 #define SQLITE_TABLE_files "id INTEGER PRIMARY KEY, "\ 111 #define SQLITE_TABLE_files "id INTEGER PRIMARY KEY, "\
112 "name STRING, firstchild INTEGER, next INTEGER, parent INTEGER, numproviders INTEGER" 112 "name STRING, firstchild INTEGER, next INTEGER, parent INTEGER, numproviders INTEGER"
113 /* struct headerList **provider; */ 113 /* struct headerList **provider; */
114 114
115 #define SQLITE_TABLE_packages_files_rel "id INTEGER PRIMARY KEY, id_package INTEGER, id_file INTEGER, "\ 115 #define SQLITE_TABLE_packages_files_rel "id INTEGER PRIMARY KEY, id_package INTEGER, id_file INTEGER, "\
116 "id_user INTEGER, id_group INTEGER, flags INTEGER, "\ 116 "id_user INTEGER, id_group INTEGER, flags INTEGER, "\
117 "name STRING, version STRING, release STRING" 117 "name STRING, version STRING, release STRING"
118 #define SQLITE_TABLE_fileusers "id INTEGER PRIMARY KEY, name STRING" 118 #define SQLITE_TABLE_fileusers "id INTEGER PRIMARY KEY, name STRING"
119 #define SQLITE_TABLE_filegroups "id INTEGER PRIMARY KEY, name STRING" 119 #define SQLITE_TABLE_filegroups "id INTEGER PRIMARY KEY, name STRING"
120 120
121 int generateSQLite_files(struct configTag* ct, sqlite3 *db, int arch) { 121 int generateSQLite_files(struct configTag* ct, sqlite3 *db, int arch) {
122 122
123 int i; 123 int i;
124 struct headerList* currpackage; 124 struct headerList* currpackage;
125 struct fileUserList *fileUser = ct->fileuserlist[arch]; 125 struct fileUserList *fileUser = ct->fileuserlist[arch];
126 struct fileGroupList *fileGroup = ct->filegrouplist[arch]; 126 struct fileGroupList *fileGroup = ct->filegrouplist[arch];
127 127
128 snprintf(sqlite3_query, PATH_MAX, "packages_files_rel"); 128 snprintf(sqlite3_query, PATH_MAX, "packages_files_rel");
129 SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_packages_files_rel); 129 SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_packages_files_rel);
130 130
131 snprintf(sqlite3_query, PATH_MAX, "files"); 131 snprintf(sqlite3_query, PATH_MAX, "files");
132 SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_files); 132 SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_files);
133 133
134 snprintf(sqlite3_query, PATH_MAX, "fileusers"); 134 snprintf(sqlite3_query, PATH_MAX, "fileusers");
135 SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_fileusers); 135 SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_fileusers);
136 136
137 snprintf(sqlite3_query, PATH_MAX, "filegroups"); 137 snprintf(sqlite3_query, PATH_MAX, "filegroups");
138 SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_filegroups); 138 SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_filegroups);
139 139
140 while (fileUser) { 140 while (fileUser) {
141 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO fileusers VALUES(%ld,?);", 141 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO fileusers VALUES(%ld,?);",
142 fileUser->id); 142 fileUser->id);
143 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 143 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
144 fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query); 144 fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
145 return 1; 145 return 1;
146 } 146 }
147 sqlite3_bind_text(stmt, 1, fileUser->name, -1, SQLITE_STATIC); 147 sqlite3_bind_text(stmt, 1, fileUser->name, -1, SQLITE_STATIC);
148 if (sqlite3_step(stmt) != SQLITE_DONE) { 148 if (sqlite3_step(stmt) != SQLITE_DONE) {
149 fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_query, sqlite3_errmsg(db)); 149 fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_query, sqlite3_errmsg(db));
150 return 3; 150 return 3;
151 } 151 }
152 sqlite3_finalize(stmt); 152 sqlite3_finalize(stmt);
153 fileUser = fileUser->next; 153 fileUser = fileUser->next;
154 } 154 }
155 155
156 while (fileGroup) { 156 while (fileGroup) {
157 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO filegroups VALUES(%ld,?);", 157 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO filegroups VALUES(%ld,?);",
158 fileGroup->id); 158 fileGroup->id);
159 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 159 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
160 fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query); 160 fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
161 return 1; 161 return 1;
162 } 162 }
163 sqlite3_bind_text(stmt, 1, fileGroup->name, -1, SQLITE_STATIC); 163 sqlite3_bind_text(stmt, 1, fileGroup->name, -1, SQLITE_STATIC);
164 if (sqlite3_step(stmt) != SQLITE_DONE) { 164 if (sqlite3_step(stmt) != SQLITE_DONE) {
165 fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_query, sqlite3_errmsg(db)); 165 fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_query, sqlite3_errmsg(db));
166 return 3; 166 return 3;
167 } 167 }
168 sqlite3_finalize(stmt); 168 sqlite3_finalize(stmt);
169 fileGroup = fileGroup->next; 169 fileGroup = fileGroup->next;
170 } 170 }
171 171
172 SQLite_begin_transaction(db); 172 SQLite_begin_transaction(db);
173 if (SQLite_print_contents_subtree(db, ct->filetree[arch], ct, arch)) return 1; 173 if (SQLite_print_contents_subtree(db, ct->filetree[arch], ct, arch)) return 1;
174 174
175 currpackage = ct->headerlist[arch]; 175 currpackage = ct->headerlist[arch];
176 while (currpackage) { 176 while (currpackage) {
177 if (currpackage->altrepository == ct->repository_level) { 177 if (currpackage->altrepository == ct->repository_level) {
178 /* packages <-> files relations */ 178 /* packages <-> files relations */
179 for (i = 0; i < currpackage->filenamecount; i++) { 179 for (i = 0; i < currpackage->filenamecount; i++) {
180 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages_files_rel VALUES(NULL,%ld,%ld,%ld,%ld,%d,?,?,?);", 180 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages_files_rel VALUES(NULL,%ld,%ld,%ld,%ld,%d,?,?,?);",
181 currpackage->id, 181 currpackage->id,
182 currpackage->file[i]->id, 182 currpackage->file[i]->id,
183 currpackage->fileuser[i]->id, 183 currpackage->fileuser[i]->id,
184 currpackage->filegroup[i]->id, 184 currpackage->filegroup[i]->id,
185 currpackage->fileflags[i]); 185 currpackage->fileflags[i]);
186 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 186 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
187 fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query); 187 fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
188 return 1; 188 return 1;
189 } 189 }
190 sqlite3_bind_text(stmt, 1, currpackage->name, -1, SQLITE_STATIC); 190 sqlite3_bind_text(stmt, 1, currpackage->name, -1, SQLITE_STATIC);
191 sqlite3_bind_text(stmt, 2, currpackage->version, -1, SQLITE_STATIC); 191 sqlite3_bind_text(stmt, 2, currpackage->version, -1, SQLITE_STATIC);
192 sqlite3_bind_text(stmt, 3, currpackage->release, -1, SQLITE_STATIC); 192 sqlite3_bind_text(stmt, 3, currpackage->release, -1, SQLITE_STATIC);
193 if (sqlite3_step(stmt) != SQLITE_DONE) { 193 if (sqlite3_step(stmt) != SQLITE_DONE) {
194 fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_query, sqlite3_errmsg(db)); 194 fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_query, sqlite3_errmsg(db));
195 return 3; 195 return 3;
196 } 196 }
197 sqlite3_finalize(stmt); 197 sqlite3_finalize(stmt);
198 sqlite3_transaction_size += strlen(sqlite3_query); 198 sqlite3_transaction_size += strlen(sqlite3_query);
199 if (sqlite3_transaction_size >= sqlite3_transaction_maxsize) { 199 if (sqlite3_transaction_size >= sqlite3_transaction_maxsize) {
200 SQLite_commit_transaction(db); 200 SQLite_commit_transaction(db);
201 SQLite_begin_transaction(db); 201 SQLite_begin_transaction(db);
202 } 202 }
203 } 203 }
204 } 204 }
205 currpackage = currpackage->next; 205 currpackage = currpackage->next;
206 } 206 }
207 SQLite_commit_transaction(db); 207 SQLite_commit_transaction(db);
208 return 0; 208 return 0;
209 } 209 }
210 210
211 #define SQLITE_TABLE_provided "id INTEGER PRIMARY KEY, "\ 211 #define SQLITE_TABLE_provided "id INTEGER PRIMARY KEY, "\
212 "name STRING, flags INTEGER, numproviders INTEGER" 212 "name STRING, flags INTEGER, numproviders INTEGER"
213 213
214 int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) { 214 int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) {
215 215
216 struct providedList* provided; 216 struct providedList* provided;
217 int i, thisrep; 217 int i, thisrep;
218 218
219 SQLite_init_table(db, "provided", SQLITE_TABLE_provided); 219 SQLite_init_table(db, "provided", SQLITE_TABLE_provided);
220 SQLite_begin_transaction(db); 220 SQLite_begin_transaction(db);
221 221
222 provided = ct->providedlist_idx[arch][0]; 222 provided = ct->providedlist_idx[arch][0];
223 while (provided) { 223 while (provided) {
224 i = 0; 224 i = 0;
225 thisrep = 0; 225 thisrep = 0;
226 for (i = 0; i < provided->numproviders; i++) { 226 for (i = 0; i < provided->numproviders; i++) {
227 if (provided->provider[i]->altrepository == ct->repository_level) { 227 if (provided->provider[i]->altrepository == ct->repository_level) {
228 thisrep = 1; 228 thisrep = 1;
229 break; 229 break;
230 } 230 }
231 } 231 }
232 if (thisrep) { 232 if (thisrep) {
233 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%ld,?,%ld,%d);", 233 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%ld,?,%ld,%d);",
234 provided->id, 234 provided->id,
235 provided->flags, 235 provided->flags,
236 provided->numproviders); 236 provided->numproviders);
237 if (sqlite3_prepare_v3(db, sqlite3_query, -1, 0, &stmt, NULL)) { 237 if (sqlite3_prepare_v3(db, sqlite3_query, -1, 0, &stmt, NULL)) {
238 fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query); 238 fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n",
239 sqlite3_errmsg(db), sqlite3_query);
239 return 1; 240 return 1;
240 } 241 }
241 sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC); 242 sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC);
242 if (sqlite3_step(stmt) != SQLITE_DONE) { 243 if (sqlite3_step(stmt) != SQLITE_DONE) {
243 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 244 fprintf(stderr, "ERROR: SQLite: (%s %s) %s; ignoring\n", sqlite3_query,
244 return 3; 245 provided->name, sqlite3_errmsg(db));
245 } 246 }
246 sqlite3_finalize(stmt); 247 sqlite3_finalize(stmt);
247 } 248 }
248 provided = provided->next; 249 provided = provided->next;
249 } 250 }
250 SQLite_commit_transaction(db); 251 SQLite_commit_transaction(db);
251 return 0; 252 return 0;
252 } 253 }
253 254
254 #define SQLITE_TABLE_packagers "id INTEGER PRIMARY KEY, "\ 255 #define SQLITE_TABLE_packagers "id INTEGER PRIMARY KEY, "\
255 "name STRING, role INTEGER, changes_count INTEGER, packages_count INTEGER" 256 "name STRING, role INTEGER, changes_count INTEGER, packages_count INTEGER"
256 /* char *alias[PACKAGER_MAXALIASES]; */ 257 /* char *alias[PACKAGER_MAXALIASES]; */
257 258
258 int generateSQLite_packagers(sqlite3 *db) { 259 int generateSQLite_packagers(sqlite3 *db) {
259 260
260 struct Packager* packager = firstPackager(); 261 struct Packager* packager = firstPackager();
261 262
262 SQLite_init_table(db, "packagers", SQLITE_TABLE_packagers); 263 SQLite_init_table(db, "packagers", SQLITE_TABLE_packagers);
263 SQLite_begin_transaction(db); 264 SQLite_begin_transaction(db);
264 265
265 while (packager) { 266 while (packager) {
266 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packagers VALUES(NULL,?,%d,%d,%d);", 267 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packagers VALUES(NULL,?,%d,%d,%d);",
267 packager->role, 268 packager->role,
268 packager->changes_count, 269 packager->changes_count,
269 packager->packages_count); 270 packager->packages_count);
270 271
271 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 272 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
272 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 273 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
273 } 274 }
274 sqlite3_bind_text(stmt, 1, packager->name, -1, SQLITE_STATIC); 275 sqlite3_bind_text(stmt, 1, packager->name, -1, SQLITE_STATIC);
275 if (sqlite3_step(stmt) != SQLITE_DONE) { 276 if (sqlite3_step(stmt) != SQLITE_DONE) {
276 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 277 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
277 return 3; 278 return 3;
278 } 279 }
279 packager->id = sqlite3_last_insert_rowid(db); 280 packager->id = sqlite3_last_insert_rowid(db);
280 sqlite3_finalize(stmt); 281 sqlite3_finalize(stmt);
281 packager = packager->next; 282 packager = packager->next;
282 } 283 }
283 SQLite_commit_transaction(db); 284 SQLite_commit_transaction(db);
284 return 0; 285 return 0;
285 } 286 }
286 287
287 long generateSQLite_add_changelog(sqlite3 *db, struct changeLog* firstchangelog, long id_source) { 288 long generateSQLite_add_changelog(sqlite3 *db, struct changeLog* firstchangelog, long id_source) {
288 289
289 struct changeLog* changelog = firstchangelog; 290 struct changeLog* changelog = firstchangelog;
290 long lastchangelogid = 0; 291 long lastchangelogid = 0;
291 292
292 while (changelog) { 293 while (changelog) {
293 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO changelog VALUES(NULL,%ld,%ld,%ld,?,?);", 294 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO changelog VALUES(NULL,%ld,%ld,%ld,?,?);",
294 id_source, 295 id_source,
295 changelog->time, 296 changelog->time,
296 changelog->pkg->id); 297 changelog->pkg->id);
297 298
298 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 299 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
299 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 300 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
300 } 301 }
301 sqlite3_bind_text(stmt, 1, changelog->release, -1, SQLITE_STATIC); 302 sqlite3_bind_text(stmt, 1, changelog->release, -1, SQLITE_STATIC);
302 sqlite3_bind_text(stmt, 2, changelog->text, -1, SQLITE_STATIC); 303 sqlite3_bind_text(stmt, 2, changelog->text, -1, SQLITE_STATIC);
303 if (sqlite3_step(stmt) != SQLITE_DONE) { 304 if (sqlite3_step(stmt) != SQLITE_DONE) {
304 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 305 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
305 return 3; 306 return 3;
306 } 307 }
307 changelog->id = sqlite3_last_insert_rowid(db); 308 changelog->id = sqlite3_last_insert_rowid(db);
308 lastchangelogid = changelog->id; 309 lastchangelogid = changelog->id;
309 sqlite3_finalize(stmt); 310 sqlite3_finalize(stmt);
310 changelog = changelog->next; 311 changelog = changelog->next;
311 } 312 }
312 return lastchangelogid; 313 return lastchangelogid;
313 } 314 }
314 315
315 #define SQLITE_TABLE_packages "id INTEGER PRIMARY KEY, "\ 316 #define SQLITE_TABLE_packages "id INTEGER PRIMARY KEY, "\
316 "name STRING, altrepository INTEGER, epoch INTEGER, version STRING, release STRING, summary STRING, "\ 317 "name STRING, altrepository INTEGER, epoch INTEGER, version STRING, release STRING, summary STRING, "\
317 "groupdescr STRING, description STRING, size INTEGER, id_source INTEGER" 318 "groupdescr STRING, description STRING, size INTEGER, id_source INTEGER"
318 319
319 #define SQLITE_TABLE_obsoletes "id INTEGER PRIMARY KEY, "\ 320 #define SQLITE_TABLE_obsoletes "id INTEGER PRIMARY KEY, "\
320 "id_package INTEGER, obsoletename STRING, obsoleteflags INTEGER, obsoleteversion STRING" 321 "id_package INTEGER, obsoletename STRING, obsoleteflags INTEGER, obsoleteversion STRING"
321 322
322 #define SQLITE_TABLE_provides "id INTEGER PRIMARY KEY, "\ 323 #define SQLITE_TABLE_provides "id INTEGER PRIMARY KEY, "\
323 "id_package INTEGER, id_provided INTEGER, provideflags INTEGER, provideversion STRING" 324 "id_package INTEGER, id_provided INTEGER, provideflags INTEGER, provideversion STRING"
324 325
325 #define SQLITE_TABLE_requires "id INTEGER PRIMARY KEY, "\ 326 #define SQLITE_TABLE_requires "id INTEGER PRIMARY KEY, "\
326 "id_package INTEGER, id_provided STRING, requireflags INTEGER, requireversion STRING" 327 "id_package INTEGER, id_provided STRING, requireflags INTEGER, requireversion STRING"
327 328
328 int 329 int
329 generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) { 330 generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
330 331
331 struct headerList* currpackage; 332 struct headerList* currpackage;
332 int i; 333 int i;
333 334
334 SQLite_init_table(db, "packages", SQLITE_TABLE_packages); 335 SQLite_init_table(db, "packages", SQLITE_TABLE_packages);
335 SQLite_init_table(db, "obsoletes", SQLITE_TABLE_obsoletes); 336 SQLite_init_table(db, "obsoletes", SQLITE_TABLE_obsoletes);
336 SQLite_init_table(db, "provides", SQLITE_TABLE_provides); 337 SQLite_init_table(db, "provides", SQLITE_TABLE_provides);
337 SQLite_init_table(db, "requires", SQLITE_TABLE_requires); 338 SQLite_init_table(db, "requires", SQLITE_TABLE_requires);
338 SQLite_begin_transaction(db); 339 SQLite_begin_transaction(db);
339 340
340 currpackage = ct->headerlist[arch]; 341 currpackage = ct->headerlist[arch];
341 while (currpackage) { 342 while (currpackage) {
342 if (currpackage->altrepository == ct->repository_level) { 343 if (currpackage->altrepository == ct->repository_level) {
343 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages VALUES(NULL,?,%d,%ld,?,?,?,?,?,%ld,%ld);", 344 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages VALUES(NULL,?,%d,%ld,?,?,?,?,?,%ld,%ld);",
344 currpackage->altrepository, 345 currpackage->altrepository,
345 currpackage->epoch, 346 currpackage->epoch,
346 currpackage->size, 347 currpackage->size,
347 currpackage->sourceheader->id); 348 currpackage->sourceheader->id);
348 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 349 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
349 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 350 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
350 return 1; 351 return 1;
351 } 352 }
352 353
353 sqlite3_bind_text(stmt, 1, currpackage->name, -1, SQLITE_STATIC); 354 sqlite3_bind_text(stmt, 1, currpackage->name, -1, SQLITE_STATIC);
354 sqlite3_bind_text(stmt, 2, currpackage->version, -1, SQLITE_STATIC); 355 sqlite3_bind_text(stmt, 2, currpackage->version, -1, SQLITE_STATIC);
355 sqlite3_bind_text(stmt, 3, currpackage->release, -1, SQLITE_STATIC); 356 sqlite3_bind_text(stmt, 3, currpackage->release, -1, SQLITE_STATIC);
356 sqlite3_bind_text(stmt, 4, currpackage->summary, -1, SQLITE_STATIC); 357 sqlite3_bind_text(stmt, 4, currpackage->summary, -1, SQLITE_STATIC);
357 sqlite3_bind_text(stmt, 5, currpackage->group, -1, SQLITE_STATIC); 358 sqlite3_bind_text(stmt, 5, currpackage->group, -1, SQLITE_STATIC);
358 sqlite3_bind_text(stmt, 6, currpackage->description, -1, SQLITE_STATIC); 359 sqlite3_bind_text(stmt, 6, currpackage->description, -1, SQLITE_STATIC);
359 360
360 if (sqlite3_step(stmt) != SQLITE_DONE) { 361 if (sqlite3_step(stmt) != SQLITE_DONE) {
361 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 362 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
362 return 3; 363 return 3;
363 } 364 }
364 currpackage->id = sqlite3_last_insert_rowid(db); 365 currpackage->id = sqlite3_last_insert_rowid(db);
365 sqlite3_finalize(stmt); 366 sqlite3_finalize(stmt);
366 367
367 /* obsoletes */ 368 /* obsoletes */
368 for (i = 0; i < currpackage->obsoletecount; i++) { 369 for (i = 0; i < currpackage->obsoletecount; i++) {
369 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO obsoletes VALUES(NULL,%ld,?,%d,?);", 370 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO obsoletes VALUES(NULL,%ld,?,%d,?);",
370 currpackage->id, 371 currpackage->id,
371 currpackage->obsoleteflags[i]); 372 currpackage->obsoleteflags[i]);
372 373
373 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 374 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
374 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 375 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
375 } 376 }
376 sqlite3_bind_text(stmt, 1, currpackage->obsoletename[i], -1, SQLITE_STATIC); 377 sqlite3_bind_text(stmt, 1, currpackage->obsoletename[i], -1, SQLITE_STATIC);
377 sqlite3_bind_text(stmt, 2, currpackage->obsoleteversion[i], -1, SQLITE_STATIC); 378 sqlite3_bind_text(stmt, 2, currpackage->obsoleteversion[i], -1, SQLITE_STATIC);
378 if (sqlite3_step(stmt) != SQLITE_DONE) { 379 if (sqlite3_step(stmt) != SQLITE_DONE) {
379 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 380 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
380 return 3; 381 return 3;
381 } 382 }
382 sqlite3_finalize(stmt); 383 sqlite3_finalize(stmt);
383 } 384 }
384 385
385 /* provides */ 386 /* provides */
386 for (i = 0; i < currpackage->providecount; i++) { 387 for (i = 0; i < currpackage->providecount; i++) {
387 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provides VALUES(NULL,%ld,%ld,%d,?);", 388 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provides VALUES(NULL,%ld,%ld,%d,?);",
388 currpackage->id, 389 currpackage->id,
389 currpackage->provided[i]->id, 390 currpackage->provided[i]->id,
390 currpackage->provideflags[i]); 391 currpackage->provideflags[i]);
391 392
392 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 393 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
393 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 394 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
394 } 395 }
395 sqlite3_bind_text(stmt, 1, currpackage->provideversion[i], -1, SQLITE_STATIC); 396 sqlite3_bind_text(stmt, 1, currpackage->provideversion[i], -1, SQLITE_STATIC);
396 if (sqlite3_step(stmt) != SQLITE_DONE) { 397 if (sqlite3_step(stmt) != SQLITE_DONE) {
397 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 398 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
398 return 3; 399 return 3;
399 } 400 }
400 sqlite3_finalize(stmt); 401 sqlite3_finalize(stmt);
401 } 402 }
402 403
403 /* requires */ 404 /* requires */
404 for (i = 0; i < currpackage->requirecount; i++) { 405 for (i = 0; i < currpackage->requirecount; i++) {
405 if (currpackage->require[i]->resolved) { 406 if (currpackage->require[i]->resolved) {
406 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO requires VALUES(NULL,%ld,%ld,%ld,?);", 407 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO requires VALUES(NULL,%ld,%ld,%ld,?);",
407 currpackage->id, 408 currpackage->id,
408 currpackage->require[i]->resolved->id, 409 currpackage->require[i]->resolved->id,
409 currpackage->require[i]->flags); 410 currpackage->require[i]->flags);
410 411
411 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 412 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
412 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 413 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
413 } 414 }
414 sqlite3_bind_text(stmt, 1, currpackage->require[i]->version, -1, SQLITE_STATIC); 415 sqlite3_bind_text(stmt, 1, currpackage->require[i]->version, -1, SQLITE_STATIC);
415 if (sqlite3_step(stmt) != SQLITE_DONE) { 416 if (sqlite3_step(stmt) != SQLITE_DONE) {
416 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 417 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
417 return 3; 418 return 3;
418 } 419 }
419 sqlite3_finalize(stmt); 420 sqlite3_finalize(stmt);
420 } else if (strstr(currpackage->require[i]->name,"rpmlib(") != currpackage->require[i]->name) { 421 } else if (strstr(currpackage->require[i]->name,"rpmlib(") != currpackage->require[i]->name) {
421 fprintf(stderr, "WARNING: package %s require %s not in provided list\n", currpackage->name, currpackage->require[i]->name); 422 fprintf(stderr, "WARNING: package %s require %s not in provided list\n", currpackage->name, currpackage->require[i]->name);
422 } 423 }
423 } 424 }
424 } 425 }
425 currpackage = currpackage->next; 426 currpackage = currpackage->next;
426 } 427 }
427 SQLite_commit_transaction(db); 428 SQLite_commit_transaction(db);
428 return 0; 429 return 0;
429 } 430 }
430 431
431 #define SQLITE_TABLE_sources_source "id INTEGER PRIMARY KEY, id_source INTEGER, source STRING" 432 #define SQLITE_TABLE_sources_source "id INTEGER PRIMARY KEY, id_source INTEGER, source STRING"
432 #define SQLITE_TABLE_sources_patch "id INTEGER PRIMARY KEY, id_source INTEGER, patch STRING" 433 #define SQLITE_TABLE_sources_patch "id INTEGER PRIMARY KEY, id_source INTEGER, patch STRING"
433 #define SQLITE_TABLE_sources "id INTEGER PRIMARY KEY, "\ 434 #define SQLITE_TABLE_sources "id INTEGER PRIMARY KEY, "\
434 "name STRING, altrepository INTEGER, epoch INTEGER, version STRING, release STRING, summary STRING, id_packager INTEGER, "\ 435 "name STRING, altrepository INTEGER, epoch INTEGER, version STRING, release STRING, summary STRING, id_packager INTEGER, "\
435 "groupdescr STRING, description STRING, url STRING, license STRING, arch STRING, buildarchs STRING, " \ 436 "groupdescr STRING, description STRING, url STRING, license STRING, arch STRING, buildarchs STRING, " \
436 "excludearch STRING, buildtime INTEGER, size INTEGER, id_changelog INTEGER" 437 "excludearch STRING, buildtime INTEGER, size INTEGER, id_changelog INTEGER"
437 //#define SQLITE_TABLE_sources_files_rel "id INTEGER PRIMARY KEY, id_source INTEGER, id_files INTEGER" 438 //#define SQLITE_TABLE_sources_files_rel "id INTEGER PRIMARY KEY, id_source INTEGER, id_files INTEGER"
438 //#define SQLITE_TABLE_sources_provided_rel "id INTEGER PRIMARY KEY, id_source INTEGER, id_provided INTEGER" 439 //#define SQLITE_TABLE_sources_provided_rel "id INTEGER PRIMARY KEY, id_source INTEGER, id_provided INTEGER"
439 #define SQLITE_TABLE_changelog "id INTEGER PRIMARY KEY, "\ 440 #define SQLITE_TABLE_changelog "id INTEGER PRIMARY KEY, "\
440 "id_source INTEGER, time INTEGER, id_packager INTEGER, release STRING, text STRING" 441 "id_source INTEGER, time INTEGER, id_packager INTEGER, release STRING, text STRING"
441 #define SQLITE_TABLE_buildrequires "id INTEGER PRIMARY KEY, "\ 442 #define SQLITE_TABLE_buildrequires "id INTEGER PRIMARY KEY, "\
442 "id_source INTEGER, buildrequirename STRING, buildrequireflags INTEGER, buildrequireversion STRING" 443 "id_source INTEGER, buildrequirename STRING, buildrequireflags INTEGER, buildrequireversion STRING"
443 444
444 int 445 int
445 generateSQLite_sources(struct configTag *ct, sqlite3 *db) { 446 generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
446 447
447 struct headerSourceList* currsource; 448 struct headerSourceList* currsource;
448 int i; 449 int i;
449 long nextchangelogid = 1; 450 long nextchangelogid = 1;
450 451
451 SQLite_init_table(db, "sources", SQLITE_TABLE_sources); 452 SQLite_init_table(db, "sources", SQLITE_TABLE_sources);
452 SQLite_init_table(db, "sources_source", SQLITE_TABLE_sources_source); 453 SQLite_init_table(db, "sources_source", SQLITE_TABLE_sources_source);
453 SQLite_init_table(db, "sources_patch", SQLITE_TABLE_sources_patch); 454 SQLite_init_table(db, "sources_patch", SQLITE_TABLE_sources_patch);
454 // SQLite_init_table(db, "sources_files_rel", SQLITE_TABLE_sources_files_rel); 455 // SQLite_init_table(db, "sources_files_rel", SQLITE_TABLE_sources_files_rel);
455 // SQLite_init_table(db, "sources_provided_rel", SQLITE_TABLE_sources_provided_rel); 456 // SQLite_init_table(db, "sources_provided_rel", SQLITE_TABLE_sources_provided_rel);
456 SQLite_init_table(db, "changelog", SQLITE_TABLE_changelog); 457 SQLite_init_table(db, "changelog", SQLITE_TABLE_changelog);
457 SQLite_init_table(db, "buildrequires", SQLITE_TABLE_buildrequires); 458 SQLite_init_table(db, "buildrequires", SQLITE_TABLE_buildrequires);
458 SQLite_begin_transaction(db); 459 SQLite_begin_transaction(db);
459 460
460 currsource = ct->headersourcelist; 461 currsource = ct->headersourcelist;
461 while (currsource != NULL) { 462 while (currsource != NULL) {
462 if (currsource->altrepository == ct->repository_level) { 463 if (currsource->altrepository == ct->repository_level) {
463 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources VALUES(%ld,?,%d,%ld,?,?,?,%ld,?,?,?,?,?,?,?,%ld,%ld,%ld);", 464 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources VALUES(%ld,?,%d,%ld,?,?,?,%ld,?,?,?,?,?,?,?,%ld,%ld,%ld);",
464 currsource->id, 465 currsource->id,
465 currsource->altrepository, 466 currsource->altrepository,
466 currsource->epoch, 467 currsource->epoch,
467 currsource->packager->id, 468 currsource->packager->id,
468 currsource->buildtime, 469 currsource->buildtime,
469 currsource->size, 470 currsource->size,
470 (currsource->changelog?nextchangelogid:0)); 471 (currsource->changelog?nextchangelogid:0));
471 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 472 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
472 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 473 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
473 } 474 }
474 475
475 sqlite3_bind_text(stmt, 1, currsource->name, -1, SQLITE_STATIC); 476 sqlite3_bind_text(stmt, 1, currsource->name, -1, SQLITE_STATIC);
476 sqlite3_bind_text(stmt, 2, currsource->version, -1, SQLITE_STATIC); 477 sqlite3_bind_text(stmt, 2, currsource->version, -1, SQLITE_STATIC);
477 sqlite3_bind_text(stmt, 3, currsource->release, -1, SQLITE_STATIC); 478 sqlite3_bind_text(stmt, 3, currsource->release, -1, SQLITE_STATIC);
478 sqlite3_bind_text(stmt, 4, currsource->summary, -1, SQLITE_STATIC); 479 sqlite3_bind_text(stmt, 4, currsource->summary, -1, SQLITE_STATIC);
479 sqlite3_bind_text(stmt, 5, currsource->group, -1, SQLITE_STATIC); 480 sqlite3_bind_text(stmt, 5, currsource->group, -1, SQLITE_STATIC);
480 sqlite3_bind_text(stmt, 6, currsource->description, -1, SQLITE_STATIC); 481 sqlite3_bind_text(stmt, 6, currsource->description, -1, SQLITE_STATIC);
481 sqlite3_bind_text(stmt, 7, currsource->url, -1, SQLITE_STATIC); 482 sqlite3_bind_text(stmt, 7, currsource->url, -1, SQLITE_STATIC);
482 sqlite3_bind_text(stmt, 8, currsource->license, -1, SQLITE_STATIC); 483 sqlite3_bind_text(stmt, 8, currsource->license, -1, SQLITE_STATIC);
483 sqlite3_bind_text(stmt, 9, currsource->arch, -1, SQLITE_STATIC); 484 sqlite3_bind_text(stmt, 9, currsource->arch, -1, SQLITE_STATIC);
484 sqlite3_bind_text(stmt, 10, currsource->buildarchs, -1, SQLITE_STATIC); 485 sqlite3_bind_text(stmt, 10, currsource->buildarchs, -1, SQLITE_STATIC);
485 sqlite3_bind_text(stmt, 11, currsource->excludearch, -1, SQLITE_STATIC); 486 sqlite3_bind_text(stmt, 11, currsource->excludearch, -1, SQLITE_STATIC);
486 487
487 if (sqlite3_step(stmt) != SQLITE_DONE) { 488 if (sqlite3_step(stmt) != SQLITE_DONE) {
488 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 489 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
489 return 3; 490 return 3;
490 } 491 }
491 currsource->id = sqlite3_last_insert_rowid(db); 492 currsource->id = sqlite3_last_insert_rowid(db);
492 sqlite3_finalize(stmt); 493 sqlite3_finalize(stmt);
493 494
494 /* source */ 495 /* source */
495 if (currsource->source) { 496 if (currsource->source) {
496 i=0; 497 i=0;
497 while (currsource->source[i]) { 498 while (currsource->source[i]) {
498 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_source VALUES(NULL,%ld,?);", 499 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_source VALUES(NULL,%ld,?);",
499 currsource->id); 500 currsource->id);
500 501
501 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 502 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
502 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 503 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
503 } 504 }
504 sqlite3_bind_text(stmt, 1, currsource->source[i], -1, SQLITE_STATIC); 505 sqlite3_bind_text(stmt, 1, currsource->source[i], -1, SQLITE_STATIC);
505 if (sqlite3_step(stmt) != SQLITE_DONE) { 506 if (sqlite3_step(stmt) != SQLITE_DONE) {
506 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 507 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
507 return 3; 508 return 3;
508 } 509 }
509 sqlite3_finalize(stmt); 510 sqlite3_finalize(stmt);
510 i++; 511 i++;
511 } 512 }
512 } 513 }
513 514
514 /* patch */ 515 /* patch */
515 if (currsource->patch) { 516 if (currsource->patch) {
516 i=0; 517 i=0;
517 while (currsource->patch[i]) { 518 while (currsource->patch[i]) {
518 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_patch VALUES(NULL,%ld,?);", 519 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_patch VALUES(NULL,%ld,?);",
519 currsource->id); 520 currsource->id);
520 521
521 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 522 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
522 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 523 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
523 } 524 }
524 sqlite3_bind_text(stmt, 1, currsource->patch[i], -1, SQLITE_STATIC); 525 sqlite3_bind_text(stmt, 1, currsource->patch[i], -1, SQLITE_STATIC);
525 if (sqlite3_step(stmt) != SQLITE_DONE) { 526 if (sqlite3_step(stmt) != SQLITE_DONE) {
526 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 527 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
527 return 3; 528 return 3;
528 } 529 }
529 sqlite3_finalize(stmt); 530 sqlite3_finalize(stmt);
530 i++; 531 i++;
531 } 532 }
532 } 533 }
533 534
534 /* buildrequires */ 535 /* buildrequires */
535 for (i = 0; i < currsource->requirecount; i++) { 536 for (i = 0; i < currsource->requirecount; i++) {
536 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO buildrequires VALUES(NULL,%ld,?,%ld,?);", 537 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO buildrequires VALUES(NULL,%ld,?,%ld,?);",
537 currsource->id, 538 currsource->id,
538 currsource->require[i]->flags); 539 currsource->require[i]->flags);
539 540
540 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 541 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
541 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 542 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
542 } 543 }
543 sqlite3_bind_text(stmt, 1, currsource->require[i]->name, -1, SQLITE_STATIC); 544 sqlite3_bind_text(stmt, 1, currsource->require[i]->name, -1, SQLITE_STATIC);
544 sqlite3_bind_text(stmt, 2, currsource->require[i]->version, -1, SQLITE_STATIC); 545 sqlite3_bind_text(stmt, 2, currsource->require[i]->version, -1, SQLITE_STATIC);
545 if (sqlite3_step(stmt) != SQLITE_DONE) { 546 if (sqlite3_step(stmt) != SQLITE_DONE) {
546 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 547 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
547 return 3; 548 return 3;
548 } 549 }
549 sqlite3_finalize(stmt); 550 sqlite3_finalize(stmt);
550 } 551 }
551 552
552 /* sources <-> provided relations (buildrequirements) */ 553 /* sources <-> provided relations (buildrequirements) */
553 /* for (i=0; i<currsource->providecount; i++) { 554 /* for (i=0; i<currsource->providecount; i++) {
554 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_provided_rel VALUES(NULL,%d,%d);", 555 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_provided_rel VALUES(NULL,%d,%d);",
555 currsource->id, 556 currsource->id,
556 currsource->required[i]->id); 557 currsource->required[i]->id);
557 558
558 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { 559 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
559 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 560 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
560 } 561 }
561 if (sqlite3_step(stmt) != SQLITE_DONE) { 562 if (sqlite3_step(stmt) != SQLITE_DONE) {
562 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); 563 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
563 return 3; 564 return 3;
564 } 565 }
565 sqlite3_finalize(stmt); 566 sqlite3_finalize(stmt);
566 }*/ 567 }*/
567 568
568 if (currsource->changelog) { 569 if (currsource->changelog) {
569 nextchangelogid = generateSQLite_add_changelog(db, currsource->changelog, currsource->id) + 1; 570 nextchangelogid = generateSQLite_add_changelog(db, currsource->changelog, currsource->id) + 1;
570 } 571 }
571 } 572 }
572 currsource = currsource->next; 573 currsource = currsource->next;
573 } 574 }
574 SQLite_commit_transaction(db); 575 SQLite_commit_transaction(db);
575 return 0; 576 return 0;
576 } 577 }
577 578
578 int 579 int
579 generateSQLiteFiles(struct configTag *ct) 580 generateSQLiteFiles(struct configTag *ct)
580 { 581 {
581 sqlite3 *db = NULL; 582 sqlite3 *db = NULL;
582 char dbname[PATH_MAX]; 583 char dbname[PATH_MAX];
583 int i; 584 int i;
584 585
585 for (i = 0; i < ARCHS_MAX && ct->arch[i]; i++) { 586 for (i = 0; i < ARCHS_MAX && ct->arch[i]; i++) {
586 snprintf(dbname, PATH_MAX, "%s%s-%s-files.db", ct->repository_dir, ct->tag, ct->arch[i]); 587 snprintf(dbname, PATH_MAX, "%s%s-%s-files.db", ct->repository_dir, ct->tag, ct->arch[i]);
587 unlink(dbname); 588 unlink(dbname);
588 589
589 if (sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) { 590 if (sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) {
590 logmsg(LOG_ERROR, "sqlite3_open_v2: %s (%s)", dbname, sqlite3_errmsg(db)); 591 logmsg(LOG_ERROR, "sqlite3_open_v2: %s (%s)", dbname, sqlite3_errmsg(db));
591 if (db) sqlite3_close(db); 592 if (db) sqlite3_close(db);
592 return 1; 593 return 1;
593 } 594 }
594 if (generateSQLite_files(ct, db, i)) return 1; 595 if (generateSQLite_files(ct, db, i)) return 1;
595 if (db) sqlite3_close(db); 596 if (db) sqlite3_close(db);
596 } 597 }
597 return 0; 598 return 0;
598 } 599 }
599 600
600 int 601 int
601 generateSQLite(struct configTag *ct) 602 generateSQLite(struct configTag *ct)
602 { 603 {
603 sqlite3 *db = NULL; 604 sqlite3 *db = NULL;
604 char dbname[PATH_MAX]; 605 char dbname[PATH_MAX];
605 int i; 606 int i;
606 607
607 for (i = 0; i < ARCHS_MAX && ct->arch[i]; i++) { 608 for (i = 0; i < ARCHS_MAX && ct->arch[i]; i++) {
608 snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository_dir, ct->tag, ct->arch[i]); 609 snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository_dir, ct->tag, ct->arch[i]);
609 unlink(dbname); 610 unlink(dbname);
610 611
611 if (sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) { 612 if (sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) {
612 logmsg(LOG_ERROR, "sqlite3_open_v2: %s %s", sqlite3_errmsg(db), dbname); 613 logmsg(LOG_ERROR, "sqlite3_open_v2: %s %s", sqlite3_errmsg(db), dbname);
613 if (db) sqlite3_close(db); 614 if (db) sqlite3_close(db);
614 return 1; 615 return 1;
615 } 616 }
616 617
617 if (generateSQLite_packages(ct, db, i)) return 1; 618 if (generateSQLite_packages(ct, db, i)) return 1;
618 if (generateSQLite_provided(ct, db, i)) return 1; 619 if (generateSQLite_provided(ct, db, i)) return 1;
619 sqlite3_close(db); 620 sqlite3_close(db);
620 } 621 }
621 622
622 snprintf(dbname, PATH_MAX, "%s%s-sources.db", ct->repository_dir, ct->tag); 623 snprintf(dbname, PATH_MAX, "%s%s-sources.db", ct->repository_dir, ct->tag);
623 unlink(dbname); 624 unlink(dbname);
624 625
625 if (sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) { 626 if (sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) {
626 if (db) sqlite3_close(db); 627 if (db) sqlite3_close(db);
627 return 1; 628 return 1;
628 } 629 }
629 630
630 generateSQLite_sources(ct, db); 631 generateSQLite_sources(ct, db);
631 generateSQLite_packagers(db); 632 generateSQLite_packagers(db);
632 633
633 sqlite3_close(db); 634 sqlite3_close(db);
634 return 0; 635 return 0;
635 } 636 }
636 637
1 /* 1 /*
2 * distromatic - tool for RPM based repositories 2 * distromatic - tool for RPM based repositories
3 * 3 *
4 * Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it> 4 * Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
5 * Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com> 5 * Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it under 7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of version 2 of the GNU General Public License as published by the 8 * the terms of version 2 of the GNU General Public License as published by the
9 * Free Software Foundation. 9 * Free Software Foundation.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT 11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY, to the extent permitted by law; without even the implied 12 * ANY WARRANTY, to the extent permitted by law; without even the implied
13 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details. 14 * See the GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License along with 16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19 */ 19 */
20 20
21 /* Tell glibc's <time.h> to provide a prototype for strptime() */ 21 /* Tell glibc's <time.h> to provide a prototype for strptime() */
22 #ifndef __USE_XOPEN 22 #ifndef __USE_XOPEN
23 # define __USE_XOPEN 23 # define __USE_XOPEN
24 #endif 24 #endif
25 25
26 #ifndef _GNU_SOURCE 26 #ifndef _GNU_SOURCE
27 # define _GNU_SOURCE 27 # define _GNU_SOURCE
28 #endif 28 #endif
29 29
30 #include <getopt.h> 30 #include <getopt.h>
31 #include <errno.h> 31 #include <errno.h>
32 #include <stdio.h> 32 #include <stdio.h>
33 #include <fcntl.h> 33 #include <fcntl.h>
34 #include <pthread.h> 34 #include <pthread.h>
35 #include <signal.h> 35 #include <signal.h>
36 36
37 #if HAVE_UNISTD_H 37 #if HAVE_UNISTD_H
38 # include <unistd.h> 38 # include <unistd.h>
39 #endif 39 #endif
40 40
41 #include <dirent.h> 41 #include <dirent.h>
42 #include <sys/stat.h> 42 #include <sys/stat.h>
43 43
44 #if HAVE_STRING_H 44 #if HAVE_STRING_H
45 # if !STDC_HEADERS && HAVE_MEMORY_H 45 # if !STDC_HEADERS && HAVE_MEMORY_H
46 # include <memory.h> 46 # include <memory.h>
47 # endif 47 # endif
48 /* Tell glibc's <string.h> to provide a prototype for strndup() */ 48 /* Tell glibc's <string.h> to provide a prototype for strndup() */
49 # ifndef __USE_GNU 49 # ifndef __USE_GNU
50 # define __USE_GNU 50 # define __USE_GNU
51 # endif 51 # endif
52 # include <string.h> 52 # include <string.h>
53 #endif 53 #endif
54 #if HAVE_STRINGS_H 54 #if HAVE_STRINGS_H
55 # include <strings.h> 55 # include <strings.h>
56 #endif 56 #endif
57 57
58 58
59 #if TIME_WITH_SYS_TIME 59 #if TIME_WITH_SYS_TIME
60 # include <sys/time.h> 60 # include <sys/time.h>
61 # include <time.h> 61 # include <time.h>
62 #else 62 #else
63 # if HAVE_SYS_TIME_H 63 # if HAVE_SYS_TIME_H
64 # include <sys/time.h> 64 # include <sys/time.h>
65 # else 65 # else
66 # include <time.h> 66 # include <time.h>
67 # endif 67 # endif
68 #endif 68 #endif
69 69
70 #if !HAVE_STRCHR 70 #if !HAVE_STRCHR
71 # define strchr index 71 # define strchr index
72 #endif 72 #endif
73 73
74 #include "buildtools.h" 74 #include "buildtools.h"
75 #include "changelog.h" 75 #include "changelog.h"
76 #include "distromatic.h" 76 #include "distromatic.h"
77 #include "reports.h" 77 #include "reports.h"
78 #include "headerlist.h" 78 #include "headerlist.h"
79 #include "requirelist.h" 79 #include "requirelist.h"
80 #include "functions.h" 80 #include "functions.h"
81 #include "rpmfunctions.h" 81 #include "rpmfunctions.h"
82 #include "backend-sqlite3.h" 82 #include "backend-sqlite3.h"
83 83
84 #define MODE_DATA_TABLES 1 84 #define MODE_DATA_TABLES 1
85 #define MODE_FIND_DEPS 2 85 #define MODE_FIND_DEPS 2
86 #define MODE_CHANGELOG 4 86 #define MODE_CHANGELOG 4
87 #define MODE_HTML 8 87 #define MODE_HTML 8
88 #define MODE_GENSRCPKGLIST 16 88 #define MODE_GENSRCPKGLIST 16
89 #define MODE_GENBUILDINFO 32 89 #define MODE_GENBUILDINFO 32
90 #define MODE_GENPKGLIST 64 90 #define MODE_GENPKGLIST 64
91 #define MODE_SQLITE3 128 91 #define MODE_SQLITE3 128
92 #define MODE_SQLITE3_FILES 256 92 #define MODE_SQLITE3_FILES 256
93 #define MODE_GENCONTENTSLIST 512 93 #define MODE_GENCONTENTSLIST 512
94 #define MODE_HTMLSTATS 1024 94 #define MODE_HTMLSTATS 1024
95 95
96 static void program_usage(int exit_code); 96 static void program_usage(int exit_code);
97 static void program_version(void); 97 static void program_version(void);
98 98
99 static int resolveFirstLevelDependencies( 99 static int resolveFirstLevelDependencies(
100 struct configTag *ct, int arch); 100 struct configTag *ct, int arch);
101 101
102 static int 102 static int
103 resolveFirstLevelSourceDependencies(struct configTag *ct, int archidx); 103 resolveFirstLevelSourceDependencies(struct configTag *ct, int archidx);
104 104
105 static int clearRecursionFlag(struct headerList *headerlist); 105 static int clearRecursionFlag(struct headerList *headerlist);
106 106
107 static int resolveRecursiveDependencies( 107 static int resolveRecursiveDependencies(
108 struct headerList *headerlist); 108 struct headerList *headerlist);
109 109
110 int compareRequiredList(const void *ptr1, const void *ptr2); 110 int compareRequiredList(const void *ptr1, const void *ptr2);
111 111
112 int handleObsoletedPackages(struct configTag *ct, int arch); 112 int handleObsoletedPackages(struct configTag *ct, int arch);
113 113
114 static const char *copyright[] = { 114 static const char *copyright[] = {
115 PACKAGE " version " PACKAGE_VERSION, 115 PACKAGE " version " PACKAGE_VERSION,
116 "Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>", 116 "Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>",
117 "Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>", 117 "Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>",
118 (char *)0 118 (char *)0
119 }; 119 };
120 120
121 static struct configTag *firstconfigtag = NULL, *configtag = NULL; 121 static struct configTag *firstconfigtag = NULL, *configtag = NULL;
122 122
123 unsigned int quietmode = 0; 123 unsigned int quietmode = 0;
124 unsigned int genheader_mode = GENHEADER_BASE + GENHEADER_REQUIREMENTS; 124 unsigned int genheader_mode = GENHEADER_BASE + GENHEADER_REQUIREMENTS;
125 unsigned int mode = 0; 125 unsigned int mode = 0;
126 unsigned int recursive_mode = 0; 126 unsigned int recursive_mode = 0;
127 unsigned int incremental_mode = 1; 127 unsigned int incremental_mode = 1;
128 unsigned int obsolete_packages = 1; 128 unsigned int obsolete_packages = 1;
129 unsigned int resolve_dependencies = 1; 129 unsigned int resolve_dependencies = 1;
130 130
131 /* *INDENT-OFF* */ 131 /* *INDENT-OFF* */
132 static const char *freelicense[] = { 132 static const char *freelicense[] = {
133 "This is free software; see the source for copying conditions. There is NO", 133 "This is free software; see the source for copying conditions. There is NO",
134 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.", 134 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.",
135 (char *)0 135 (char *)0
136 }; 136 };
137 137
138 static const char *helpmsg[] = { 138 static const char *helpmsg[] = {
139 "Usage:", 139 "Usage:",
140 "distromatic [options] [command [arguments] ]...", 140 "distromatic [options] [command [arguments] ]...",
141 "", 141 "",
142 "Commands:", 142 "Commands:",
143 " --gendatatables write dependencies, buildinfo and apt db files", 143 " --gendatatables write dependencies, buildinfo and apt db files",
144 " --genbuildinfo generate build info files for all SRPMS packages", 144 " --genbuildinfo generate build info files for all SRPMS packages",
145 " --genhtml generate HTML code for repository (implies --genhtmlstats)", 145 " --genhtml generate HTML code for repository (implies --genhtmlstats)",
146 " --genhtmlstats generate HTML summary pages for repository", 146 " --genhtmlstats generate HTML summary pages for repository",
147 " --genpkglist generate binary packages list with version and size", 147 " --genpkglist generate binary packages list with version and size",
148 " --gensrcpkglist generate a source packages list with version", 148 " --gensrcpkglist generate a source packages list with version",
149 " --gensqlite3 dump data to SQLite3 databases", 149 " --gensqlite3 dump data to SQLite3 databases",
150 " --gensqlite3files dump files to SQLite3 databases", 150 " --gensqlite3files dump files to SQLite3 databases",
151 " --gencontentslist generate files listing all files in packages", 151 " --gencontentslist generate files listing all files in packages",
152 " --find-deps <package> find dependencies for given package name", 152 " --find-deps <package> find dependencies for given package name",
153 " --changelog <package> print changelog for given package name", 153 " --changelog <package> print changelog for given package name",
154 " --changelogsince <mmddyy> print changelog for all packages since given date", 154 " --changelogsince <mmddyy> print changelog for all packages since given date",
155 "", 155 "",
156 "Options:", 156 "Options:",
157 " -t, --tag use repository identified by tag in config file", 157 " -t, --tag use repository identified by tag in config file",
158 " -a, --arch specify a target architecture (default: " DEFAULT_ARCH ")", 158 " -a, --arch specify a target architecture (default: " DEFAULT_ARCH ")",
159 " -c, --conf <file> specify configuration file (default: " DEFAULT_CONFIGFILE ")", 159 " -c, --conf <file> specify configuration file (default: " DEFAULT_CONFIGFILE ")",
160 " -q, --quiet suppress all messages excluding warnings and errors", 160 " -q, --quiet suppress all messages excluding warnings and errors",
161 " -d, --debug display debug level messages", 161 " -d, --debug display debug level messages",
162 " -v, --version display version and exit", 162 " -v, --version display version and exit",
163 "", 163 "",
164 "Examples:", 164 "Examples:",
165 " distromatic -t devel --genhtml --deps-table", 165 " distromatic -t devel --genhtml --deps-table",
166 " distromatic -t stable/2.0 --changelogsince 010106", 166 " distromatic -t stable/2.0 --changelogsince 010106",
167 "", 167 "",
168 "Please report bugs to <"PACKAGE_BUGREPORT">.", 168 "Please report bugs to <"PACKAGE_BUGREPORT">.",
169 (char *)0 169 (char *)0
170 }; 170 };
171 /* *INDENT-ON* */ 171 /* *INDENT-ON* */
172 172
173 static void 173 static void
174 program_usage(int exit_code) { 174 program_usage(int exit_code) {
175 int linenum; 175 int linenum;
176 176
177 for (linenum = 0; copyright[linenum]; linenum++) 177 for (linenum = 0; copyright[linenum]; linenum++)
178 printf("%s\n", copyright[linenum]); 178 printf("%s\n", copyright[linenum]);
179 printf("\n"); 179 printf("\n");
180 180
181 for (linenum = 0; helpmsg[linenum]; linenum++) 181 for (linenum = 0; helpmsg[linenum]; linenum++)
182 printf("%s\n", helpmsg[linenum]); 182 printf("%s\n", helpmsg[linenum]);
183 183
184 exit(exit_code); 184 exit(exit_code);
185 } 185 }
186 186
187 static void 187 static void
188 program_version(void) { 188 program_version(void) {
189 int linenum; 189 int linenum;
190 190
191 for (linenum = 0; copyright[linenum]; linenum++) 191 for (linenum = 0; copyright[linenum]; linenum++)
192 printf("%s\n", copyright[linenum]); 192 printf("%s\n", copyright[linenum]);
193 printf("\n"); 193 printf("\n");
194 194
195 for (linenum = 0; freelicense[linenum]; linenum++) 195 for (linenum = 0; freelicense[linenum]; linenum++)
196 printf("%s\n", freelicense[linenum]); 196 printf("%s\n", freelicense[linenum]);
197 } 197 }
198 198
199 /* 199 /*
200 * checks if given single requirement is met by given provides 200 * checks if given single requirement is met by given provides
201 * 201 *
202 * returns: 0 if check is unsuccessful 202 * returns: 0 if check is unsuccessful
203 * 1 if successful 203 * 1 if successful
204 * 204 *
205 * FIXME: this just checks for names equality, not for version */ 205 * FIXME: this just checks for names equality, not for version */
206 static int 206 static int
207 checkRequireWithProvides(char *requirename, 207 checkRequireWithProvides(char *requirename,
208 struct headerList *provideheader) 208 struct headerList *provideheader)
209 { 209 {
210 int j; 210 int j;
211 211
212 /* assuming requirename is a library or a virtual package */ 212 /* assuming requirename is a library or a virtual package */
213 for (j = 0; j < provideheader->providecount; j++) { 213 for (j = 0; j < provideheader->providecount; j++) {
214 if (!strcmp 214 if (!strcmp
215 (provideheader->provided[j]->name,requirename)) return 1; 215 (provideheader->provided[j]->name,requirename)) return 1;
216 } 216 }
217 return 0; 217 return 0;
218 } 218 }
219 219
220 int 220 int
221 compareRequiredList(const void *ptr1, const void *ptr2) 221 compareRequiredList(const void *ptr1, const void *ptr2)
222 { 222 {
223 #define require1 (*(struct Require**)ptr1) 223 #define require1 (*(struct Require**)ptr1)
224 #define require2 (*(struct Require**)ptr2) 224 #define require2 (*(struct Require**)ptr2)
225 225
226 if (!require1 && !require2) return 0; 226 if (!require1 && !require2) return 0;
227 if (!require1 || !require1->name) return 1; 227 if (!require1 || !require1->name) return 1;
228 if (!require2 || !require2->name) return -1; 228 if (!require2 || !require2->name) return -1;
229 /* if (require1->resolved->numproviders != require2->resolved->numproviders) 229 /* if (require1->resolved->numproviders != require2->resolved->numproviders)
230 return require2->resolved->numproviders - require1->resolved->numproviders; 230 return require2->resolved->numproviders - require1->resolved->numproviders;
231 231
232 if (require1->resolved->numproviders == 1) 232 if (require1->resolved->numproviders == 1)
233 return strcmp(require1->resolved->provider[0]->name,require2->resolved->provider[0]->name); 233 return strcmp(require1->resolved->provider[0]->name,require2->resolved->provider[0]->name);
234 else*/ 234 else*/
235 return strcmp(require1->name,require2->name); 235 return strcmp(require1->name,require2->name);
236 } 236 }
237 237
238 /* 238 /*
239 * inspect multiple providing packages in providedList 239 * inspect multiple providing packages in providedList
240 * and remove providers that are obsoleted by others 240 * and remove providers that are obsoleted by others
241 */ 241 */
242 int 242 int
243 handleObsoletedPackages(struct configTag *ct, int archidx) 243 handleObsoletedPackages(struct configTag *ct, int archidx)
244 { 244 {
245 struct providedList *prov = ct->providedlist_idx[archidx][0]; 245 struct providedList *prov = ct->providedlist_idx[archidx][0];
246 int i,j,k; 246 int i,j,k;
247 int obs[OBSOLETE_MAX]; 247 int obs[OBSOLETE_MAX];
248 char buf[PATH_MAX]; 248 char buf[PATH_MAX];
249 struct headerList *currheader; 249 struct headerList *currheader;
250 250
251 while (prov) { 251 while (prov) {
252 252
253 if (prov->numproviders > OBSOLETE_MAX) { 253 if (prov->numproviders > OBSOLETE_MAX) {
254 return 1; 254 return 1;
255 } 255 }
256 256
257 if (prov->numproviders > 1) { 257 if (prov->numproviders > 1) {
258 for (i = 0; i < prov->numproviders; i++) obs[i]=-1; 258 for (i = 0; i < prov->numproviders; i++) obs[i]=-1;
259 for (i = 0; i < prov->numproviders; i++) 259 for (i = 0; i < prov->numproviders; i++)
260 for (j = 0; j < prov->provider[i]->obsoletecount; j++) 260 for (j = 0; j < prov->provider[i]->obsoletecount; j++)
261 for (k = 0; k < prov->numproviders; k++) 261 for (k = 0; k < prov->numproviders; k++)
262 if (!strcmp(prov->provider[i]->obsoletename[j],prov->provider[k]->name) 262 if (!strcmp(prov->provider[i]->obsoletename[j],prov->provider[k]->name)
263 && strcmp(prov->provider[i]->name,prov->provider[k]->name)) { 263 && strcmp(prov->provider[i]->name,prov->provider[k]->name)) {
264 if (prov->provider[i]->obsoleteflags[j] & (RPMSENSE_EQUAL|RPMSENSE_GREATER|RPMSENSE_LESS)) { 264 if (prov->provider[i]->obsoleteflags[j] & (RPMSENSE_EQUAL|RPMSENSE_GREATER|RPMSENSE_LESS)) {
265 snprintf(buf, PATH_MAX, "%s-%s",prov->provider[k]->version,prov->provider[k]->release); 265 snprintf(buf, PATH_MAX, "%s-%s",prov->provider[k]->version,prov->provider[k]->release);
266 if (!checkVersionWithFlags( 266 if (!checkVersionWithFlags(
267 prov->provider[i]->obsoleteversion[j], 267 prov->provider[i]->obsoleteversion[j],
268 prov->provider[i]->obsoleteflags[j], 268 prov->provider[i]->obsoleteflags[j],
269 buf)) continue; 269 buf)) continue;
270 } 270 }
271 /* print 'obsoletes' warning for binary packages belonging to target repository, 271 /* print 'obsoletes' warning for binary packages belonging to target repository,
272 and 'obsoleted by' for all obsoletions in upper level repositories */ 272 and 'obsoleted by' for all obsoletions in upper level repositories */
273 if (prov->provider[k]->altrepository != ct->repository_level) { 273 if (prov->provider[k]->altrepository != ct->repository_level) {
274 currheader = prov->provider[k]->sourceheader->firstchild[archidx]; 274 currheader = prov->provider[k]->sourceheader->firstchild[archidx];
275 while (currheader) { 275 while (currheader) {
276 if (!strcmp(currheader->name, prov->provider[k]->name)) { 276 if (!strcmp(currheader->name, prov->provider[k]->name)) {
277 prov->provider[k]->obsoleted = 1; 277 prov->provider[k]->obsoleted = 1;
278 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoleted by %s(%s,%s)", 278 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoleted by %s(%s,%s)",
279 prov->provider[k]->name, 279 prov->provider[k]->name,
280 prov->provider[k]->arch, 280 prov->provider[k]->arch,
281 ct->repository[prov->provider[k]->altrepository]->tag, 281 ct->repository[prov->provider[k]->altrepository]->tag,
282 prov->provider[i]->name, 282 prov->provider[i]->name,
283 prov->provider[i]->arch, 283 prov->provider[i]->arch,
284 ct->repository[prov->provider[i]->altrepository]->tag); 284 ct->repository[prov->provider[i]->altrepository]->tag);
285 addWarning(prov->provider[k]->sourceheader, buf); 285 addWarning(prov->provider[k]->sourceheader, buf);
286 logmsg(LOG_WARNING,"%s", buf); 286 logmsg(LOG_WARNING,"%s", buf);
287 break; 287 break;
288 } 288 }
289 currheader = currheader -> nextbrother; 289 currheader = currheader -> nextbrother;
290 } 290 }
291 } else { 291 obs[k]=i;
292 prov->provider[k]->obsoleted = 1; 292 } else if (prov->provider[i]->altrepository == ct->repository_level) {
293 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s(%s,%s)", 293 // NOTE: don't obsolete if it comes from an upper level repository
294 prov->provider[i]->name, 294 prov->provider[k]->obsoleted = 1;
295 prov->provider[i]->arch, 295 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s(%s,%s)",
296 ct->repository[prov->provider[i]->altrepository]->tag, 296 prov->provider[i]->name,
297 prov->provider[k]->name, 297 prov->provider[i]->arch,
298 prov->provider[k]->arch, 298 ct->repository[prov->provider[i]->altrepository]->tag,
299 ct->repository[prov->provider[k]->altrepository]->tag); 299 prov->provider[k]->name,
300 addWarning(prov->provider[i]->sourceheader, buf); 300 prov->provider[k]->arch,
301 logmsg(LOG_WARNING,"%s", buf); 301 ct->repository[prov->provider[k]->altrepository]->tag);
302 } 302 addWarning(prov->provider[i]->sourceheader, buf);
303 obs[k]=i; 303 logmsg(LOG_WARNING,"%s", buf);
304 } 304 obs[k]=i;
305 }
306 }
305 307
306 // now delete found obsoleted providers 308 // now delete found obsoleted providers
307 j = prov->numproviders; 309 j = prov->numproviders;
308 for (i = 0; i < prov->numproviders; i++) { 310 for (i = 0; i < prov->numproviders; i++) {
309 if (obs[i] >=0) { 311 if (obs[i] >=0) {
310 j--; 312 j--;
311 prov->provider[i]->obsoleted=1; 313 prov->provider[i]->obsoleted=1;
312 prov->provider[i]=NULL; 314 prov->provider[i]=NULL;
313 } 315 }
314 } 316 }
315 317
316 if (j < prov->numproviders) { 318 if (j < prov->numproviders) {
317 for (i = 0; i < j; i++) { 319 for (i = 0; i < j; i++) {
318 if (prov->provider[i] == NULL) { 320 if (prov->provider[i] == NULL) {
319 k=i+1; 321 k=i+1;
320 while (k < prov->numproviders && !prov->provider[k]) k++; 322 while (k < prov->numproviders && !prov->provider[k]) k++;
321 prov->provider[i]=prov->provider[k]; 323 prov->provider[i]=prov->provider[k];
322 prov->provider[k]=NULL; 324 prov->provider[k]=NULL;
323 } 325 }
324 } 326 }
325 prov->numproviders = j; 327 prov->numproviders = j;
326 } 328 }
327 } 329 }
328
329 prov=prov->next; 330 prov=prov->next;
330 } 331 }
331 332
332 /* mark obsoleted elements which are provided by other packages */ 333 /* mark obsoleted elements which are provided by other packages */
333 currheader = ct->headerlist[archidx]; 334 currheader = ct->headerlist[archidx];
334 while (currheader) { 335 while (currheader) {
335 if (currheader->obsoleted == 0) 336 if (currheader->obsoleted == 0)
336 for (j = 0; j < currheader->obsoletecount; j++) { 337 for (j = 0; j < currheader->obsoletecount; j++) {
337 prov=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx], 338 prov=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx],
338 currheader->obsoletename[j],0,archidx); 339 currheader->obsoletename[j],0,archidx);
339 if (prov) { 340 if (prov) {
340 for (i = 0; i < prov->numproviders; i++) { 341 for (i = 0; i < prov->numproviders; i++) {
341 if (strcmp(currheader->name,prov->provider[i]->name)) { 342 if (strcmp(currheader->name,prov->provider[i]->name)) {
342 // if (currheader->sourceheader != prov->provider[i]->sourceheader) { 343 // if (currheader->sourceheader != prov->provider[i]->sourceheader) {
343 if (prov->provider[i]->sourceheader == currheader->sourceheader) { 344 if (prov->provider[i]->sourceheader == currheader->sourceheader) {
344 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s provided by %s(%s,%s) which comes from its own source; ignoring", 345 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s provided by %s(%s,%s) which comes from its own source; ignoring",
345 currheader->name, 346 currheader->name,
346 currheader->arch, 347 currheader->arch,
347 ct->repository[currheader->altrepository]->tag, 348 ct->repository[currheader->altrepository]->tag,
348 prov->name, 349 prov->name,
349 prov->provider[i]->name, 350 prov->provider[i]->name,
350 prov->provider[i]->arch, 351 prov->provider[i]->arch,
351 ct->repository[prov->provider[i]->altrepository]->tag); 352 ct->repository[prov->provider[i]->altrepository]->tag);
352 } else if (!strcmp(prov->provider[i]->sourceheader->name,currheader->sourceheader->name)) { 353 } else if (!strcmp(prov->provider[i]->sourceheader->name,currheader->sourceheader->name)) {
353 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s provided by %s(%s,%s) which comes from same source name; ignoring", 354 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s provided by %s(%s,%s) which comes from same source name; ignoring",
354 currheader->name, 355 currheader->name,
355 currheader->arch, 356 currheader->arch,
356 ct->repository[currheader->altrepository]->tag, 357 ct->repository[currheader->altrepository]->tag,
357 prov->name, 358 prov->name,
358 prov->provider[i]->name, 359 prov->provider[i]->name,
359 prov->provider[i]->arch, 360 prov->provider[i]->arch,
360 ct->repository[prov->provider[i]->altrepository]->tag); 361 ct->repository[prov->provider[i]->altrepository]->tag);
361 } else { 362 } else {
362 prov->provider[i]->obsoleted = 1; 363 prov->provider[i]->obsoleted = 1;
363 if (!strcmp(prov->name,prov->provider[i]->name)) { 364 if (!strcmp(prov->name,prov->provider[i]->name)) {
364 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s(%s,%s)", 365 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s(%s,%s)",
365 currheader->name, 366 currheader->name,
366 currheader->arch, 367 currheader->arch,
367 ct->repository[currheader->altrepository]->tag, 368 ct->repository[currheader->altrepository]->tag,
368 prov->provider[i]->name, 369 prov->provider[i]->name,
369 prov->provider[i]->arch, 370 prov->provider[i]->arch,
370 ct->repository[prov->provider[i]->altrepository]->tag); 371 ct->repository[prov->provider[i]->altrepository]->tag);
371 } else { 372 } else {
372 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s provided by %s(%s,%s)", 373 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s provided by %s(%s,%s)",
373 currheader->name, 374 currheader->name,
374 currheader->arch, 375 currheader->arch,
375 ct->repository[currheader->altrepository]->tag, 376 ct->repository[currheader->altrepository]->tag,
376 prov->name, 377 prov->name,
377 prov->provider[i]->name, 378 prov->provider[i]->name,
378 prov->provider[i]->arch, 379 prov->provider[i]->arch,
379 ct->repository[prov->provider[i]->altrepository]->tag); 380 ct->repository[prov->provider[i]->altrepository]->tag);
380 } 381 }
381 } 382 }
382 addWarning(currheader->sourceheader, buf); 383 addWarning(currheader->sourceheader, buf);
383 logmsg(LOG_WARNING,"%s", buf); 384 logmsg(LOG_WARNING,"%s", buf);
384 } 385 }
385 } 386 }
386 } 387 }
387 } 388 }
388 currheader = currheader->next; 389 currheader = currheader->next;
389 } 390 }
390 391
391 return 0; 392 return 0;
392 } 393 }
393 394
394 /* 395 /*
395 * resolve first level requires for given headerList 396 * resolve first level requires for given headerList
396 * note: this function doesn't free allocated memory so it should be called 397 * note: this function doesn't free allocated memory so it should be called
397 * only once */ 398 * only once */
398 static int 399 static int
399 resolveFirstLevelDependencies(struct configTag *ct, int archidx) 400 resolveFirstLevelDependencies(struct configTag *ct, int archidx)
400 { 401 {
401 struct headerList *currheader, *scanheader, **newprovider; 402 struct headerList *currheader, *scanheader, **newprovider;
402 struct providedList *provided; 403 struct providedList *provided;
403 struct fileTree *file; 404 struct fileTree *file;
404 int i,j,k,found,foundprovider, foundupstreamprovider; 405 int i,j,k,found,foundprovider, foundupstreamprovider;
405 char warning[PATH_MAX]; 406 char warning[PATH_MAX];
406 char ** newversion; 407 char ** newversion;
407 408
408 currheader = ct->headerlist[archidx]; 409 currheader = ct->headerlist[archidx];
409 410
410 logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - binaries"); 411 logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - binaries");
411 412
412 while (currheader) { 413 while (currheader) {
413 scanheader = ct->headerlist[archidx]; 414 scanheader = ct->headerlist[archidx];
414 currheader->requirelist = NULL; 415 currheader->requirelist = NULL;
415 if ((!currheader->obsoleted) && (currheader->next) && (currheader->sourceheader->updatingparent)) { 416 if ((!currheader->obsoleted) && (currheader->next) && (currheader->sourceheader->updatingparent)) {
416 // mark obsoleted any package with same name in upper level repositories 417 // mark obsoleted any package with same name in upper level repositories
417 if (currheader->altrepository < currheader->sourceheader->updatingparent->altrepository) { 418 if (currheader->altrepository < currheader->sourceheader->updatingparent->altrepository) {
418 currheader->obsoleted = 1; 419 currheader->obsoleted = 1;
419 if (checkVersionWithFlags( 420 if (checkVersionWithFlags(
420 currheader->version, 421 currheader->version,
421 RPMSENSE_GREATER & RPMSENSE_EQUAL, 422 RPMSENSE_GREATER & RPMSENSE_EQUAL,
422 currheader->next->version)) { 423 currheader->next->version)) {
423 snprintf(warning,PATH_MAX,"%s(%s,%s): same or higher version than package with same name in %s (%s >= %s)", 424 snprintf(warning,PATH_MAX,"%s(%s,%s): same or higher version than package with same name in %s (%s >= %s)",
424 currheader->name, 425 currheader->name,
425 ct->arch[archidx], 426 ct->arch[archidx],
426 ct->repository[currheader->altrepository]->tag, 427 ct->repository[currheader->altrepository]->tag,
427 ct->repository[currheader->next->altrepository]->tag, 428 ct->repository[currheader->next->altrepository]->tag,
428 currheader->version, 429 currheader->version,
429 currheader->next->version); 430 currheader->next->version);
430 fprintf(stderr,"Warning: %s\n",warning); 431 fprintf(stderr,"Warning: %s\n",warning);
431 addWarning(currheader->sourceheader,warning); 432 addWarning(currheader->sourceheader,warning);
432 } 433 }
433 } else if (currheader->altrepository >= currheader->sourceheader->updatingparent->altrepository) { 434 } else if (currheader->altrepository >= currheader->sourceheader->updatingparent->altrepository) {
434 currheader->next->obsoleted = 1; 435 currheader->next->obsoleted = 1;
435 if (checkVersionWithFlags( 436 if (checkVersionWithFlags(
436 currheader->version, 437 currheader->version,
437 RPMSENSE_LESS & RPMSENSE_EQUAL, 438 RPMSENSE_LESS & RPMSENSE_EQUAL,
438 currheader->next->version)) { 439 currheader->next->version)) {
439 snprintf(warning,PATH_MAX,"%s(%s,%s): same or higher version than package with same name in %s (%s >= %s)", 440 snprintf(warning,PATH_MAX,"%s(%s,%s): same or higher version than package with same name in %s (%s >= %s)",
440 currheader->next->name, 441 currheader->next->name,
441 ct->arch[archidx], 442 ct->arch[archidx],
442 ct->repository[currheader->next->altrepository]->tag, 443 ct->repository[currheader->next->altrepository]->tag,
443 ct->repository[currheader->altrepository]->tag, 444 ct->repository[currheader->altrepository]->tag,
444 currheader->next->version, 445 currheader->next->version,
445 currheader->version); 446 currheader->version);
446 fprintf(stderr,"Warning: %s\n",warning); 447 fprintf(stderr,"Warning: %s\n",warning);
447 addWarning(currheader->sourceheader,warning); 448 addWarning(currheader->sourceheader,warning);
448 } 449 }
449 } 450 }
450 } 451 }
451 452
452 if (currheader->obsoleted || currheader->sourceheader->updatingparent) { 453 if (currheader->obsoleted || currheader->sourceheader->updatingparent) {
453 currheader = currheader->next; 454 currheader = currheader->next;
454 continue; 455 continue;
455 } 456 }
456 // currheader->require.resolved = malloc(sizeof(struct providedList*)*currheader->requirecount); 457 // currheader->require.resolved = malloc(sizeof(struct providedList*)*currheader->requirecount);
457 458
458 for (i = 0; i < currheader->requirecount; i++) { 459 for (i = 0; i < currheader->requirecount; i++) {
459 460
460 if (!strncmp("executable(",currheader->require[i]->name,11)) { 461 if (!strncmp("executable(",currheader->require[i]->name,11)) {
461 /* dynamic requirement for executable file */ 462 /* dynamic requirement for executable file */
462 /* fprintf(stderr,"Warning: skipping unhandled requirement %s for package %s\n", 463 /* fprintf(stderr,"Warning: skipping unhandled requirement %s for package %s\n",
463 currheader->require[i]->name,currheader->name);*/ 464 currheader->require[i]->name,currheader->name);*/
464 currheader->require[i]->resolved=NULL; 465 currheader->require[i]->resolved=NULL;
465 } else if (strncmp("rpmlib(",currheader->require[i]->name,7) != 0) { 466 } else if (strncmp("rpmlib(",currheader->require[i]->name,7) != 0) {
466 provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx], 467 provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx],
467 currheader->require[i]->name,1,archidx); 468 currheader->require[i]->name,1,archidx);
468 if (provided->numproviders == 0) { 469 if (provided->numproviders == 0) {
469 // check if require[i]->name requirement is met 470 // check if require[i]->name requirement is met
470 scanheader = ct->headerlist[archidx]; 471 scanheader = ct->headerlist[archidx];
471 472
472 if ((currheader->require[i]->name)[0] == '/') { 473 if ((currheader->require[i]->name)[0] == '/') {
473 /* requirement is a file, find who provides it */ 474 /* requirement is a file, find who provides it */
474 file=findOrCreateFileTreeEntry(&ct->filetree[archidx],currheader->require[i]->name, archidx); 475 file=findOrCreateFileTreeEntry(&ct->filetree[archidx],currheader->require[i]->name, archidx);
475 if (file->numproviders > 0) { 476 if (file->numproviders > 0) {
476 scanheader=file->provider[0]; 477 scanheader=file->provider[0];
477 provided->numproviders=file->numproviders; 478 provided->numproviders=file->numproviders;
478 provided->numbuildproviders=0; 479 provided->numbuildproviders=0;
479 provided->provider=file->provider; 480 provided->provider=file->provider;
480 provided->flags=0; 481 provided->flags=0;
481 } else { 482 } else {
482 scanheader=NULL; 483 scanheader=NULL;
483 } 484 }
484 } else { 485 } else {
485 /* requirement is not a file, cross-check with provides */ 486 /* requirement is not a file, cross-check with provides */
486 while (scanheader && 487 while (scanheader &&
487 !checkRequireWithProvides( 488 !checkRequireWithProvides(
488 currheader->require[i]->name, 489 currheader->require[i]->name,
489 scanheader)) scanheader = scanheader->next; 490 scanheader)) scanheader = scanheader->next;
490 if (scanheader) { 491 if (scanheader) {
491 provided->numproviders=1; 492 provided->numproviders=1;
492 provided->numbuildproviders=0; 493 provided->numbuildproviders=0;
493 provided->provider=malloc(sizeof(struct headerList*)); 494 provided->provider=malloc(sizeof(struct headerList*));
494 provided->provider[0]=scanheader; 495 provided->provider[0]=scanheader;
495 provided->flags=0; 496 provided->flags=0;
496 } 497 }
497 } 498 }
498 if (!scanheader && incremental_mode) { 499 if (!scanheader && incremental_mode) {
499 snprintf(warning,PATH_MAX,"%s(%s,%s): missing provider for %s", 500 snprintf(warning,PATH_MAX,"%s(%s,%s): missing provider for %s",
500 currheader->name, 501 currheader->name,
501 ct->arch[archidx], 502 ct->arch[archidx],
502 ct->repository[currheader->altrepository]->tag, 503 ct->repository[currheader->altrepository]->tag,
503 currheader->require[i]->name); 504 currheader->require[i]->name);
504 fprintf(stderr,"Warning: %s\n",warning); 505 fprintf(stderr,"Warning: %s\n",warning);
505 addWarning(currheader->sourceheader,warning); 506 addWarning(currheader->sourceheader,warning);
506 } 507 }
507 } else { /* provided->numproviders > 0 */ 508 } else { /* provided->numproviders > 0 */
508 /* warn about provides only provided by older packages */ 509 /* warn about provides only provided by older packages */
509 k=0; 510 k=0;
510 for (j = 0; j < provided->numproviders; j++) { 511 for (j = 0; j < provided->numproviders; j++) {
511 if (provided->provider[j]->sourceheader->updatingparent && 512 if (provided->provider[j]->sourceheader->updatingparent &&
512 provided->provider[j]->sourceheader->updatingparent->firstchild[archidx] && /* skip if not built for arch */ 513 provided->provider[j]->sourceheader->updatingparent->firstchild[archidx] && /* skip if not built for arch */
513 !currheader->obsoleted) k++; 514 !currheader->obsoleted) k++;
514 } 515 }
515 if (k == provided->numproviders) { // all provides are from older packages 516 if (k == provided->numproviders) { // all provides are from older packages
516 snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s which is only provided by older package(s):", 517 snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s which is only provided by older package(s):",
517 currheader->name, 518 currheader->name,
518 currheader->arch, 519 currheader->arch,
519 ct->repository[currheader->altrepository]->tag, 520 ct->repository[currheader->altrepository]->tag,
520 provided->name); 521 provided->name);
521 for (j = 0; j < provided->numproviders; j++) { 522 for (j = 0; j < provided->numproviders; j++) {
522 snprintf(&warning[strlen(warning)], PATH_MAX - strlen(warning), " %s(%s,%s)", 523 snprintf(&warning[strlen(warning)], PATH_MAX - strlen(warning), " %s(%s,%s)",
523 provided->provider[j]->name, 524 provided->provider[j]->name,
524 provided->provider[j]->arch, 525 provided->provider[j]->arch,
525 ct->repository[provided->provider[j]->altrepository]->tag); 526 ct->repository[provided->provider[j]->altrepository]->tag);
526 addRebuild(provided->provider[j]->sourceheader,currheader->sourceheader,provided->provider[j]); 527 addRebuild(provided->provider[j]->sourceheader,currheader->sourceheader,provided->provider[j]);
527 addWarning(provided->provider[j]->sourceheader,warning); 528 addWarning(provided->provider[j]->sourceheader,warning);
528 } 529 }
529 fprintf(stderr,"Warning: %s\n",warning); 530 fprintf(stderr,"Warning: %s\n",warning);
530 } else { 531 } else {
531 /* warn about provides provided by obsoleted packages */ 532 /* warn about provides provided by obsoleted packages */
532 k=0; 533 k=0;
533 for (j = 0; j < provided->numproviders; j++) { 534 for (j = 0; j < provided->numproviders; j++) {
534 if (provided->provider[j]->obsoleted && 535 if (provided->provider[j]->obsoleted &&
535 !provided->provider[j]->sourceheader->updatingparent && // don't fall in case above 536 !provided->provider[j]->sourceheader->updatingparent && // don't fall in case above
536 !currheader->obsoleted) k++; 537 !currheader->obsoleted) k++;
537 } 538 }
538 if (k == provided->numproviders) { // all provides are obsoleted 539 if (k == provided->numproviders) { // all provides are obsoleted
539 snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s which is only provided by obsoleted package(s):", 540 snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s which is only provided by obsoleted package(s):",
540 currheader->name, 541 currheader->name,
541 currheader->arch, 542 currheader->arch,
542 ct->repository[currheader->altrepository]->tag, 543 ct->repository[currheader->altrepository]->tag,
543 provided->name); 544 provided->name);
544 for (j = 0; j < provided->numproviders; j++) { 545 for (j = 0; j < provided->numproviders; j++) {
545 snprintf(&warning[strlen(warning)], PATH_MAX - strlen(warning), " %s(%s,%s)", 546 snprintf(&warning[strlen(warning)], PATH_MAX - strlen(warning), " %s(%s,%s)",
546 provided->provider[j]->name, 547 provided->provider[j]->name,
547 provided->provider[j]->arch, 548 provided->provider[j]->arch,
548 ct->repository[provided->provider[j]->altrepository]->tag); 549 ct->repository[provided->provider[j]->altrepository]->tag);
549 } 550 }
550 fprintf(stderr,"Warning: %s\n",warning); 551 fprintf(stderr,"Warning: %s\n",warning);
551 addWarning(currheader->sourceheader,warning); 552 addWarning(currheader->sourceheader,warning);
552 for (j = 0; j < provided->numproviders; j++) { 553 for (j = 0; j < provided->numproviders; j++) {
553 addWarning(provided->provider[j]->sourceheader,warning); 554 addWarning(provided->provider[j]->sourceheader,warning);
554 } 555 }
555 } 556 }
556 } 557 }
557 if ((currheader->require[i]->name)[0] == '/') { 558 if ((currheader->require[i]->name)[0] == '/') {
558 /* when there is a Requires: /file/requirement add provide from file tree as well */ 559 /* when there is a Requires: /file/requirement add provide from file tree as well */
559 file=findOrCreateFileTreeEntry(&ct->filetree[archidx],currheader->require[i]->name, archidx); 560 file=findOrCreateFileTreeEntry(&ct->filetree[archidx],currheader->require[i]->name, archidx);
560 for (k = 0; k < file->numproviders; k++) { 561 for (k = 0; k < file->numproviders; k++) {
561 for (j = 0, found = 0; j < provided->numproviders; j++) { 562 for (j = 0, found = 0; j < provided->numproviders; j++) {
562 /* avoid duplicates */ 563 /* avoid duplicates */
563 if (file->provider[k] == provided->provider[j]) { 564 if (file->provider[k] == provided->provider[j]) {
564 found = 1; 565 found = 1;
565 break; 566 break;
566 } 567 }
567 } 568 }
568 if (! found) { 569 if (! found) {
569 //printf("%s also provided by %s\n", currheader->require[i]->name, file->provider[k]->name); 570 //printf("%s also provided by %s\n", currheader->require[i]->name, file->provider[k]->name);
570 provided->numproviders++; 571 provided->numproviders++;
571 newprovider=malloc(sizeof(struct headerList*)*provided->numproviders); 572 newprovider=malloc(sizeof(struct headerList*)*provided->numproviders);
572 for (j = 0; j < provided->numproviders-1; j++) { 573 for (j = 0; j < provided->numproviders-1; j++) {
573 newprovider[j]=provided->provider[j]; 574 newprovider[j]=provided->provider[j];
574 } 575 }
575 newprovider[provided->numproviders-1] = file->provider[k]; 576 newprovider[provided->numproviders-1] = file->provider[k];
576 if (provided->provider) free(provided->provider); 577 if (provided->provider) free(provided->provider);
577 provided->provider=newprovider; 578 provided->provider=newprovider;
578 newversion=malloc(sizeof(char *)*provided->numproviders); 579 newversion=malloc(sizeof(char *)*provided->numproviders);
579 for (j = 0; j < provided->numproviders-1; j++) { 580 for (j = 0; j < provided->numproviders-1; j++) {
580 newversion[j]=provided->version[j]; 581 newversion[j]=provided->version[j];
581 } 582 }
582 newversion[provided->numproviders-1] = strdup(provided->provider[j]->version); 583 newversion[provided->numproviders-1] = strdup(provided->provider[j]->version);
583 if (provided->version) free(provided->version); 584 if (provided->version) free(provided->version);
584 provided->version=newversion; 585 provided->version=newversion;
585 } 586 }
586 } 587 }
587 } 588 }
588 } 589 }
589 590
590 if (provided->numproviders > 0) { 591 if (provided->numproviders > 0) {
591 if (strcmp(currheader->require[i]->version,"") && 592 if (strcmp(currheader->require[i]->version,"") &&
592 (currheader->require[i]->flags & (RPMSENSE_LESS|RPMSENSE_GREATER|RPMSENSE_EQUAL))) { 593 (currheader->require[i]->flags & (RPMSENSE_LESS|RPMSENSE_GREATER|RPMSENSE_EQUAL))) {
593 594
594 found = 0; 595 found = 0;
595 foundprovider = -1; 596 foundprovider = -1;
596 foundupstreamprovider = 0; 597 foundupstreamprovider = 0;
597 for (j = 0; j < provided->numproviders; j++) { 598 for (j = 0; j < provided->numproviders; j++) {
598 /* updated packages: ignore check with upstream package */ 599 /* updated packages: ignore check with upstream package */
599 if ((foundprovider >= 0) && 600 if ((foundprovider >= 0) &&
600 !strcmp(provided->provider[foundprovider]->name,provided->provider[j]->name) && 601 !strcmp(provided->provider[foundprovider]->name,provided->provider[j]->name) &&
601 provided->provider[foundprovider]->altrepository < provided->provider[j]->altrepository) { 602 provided->provider[foundprovider]->altrepository < provided->provider[j]->altrepository)
602 found -= 1; 603 {
603 foundupstreamprovider = foundprovider; 604 found -= 1;
604 foundprovider = -1; 605 foundupstreamprovider = foundprovider;
605 } 606 foundprovider = -1;
606 if (!strcmp(provided->version[j],"")) { 607 }
607 /* provider with no version; assume ok */ 608 if (!strcmp(provided->version[j],"")) {
608 found += 1; 609 /* provider with no version; assume ok */
609 foundupstreamprovider = foundprovider; 610 found += 1;
610 foundprovider = j; 611 foundupstreamprovider = foundprovider;
611 } else { 612 foundprovider = j;
612 if (checkVersionWithFlags( 613 } else {
613 currheader->require[i]->version, 614 if (checkVersionWithFlags(
614 currheader->require[i]->flags, 615 currheader->require[i]->version,
615 provided->version[j])) { 616 currheader->require[i]->flags,
616 found += 1; 617 provided->version[j])) {
617 foundupstreamprovider = foundprovider; 618 found += 1;
618 foundprovider = j; 619 foundupstreamprovider = foundprovider;
619 } 620 foundprovider = j;
620 } 621 }
621 /*if (!strcmp(provided->name,"pkgconfig(gio-2.0)")) 622 }
622 printf("provided->name=pkgconfig(gio-2.0) found=%d foundprovider=%d foundupstreamprovider=%d provided->version[j]=%s\n", 623 } /* for */
623 found, foundprovider, foundupstreamprovider, provided->version[j]);*/ 624 if ((found >= 1) && (!foundupstreamprovider) &&
624 } /* for */ 625 (currheader->altrepository != 0) &&
625 if ((found >= 1) && (!foundupstreamprovider) && 626 (currheader->altrepository = ct->repository_level) &&
626 (currheader->altrepository != 0) && 627 (provided->provider[foundprovider]->sourceheader != currheader->sourceheader) &&
627 (currheader->altrepository = ct->repository_level) && 628 (provided->provider[foundprovider]->altrepository == currheader->altrepository)) {
628 (provided->provider[foundprovider]->sourceheader != currheader->sourceheader) && 629 snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s(%s,%s) because it needs %s=%s",
629 (provided->provider[foundprovider]->altrepository == currheader->altrepository)) { 630 currheader->name, currheader->arch,
630 snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s(%s,%s) because it needs %s=%s", 631 ct->repository[currheader->altrepository]->tag,
631 currheader->name, 632 provided->provider[foundprovider]->name,
632 currheader->arch, 633 provided->provider[foundprovider]->arch,
633 ct->repository[currheader->altrepository]->tag, 634 ct->repository[provided->provider[foundprovider]->altrepository]->tag,
634 provided->provider[foundprovider]->name, 635 provided->name,
635 provided->provider[foundprovider]->arch, 636 provided->version[foundprovider]);
636 ct->repository[provided->provider[foundprovider]->altrepository]->tag, 637 logmsg(LOG_WARNING,"%s", warning);
637 provided->name, 638 addWarning(currheader->sourceheader, warning);
638 provided->version[foundprovider]); 639 } else if (!found) {
639 logmsg(LOG_WARNING,"%s", warning); 640 for (j = 0; j < provided->numproviders; j++) {
640 addWarning(currheader->sourceheader, warning); 641 if (!checkVersionWithFlags(
641 } else if (!found) { 642 currheader->require[i]->version,
642 for (j = 0; j < provided->numproviders; j++) { 643 currheader->require[i]->flags,
643 if (!checkVersionWithFlags( 644 provided->version[j])) {
644 currheader->require[i]->version, 645 snprintf(warning, PATH_MAX, "%s=%s from %s(%s,%s) fails to provide %s",
645 currheader->require[i]->flags, 646 provided->name,
646 provided->version[j])) { 647 provided->version[j],
647 snprintf(warning, PATH_MAX, "%s=%s from %s(%s,%s) fails to provide %s", 648 provided->provider[j]->name,
648 provided->name, 649 provided->provider[j]->arch,
649 provided->version[j], 650 ct->repository[provided->provider[j]->altrepository]->tag,
650 provided->provider[j]->name, 651 provided->name);
651 provided->provider[j]->arch, 652 if (currheader->require[i]->flags & RPMSENSE_LESS) snprintf(&warning[strlen(warning)], PATH_MAX,"<");
652 ct->repository[provided->provider[j]->altrepository]->tag, 653 if (currheader->require[i]->flags & RPMSENSE_GREATER) snprintf(&warning[strlen(warning)], PATH_MAX, ">");
653 provided->name); 654 if (currheader->require[i]->flags & RPMSENSE_EQUAL) snprintf(&warning[strlen(warning)], PATH_MAX, "=");
654 if (currheader->require[i]->flags & RPMSENSE_LESS) snprintf(&warning[strlen(warning)], PATH_MAX,"<"); 655 snprintf(&warning[strlen(warning)], PATH_MAX, "%s to %s(%s,%s)",
655 if (currheader->require[i]->flags & RPMSENSE_GREATER) snprintf(&warning[strlen(warning)], PATH_MAX, ">");
656 if (currheader->require[i]->flags & RPMSENSE_EQUAL) snprintf(&warning[strlen(warning)], PATH_MAX, "=");
657 snprintf(&warning[strlen(warning)], PATH_MAX, "%s to %s(%s,%s)",
658 currheader->require[i]->version, 656 currheader->require[i]->version,
659 currheader->name, 657 currheader->name,
660 currheader->arch, 658 currheader->arch,
661 ct->repository[currheader->altrepository]->tag); 659 ct->repository[currheader->altrepository]->tag);
662 logmsg(LOG_WARNING,"%s", warning); 660 logmsg(LOG_WARNING,"%s", warning);
663 for (k = 0; k < provided->numproviders; k++) { 661 for (k = 0; k < provided->numproviders; k++) {
664 if (provided->provider[k]->sourceheader && 662 if (provided->provider[k]->sourceheader &&
665 (provided->provider[k]->altrepository == ct->repository_level)) { 663 (provided->provider[k]->altrepository == ct->repository_level)) {
666 addWarning(provided->provider[k]->sourceheader, warning); 664 addWarning(provided->provider[k]->sourceheader, warning);
667 } 665 }
668 if ((currheader->altrepository == ct->repository_level)) { 666 if ((currheader->altrepository == ct->repository_level)) {
669 addWarning(currheader->sourceheader, warning); 667 addWarning(currheader->sourceheader, warning);
670 } 668 }
671 } 669 }
672 } 670 }
673 } 671 } /* for */
674 } 672 }
675 673 }
676 }
677 }
678 currheader->require[i]->resolved=provided;
679 } else {
680 currheader->require[i]->resolved=NULL;
681 }
682 } 674 }
683 // sort required list by first provider's name 675 currheader->require[i]->resolved=provided;
684 qsort((void *) &currheader->require[0], 676 } else {
685 currheader->requirecount, 677 currheader->require[i]->resolved=NULL;
686 sizeof(struct Require *), 678 }
687 compareRequiredList); 679 }
688 currheader = currheader->next; 680 // sort required list by first provider's name
689 } 681 qsort((void *) &currheader->require[0],
690 logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - done"); 682 currheader->requirecount,
691 return 0; 683 sizeof(struct Require *),
684 compareRequiredList);
685 currheader = currheader->next;
686 }
687 logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - done");
688 return 0;
692 } 689 }
693 690
694 static int 691 static int
695 resolveFirstLevelSourceDependencies(struct configTag *ct, int archidx) 692 resolveFirstLevelSourceDependencies(struct configTag *ct, int archidx)
696 { 693 {
697 struct headerSourceList *currsourceheader = ct->headersourcelist; 694 struct headerSourceList *currsourceheader = ct->headersourcelist;
698 struct headerList *scanheader; 695 struct headerList *scanheader;
699 struct providedList *provided; 696 struct providedList *provided;
700 struct fileTree *file; 697 struct fileTree *file;
701 char warning[PATH_MAX]; 698 char warning[PATH_MAX];
702 int i; 699 int i;
703 int j,found; 700 int j,found;
704 701
705 logmsg(LOG_DEBUG,"resolveFirstLevelSourceDependencies - sources"); 702 logmsg(LOG_DEBUG,"resolveFirstLevelSourceDependencies - sources");
706 while (currsourceheader) { 703 while (currsourceheader) {
707 if (!currsourceheader->firstchild[archidx]) { // ignore SRPMs with no builds 704 if (!currsourceheader->firstchild[archidx]) { // ignore SRPMs with no builds
708 currsourceheader = currsourceheader->next; 705 currsourceheader = currsourceheader->next;
709 continue; 706 continue;
710 } 707 }
711 scanheader = ct->headerlist[archidx]; 708 scanheader = ct->headerlist[archidx];
712 currsourceheader->requirelist = NULL; 709 currsourceheader->requirelist = NULL;
713 // currsourceheader->require.resolved = malloc(sizeof(struct providedList*)*currsourceheader->requirecount); 710 // currsourceheader->require.resolved = malloc(sizeof(struct providedList*)*currsourceheader->requirecount);
714 for (i = 0; i < currsourceheader->requirecount; i++) { 711 for (i = 0; i < currsourceheader->requirecount; i++) {
715 /* if (strncmp("a2ps",currsourceheader->name,4) == 0) { 712 /* if (strncmp("a2ps",currsourceheader->name,4) == 0) {
716 fprintf(stderr,"a2ps:%s\n",currheader->require[i]->name); 713 fprintf(stderr,"a2ps:%s\n",currheader->require[i]->name);
717 }*/ 714 }*/
718 if (strncmp("rpmlib(",currsourceheader->require[i]->name,7) != 0) { 715 if (strncmp("rpmlib(",currsourceheader->require[i]->name,7) != 0) {
719 provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx], 716 provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx],
720 currsourceheader->require[i]->name,1,archidx); 717 currsourceheader->require[i]->name,1,archidx);
721 if (provided->numbuildproviders == 0) { 718 if (provided->numbuildproviders == 0) {
722 // check if require[i]->name requirement is met 719 // check if require[i]->name requirement is met
723 720
724 if ((currsourceheader->require[i]->name)[0] == '/') { 721 if ((currsourceheader->require[i]->name)[0] == '/') {
725 /* requirement is a file, find who provides it */ 722 /* requirement is a file, find who provides it */
726 file=findOrCreateFileTreeEntry(&ct->filetree[archidx],currsourceheader->require[i]->name, archidx); 723 file=findOrCreateFileTreeEntry(&ct->filetree[archidx],currsourceheader->require[i]->name, archidx);
727 if (file->numproviders > 0) { 724 if (file->numproviders > 0) {
728 provided->numbuildproviders=file->numproviders; 725 provided->numbuildproviders=file->numproviders;
729 provided->buildprovider=file->provider; 726 provided->buildprovider=file->provider;
730 provided->flags=0; 727 provided->flags=0;
731 logmsg(LOG_DEBUG,"file %s is a build provider for %s",currsourceheader->require[i]->name,currsourceheader->name); 728 logmsg(LOG_DEBUG,"file %s is a build provider for %s",currsourceheader->require[i]->name,currsourceheader->name);
732 } 729 }
733 } else { 730 } else {
734 /* requirement is not a file, cross-check with provides */ 731 /* requirement is not a file, cross-check with provides */
735 scanheader = ct->headerlist[archidx]; 732 scanheader = ct->headerlist[archidx];
736 while (scanheader) { 733 while (scanheader) {
737 if (checkRequireWithProvides( 734 if (checkRequireWithProvides(
738 currsourceheader->require[i]->name, 735 currsourceheader->require[i]->name,
739 scanheader)) provided->numbuildproviders+=1; 736 scanheader)) provided->numbuildproviders+=1;
740 scanheader = scanheader->next; 737 scanheader = scanheader->next;
741 } 738 }
742 if (provided->numbuildproviders > 0) { 739 if (provided->numbuildproviders > 0) {
743 provided->buildprovider = malloc(sizeof(struct headerList*) * provided->numbuildproviders); 740 provided->buildprovider = malloc(sizeof(struct headerList*) * provided->numbuildproviders);
744 provided->flags = 0; 741 provided->flags = 0;
745 scanheader = ct->headerlist[archidx]; 742 scanheader = ct->headerlist[archidx];
746 j = 0; 743 j = 0;
747 while (scanheader) { 744 while (scanheader) {
748 if (checkRequireWithProvides( 745 if (checkRequireWithProvides(
749 currsourceheader->require[i]->name, 746 currsourceheader->require[i]->name,
750 scanheader)) provided->buildprovider[j++] = scanheader; 747 scanheader)) provided->buildprovider[j++] = scanheader;
751 scanheader = scanheader->next; 748 scanheader = scanheader->next;
752 } 749 }
753 logmsg(LOG_DEBUG,"%s is a build provider for %s",provided->name,currsourceheader->name); 750 logmsg(LOG_DEBUG,"%s is a build provider for %s",provided->name,currsourceheader->name);
754 } 751 }
755 } 752 }
756 if (provided->numbuildproviders == 0 && incremental_mode) { 753 if (provided->numbuildproviders == 0 && incremental_mode) {
757 snprintf(warning,PATH_MAX,"missing build provider for %s",currsourceheader->require[i]->name); 754 snprintf(warning,PATH_MAX,"missing build provider for %s",currsourceheader->require[i]->name);
758 fprintf(stderr,"Warning: %s(source,%s): %s\n", 755 fprintf(stderr,"Warning: %s(source,%s): %s\n",
759 currsourceheader->name, 756 currsourceheader->name,
760 ct->repository[currsourceheader->altrepository]->tag, 757 ct->repository[currsourceheader->altrepository]->tag,
761 warning); 758 warning);
762 addWarning(currsourceheader,warning); 759 addWarning(currsourceheader,warning);
763 } 760 }
764 //} else if (provided->numbuildproviders > 1) { 761 //} else if (provided->numbuildproviders > 1) {
765 /*printf("Multiple providers for %s in package %s\n",currsourceheader->require[i]->name,currsourceheader->name);*/ 762 /*printf("Multiple providers for %s in package %s\n",currsourceheader->require[i]->name,currsourceheader->name);*/
766 } 763 }
767 764
768 if (provided->numbuildproviders > 0) { 765 if (provided->numbuildproviders > 0) {
769 if (strcmp(currsourceheader->require[i]->version,"") && 766 if (strcmp(currsourceheader->require[i]->version,"") &&
770 (currsourceheader->require[i]->flags & (RPMSENSE_LESS+RPMSENSE_GREATER+RPMSENSE_EQUAL))) { 767 (currsourceheader->require[i]->flags & (RPMSENSE_LESS+RPMSENSE_GREATER+RPMSENSE_EQUAL))) {
771 found = 0; 768 found = 0;
772 for (j = 0; j < provided->numproviders; j++) { 769 for (j = 0; j < provided->numproviders; j++) {
773 if (!strcmp(provided->version[j],"")) { 770 if (!strcmp(provided->version[j],"")) {
774 /* provider with no version; assume ok */ 771 /* provider with no version; assume ok */
775 found = 1; 772 found = 1;
776 } else { 773 } else {
777 if (checkVersionWithFlags( 774 if (checkVersionWithFlags(
778 currsourceheader->require[i]->version, 775 currsourceheader->require[i]->version,
779 currsourceheader->require[i]->flags, 776 currsourceheader->require[i]->flags,
780 provided->version[j])) found = 1; 777 provided->version[j])) found = 1;
781 } 778 }
782 } /* for */ 779 } /* for */
783 if (!found) { 780 if (!found) {
784 if (currsourceheader->altrepository == ct->repository_level) { 781 if (currsourceheader->altrepository == ct->repository_level) {
785 fprintf(stderr,"Warning: %s(source): build requires %s ",currsourceheader->name,currsourceheader->require[i]->name); 782 fprintf(stderr,"Warning: %s(source): build requires %s ",currsourceheader->name,currsourceheader->require[i]->name);
786 if (currsourceheader->require[i]->flags & RPMSENSE_LESS) fprintf(stderr,"<"); 783 if (currsourceheader->require[i]->flags & RPMSENSE_LESS) fprintf(stderr,"<");
787 if (currsourceheader->require[i]->flags & RPMSENSE_GREATER) fprintf(stderr,">"); 784 if (currsourceheader->require[i]->flags & RPMSENSE_GREATER) fprintf(stderr,">");
788 if (currsourceheader->require[i]->flags & RPMSENSE_EQUAL) fprintf(stderr,"="); 785 if (currsourceheader->require[i]->flags & RPMSENSE_EQUAL) fprintf(stderr,"=");
789 fprintf(stderr," %s (failing build provider(s):", currsourceheader->require[i]->version); 786 fprintf(stderr," %s (failing build provider(s):", currsourceheader->require[i]->version);
790 for (j = 0; j < provided->numbuildproviders; j++) { 787 for (j = 0; j < provided->numbuildproviders; j++) {
791 fprintf(stderr," %s#%s", 788 fprintf(stderr," %s#%s",
792 provided->provider[j]->name, provided->buildprovider[j]->version); 789 provided->provider[j]->name, provided->buildprovider[j]->version);
793 /* printrpmversion(buffer,PATH_MAX, 790 /* printrpmversion(buffer,PATH_MAX,
794 provided->provider[j]->epoch, 791 provided->provider[j]->epoch,
795 provided->provider[j]->version, 792 provided->provider[j]->version,
796 provided->provider[j]->release));*/ 793 provided->provider[j]->release));*/
797 } 794 }
798 fprintf(stderr,")\n"); 795 fprintf(stderr,")\n");
799 } 796 }
800 } 797 }
801 798
802 } 799 }
803 } 800 }
804 currsourceheader->require[i]->resolved=provided; 801 currsourceheader->require[i]->resolved=provided;
805 } else { 802 } else {
806 currsourceheader->require[i]->resolved=NULL; 803 currsourceheader->require[i]->resolved=NULL;
807 } 804 }
808 } 805 }
809 806
810 // sort required list by first provider's name 807 // sort required list by first provider's name
811 qsort((void *) &currsourceheader->require[0], 808 qsort((void *) &currsourceheader->require[0],
812 currsourceheader->requirecount, 809 currsourceheader->requirecount,
813 sizeof(struct Require *), 810 sizeof(struct Require *),
814 compareRequiredList); 811 compareRequiredList);
815 currsourceheader = currsourceheader->next; 812 currsourceheader = currsourceheader->next;
816 } 813 }
817 logmsg(LOG_DEBUG,"resolveFirstLevelSourceDependencies - done"); 814 logmsg(LOG_DEBUG,"resolveFirstLevelSourceDependencies - done");
818 return 0; 815 return 0;
819 } 816 }
820 817
821 static int 818 static int
822 clearRecursionFlag(struct headerList *headerlist) 819 clearRecursionFlag(struct headerList *headerlist)
823 { 820 {
824 while (headerlist) { 821 while (headerlist) {
825 if (headerlist->recursed == 1) { 822 if (headerlist->recursed == 1) {
826 headerlist->recursed = 0; 823 headerlist->recursed = 0;
827 } 824 }
828 headerlist = headerlist->next; 825 headerlist = headerlist->next;
829 } 826 }
830 827
831 return 0; 828 return 0;
832 } 829 }
833 830
834 /* 831 /*
835 * resolve recursive requirement dependencies 832 * resolve recursive requirement dependencies
836 * (first level dependencies should have been resolved already) */ 833 * (first level dependencies should have been resolved already) */
837 static int 834 static int
838 resolveRecursiveDependencies(struct headerList *headerlist) 835 resolveRecursiveDependencies(struct headerList *headerlist)
839 { 836 {
840 while (headerlist) { 837 while (headerlist) {
841 clearRecursionFlag(headerlist); 838 clearRecursionFlag(headerlist);
842 headerlist->requirelist = recurseRequireList(headerlist); 839 headerlist->requirelist = recurseRequireList(headerlist);
843 headerlist->recursed = 2; 840 headerlist->recursed = 2;
844 headerlist = headerlist->next; 841 headerlist = headerlist->next;
845 } 842 }
846 843
847 return 0; 844 return 0;
848 } 845 }
849 846
850 void *threadArchScan(void* arg) { 847 void *threadArchScan(void* arg) {
851 int arch = *(int *)arg; 848 int arch = *(int *)arg;
852 849
853 if (generateHeaderList(configtag,arch,incremental_mode)) { 850 if (generateHeaderList(configtag,arch,incremental_mode)) {
854 fprintf(stderr, 851 fprintf(stderr,
855 "Fatal error: could not generate header list\n"); 852 "Fatal error: could not generate header list\n");
856 exit(1); 853 exit(1);
857 } 854 }
858 855
859 if (genheader_mode & GENHEADER_REQUIREMENTS) { 856 if (genheader_mode & GENHEADER_REQUIREMENTS) {
860 857
861 if (obsolete_packages) { 858 if (obsolete_packages) {
862 if (!quietmode) fprintf(stdout, "%s: handling obsoleted packages...\n",configtag->arch[arch]); 859 if (!quietmode) fprintf(stdout, "%s: handling obsoleted packages...\n",configtag->arch[arch]);
863 if (handleObsoletedPackages(configtag,arch)) { 860 if (handleObsoletedPackages(configtag,arch)) {
864 fprintf(stderr, 861 fprintf(stderr,
865 "Fatal error: maximum number of multiple providing packages reached. Aborting."); 862 "Fatal error: maximum number of multiple providing packages reached. Aborting.");
866 exit(1); 863 exit(1);
867 } 864 }
868 } 865 }
869 866
870 if (resolve_dependencies) { 867 if (resolve_dependencies) {
871 if (!quietmode) fprintf(stdout, "%s: resolving dependencies...\n",configtag->arch[arch]); 868 if (!quietmode) fprintf(stdout, "%s: resolving dependencies...\n",configtag->arch[arch]);
872 if (resolveFirstLevelDependencies(configtag, arch)) { 869 if (resolveFirstLevelDependencies(configtag, arch)) {
873 fprintf(stderr, 870 fprintf(stderr,
874 "Fatal error: could not generate first level requires table\n"); 871 "Fatal error: could not generate first level requires table\n");
875 exit(1); 872 exit(1);
876 } 873 }
877 874
878 if (arch == 0) /* fixme? */ { 875 if (arch == 0) /* fixme? */ {
879 if (!quietmode) fprintf(stdout, "%s: resolving source dependencies\n",configtag->arch[arch]); 876 if (!quietmode) fprintf(stdout, "%s: resolving source dependencies\n",configtag->arch[arch]);
880 if (resolveFirstLevelSourceDependencies(configtag, arch)) { 877 if (resolveFirstLevelSourceDependencies(configtag, arch)) {
881 fprintf(stderr, 878 fprintf(stderr,
882 "Fatal error: could not generate first level requires table\n"); 879 "Fatal error: could not generate first level requires table\n");
883 exit(1); 880 exit(1);
884 } 881 }
885 } 882 }
886 883
887 if (recursive_mode) { 884 if (recursive_mode) {
888 if (!quietmode) fprintf(stdout, "%s: resolving recursive dependencies...\n",configtag->arch[arch]); 885 if (!quietmode) fprintf(stdout, "%s: resolving recursive dependencies...\n",configtag->arch[arch]);
889 886
890 if (resolveRecursiveDependencies 887 if (resolveRecursiveDependencies
891 (configtag->headerlist[arch])) { 888 (configtag->headerlist[arch])) {
892 fprintf(stderr,"Fatal error: could not resolve recursive dependencies\n"); 889 fprintf(stderr,"Fatal error: could not resolve recursive dependencies\n");
893 exit(1); 890 exit(1);
894 } 891 }
895 } 892 }
896 } 893 }
897 } 894 }
898 895
899 if (mode & MODE_DATA_TABLES) { 896 if (mode & MODE_DATA_TABLES) {
900 if (!quietmode) fprintf(stdout,"%s: writing dependencies tables...\n",configtag->arch[arch]); 897 if (!quietmode) fprintf(stdout,"%s: writing dependencies tables...\n",configtag->arch[arch]);
901 print_datatables(configtag,arch); 898 print_datatables(configtag,arch);
902 } 899 }
903 900
904 901
905 if (mode & MODE_GENCONTENTSLIST) { 902 if (mode & MODE_GENCONTENTSLIST) {
906 if (!quietmode) fprintf(stdout,"%s: writing contentslist files...\n",configtag->arch[arch]); 903 if (!quietmode) fprintf(stdout,"%s: writing contentslist files...\n",configtag->arch[arch]);
907 print_contentslist(configtag,arch); 904 print_contentslist(configtag,arch);
908 } 905 }
909 906
910 if (genheader_mode & GENHEADER_STATS) { 907 if (genheader_mode & GENHEADER_STATS) {
911 if (!quietmode) fprintf(stdout,"%s: generating statistics...\n",configtag->arch[arch]); 908 if (!quietmode) fprintf(stdout,"%s: generating statistics...\n",configtag->arch[arch]);
912 909
913 logmsg(LOG_DEBUG,"%s: generateHeaderStats - start",configtag->arch[arch]); 910 logmsg(LOG_DEBUG,"%s: generateHeaderStats - start",configtag->arch[arch]);
914 if (generateHeaderStats(configtag, arch)) { 911 if (generateHeaderStats(configtag, arch)) {
915 fprintf(stderr,"Fatal error: could not generate statistic for headers\n"); 912 fprintf(stderr,"Fatal error: could not generate statistic for headers\n");
916 exit(1); 913 exit(1);
917 } 914 }
918 logmsg(LOG_DEBUG,"%s: generateHeaderStats - done",configtag->arch[arch]); 915 logmsg(LOG_DEBUG,"%s: generateHeaderStats - done",configtag->arch[arch]);
919 } 916 }
920 917
921 if (mode & MODE_HTML) { 918 if (mode & MODE_HTML) {
922 // printf("Generating HTML files for binary RPMs...\n"); 919 // printf("Generating HTML files for binary RPMs...\n");
923 logmsg(LOG_DEBUG,"%s: generateHTMLFiles - start",configtag->arch[arch]); 920 logmsg(LOG_DEBUG,"%s: generateHTMLFiles - start",configtag->arch[arch]);
924 generateHTMLFiles(configtag, arch); 921 generateHTMLFiles(configtag, arch);
925 logmsg(LOG_DEBUG,"%s: generateHTMLFiles - done",configtag->arch[arch]); 922 logmsg(LOG_DEBUG,"%s: generateHTMLFiles - done",configtag->arch[arch]);
926 } 923 }
927 924
928 if (mode & MODE_GENPKGLIST) { 925 if (mode & MODE_GENPKGLIST) {
929 /* currheaderlist = headerlist; */ 926 /* currheaderlist = headerlist; */
930 generatePkgList(configtag, arch); 927 generatePkgList(configtag, arch);
931 } 928 }
932 return NULL; 929 return NULL;
933 } 930 }
934 931
935 int 932 int
936 main(int argc, char *argv[]) 933 main(int argc, char *argv[])
937 { 934 {
938 char *name = NULL, *date = NULL, 935 char *name = NULL, *date = NULL,
939 *repository_dir = NULL, *repository_tag = NULL, 936 *repository_dir = NULL, *repository_tag = NULL,
940 *configfile = NULL, *passed_arch = NULL; 937 *configfile = NULL, *passed_arch = NULL;
941 938
942 struct headerList *currheaderlist; 939 struct headerList *currheaderlist;
943 struct headerSourceList *currheadersourcelist = NULL, *oldheadersourcelist; 940 struct headerSourceList *currheadersourcelist = NULL, *oldheadersourcelist;
944 struct rebuildList *currrebuild; 941 struct rebuildList *currrebuild;
945 942
946 int i = 0,hasbuilds[ARCHS_MAX],ptharg[ARCHS_MAX]; 943 int i = 0,hasbuilds[ARCHS_MAX],ptharg[ARCHS_MAX];
947 pthread_t pth[ARCHS_MAX]; 944 pthread_t pth[ARCHS_MAX];
948 char warning[8096]; 945 char warning[8096];
949 946
950 time_t start_time, stop_time; 947 time_t start_time, stop_time;
951 948
952 /* options args for 'getopt_long()' */ 949 /* options args for 'getopt_long()' */
953 static const char *optstring = "+a:c:t:qhvd"; 950 static const char *optstring = "+a:c:t:qhvd";
954 static struct option longopts[] = { 951 static struct option longopts[] = {
955 { "deps-table", no_argument, 0, 0 }, 952 { "deps-table", no_argument, 0, 0 },
956 { "data-tables", no_argument, 0, 0 }, 953 { "data-tables", no_argument, 0, 0 },
957 { "gendatatables", no_argument, 0, 0 }, 954 { "gendatatables", no_argument, 0, 0 },
958 { "find-deps", required_argument, 0, 0 }, 955 { "find-deps", required_argument, 0, 0 },
959 { "changelog", required_argument, 0, 0 }, 956 { "changelog", required_argument, 0, 0 },
960 { "changelogsince", required_argument, 0, 0 }, 957 { "changelogsince", required_argument, 0, 0 },
961 { "genbuildinfo", no_argument, 0, 0 }, 958 { "genbuildinfo", no_argument, 0, 0 },
962 { "genhtml", no_argument, 0, 0 }, 959 { "genhtml", no_argument, 0, 0 },
963 { "genhtmlstats", no_argument, 0, 0 }, 960 { "genhtmlstats", no_argument, 0, 0 },
964 { "genpkglist", no_argument, 0, 0 }, 961 { "genpkglist", no_argument, 0, 0 },
965 { "gensrcpkglist", no_argument, 0, 0 }, 962 { "gensrcpkglist", no_argument, 0, 0 },
966 { "gensqlite3", no_argument, 0, 0 }, 963 { "gensqlite3", no_argument, 0, 0 },
967 { "gensqlite3files", no_argument, 0, 0 }, 964 { "gensqlite3files", no_argument, 0, 0 },
968 { "gencontentslist", no_argument, 0, 0 }, 965 { "gencontentslist", no_argument, 0, 0 },
969 { "arch", required_argument, 0, 'a' }, 966 { "arch", required_argument, 0, 'a' },
970 { "conf", required_argument, 0, 'c' }, 967 { "conf", required_argument, 0, 'c' },
971 { "help", no_argument, 0, 'h' }, 968 { "help", no_argument, 0, 'h' },
972 { "quiet", no_argument, 0, 'q' }, 969 { "quiet", no_argument, 0, 'q' },
973 { "tag", required_argument, 0, 't' }, 970 { "tag", required_argument, 0, 't' },
974 { "version", no_argument, 0, 'v' }, 971 { "version", no_argument, 0, 'v' },
975 { "debug", no_argument, 0, 'd' }, 972 { "debug", no_argument, 0, 'd' },
976 { 0, 0, 0, 0 } 973 { 0, 0, 0, 0 }
977 }; 974 };
978 975
979 // install backtrace handler 976 // install backtrace handler
980 signal(SIGSEGV, backtraceHandler); 977 signal(SIGSEGV, backtraceHandler);
981 978
982 start_time=time(NULL); 979 start_time=time(NULL);
983 980
984 opterr = 1; 981 opterr = 1;
985 unsigned int syntaxerr = 0; 982 unsigned int syntaxerr = 0;
986 983
987 while (1) { 984 while (1) {
988 int longindex = 0; 985 int longindex = 0;
989 int argval = getopt_long(argc, argv, optstring, longopts, &longindex); 986 int argval = getopt_long(argc, argv, optstring, longopts, &longindex);
990 if (argval == -1) { 987 if (argval == -1) {
991 break; 988 break;
992 } 989 }
993 990
994 switch (argval) { 991 switch (argval) {
995 case 0: 992 case 0:
996 if (!strcmp(longopts[longindex].name, "gendatatables")) { 993 if (!strcmp(longopts[longindex].name, "gendatatables")) {
997 mode |= MODE_DATA_TABLES; 994 mode |= MODE_DATA_TABLES;
998 } else if (!strcmp(longopts[longindex].name, "deps-table") || 995 } else if (!strcmp(longopts[longindex].name, "deps-table") ||
999 !strcmp(longopts[longindex].name, "data-tables")) { 996 !strcmp(longopts[longindex].name, "data-tables")) {
1000 fprintf(stderr,"Warning: use of --deps-table and --data-tables is obsolete; use --gendatatables instead.\n"); 997 fprintf(stderr,"Warning: use of --deps-table and --data-tables is obsolete; use --gendatatables instead.\n");
1001 mode |= MODE_DATA_TABLES; 998 mode |= MODE_DATA_TABLES;
1002 } else if (!strcmp(longopts[longindex].name, "find-deps")) { 999 } else if (!strcmp(longopts[longindex].name, "find-deps")) {
1003 mode |= MODE_FIND_DEPS; 1000 mode |= MODE_FIND_DEPS;
1004 name = optarg; 1001 name = optarg;
1005 } else if (!strcmp(longopts[longindex].name, "changelog")) { 1002 } else if (!strcmp(longopts[longindex].name, "changelog")) {
1006 mode |= MODE_CHANGELOG; 1003 mode |= MODE_CHANGELOG;
1007 genheader_mode |= GENHEADER_CHANGELOG | GENHEADER_STATS; 1004 genheader_mode |= GENHEADER_CHANGELOG | GENHEADER_STATS;
1008 name = optarg; 1005 name = optarg;
1009 } else if (!strcmp(longopts[longindex].name, "changelogsince")) { 1006 } else if (!strcmp(longopts[longindex].name, "changelogsince")) {
1010 mode |= MODE_CHANGELOG; 1007 mode |= MODE_CHANGELOG;
1011 genheader_mode |= GENHEADER_CHANGELOG | GENHEADER_STATS; 1008 genheader_mode |= GENHEADER_CHANGELOG | GENHEADER_STATS;
1012 date = optarg; 1009 date = optarg;
1013 name = NULL; 1010 name = NULL;
1014 } else if (!strcmp(longopts[longindex].name, "genhtml")) { 1011 } else if (!strcmp(longopts[longindex].name, "genhtml")) {
1015 mode |= MODE_HTML | MODE_HTMLSTATS; 1012 mode |= MODE_HTML | MODE_HTMLSTATS;
1016 genheader_mode |= GENHEADER_CHANGELOG | GENHEADER_STATS; 1013 genheader_mode |= GENHEADER_CHANGELOG | GENHEADER_STATS;
1017 recursive_mode = 1; 1014 recursive_mode = 1;
1018 name = NULL; 1015 name = NULL;
1019 } else if (!strcmp(longopts[longindex].name, "genhtmlstats")) { 1016 } else if (!strcmp(longopts[longindex].name, "genhtmlstats")) {
1020 mode |= MODE_HTMLSTATS; 1017 mode |= MODE_HTMLSTATS;
1021 genheader_mode |= GENHEADER_CHANGELOG | GENHEADER_STATS; 1018 genheader_mode |= GENHEADER_CHANGELOG | GENHEADER_STATS;
1022 recursive_mode = 1; 1019 recursive_mode = 1;
1023 name = NULL; 1020 name = NULL;
1024 } else if (!strcmp(longopts[longindex].name, "gensqlite3")) { 1021 } else if (!strcmp(longopts[longindex].name, "gensqlite3")) {
1025 mode |= MODE_SQLITE3; 1022 mode |= MODE_SQLITE3;
1026 } else if (!strcmp(longopts[longindex].name, "gensqlite3files")) { 1023 } else if (!strcmp(longopts[longindex].name, "gensqlite3files")) {
1027 mode |= MODE_SQLITE3_FILES; 1024 mode |= MODE_SQLITE3_FILES;
1028 } else if (!strcmp(longopts[longindex].name, "gensrcpkglist")) { 1025 } else if (!strcmp(longopts[longindex].name, "gensrcpkglist")) {
1029 mode |= MODE_GENSRCPKGLIST; 1026 mode |= MODE_GENSRCPKGLIST;
1030 name = NULL; 1027 name = NULL;
1031 } else if (!strcmp(longopts[longindex].name, "genpkglist")) { 1028 } else if (!strcmp(longopts[longindex].name, "genpkglist")) {
1032 mode |= MODE_GENPKGLIST; 1029 mode |= MODE_GENPKGLIST;
1033 name = NULL; 1030 name = NULL;
1034 } else if (!strcmp(longopts[longindex].name, "genbuildinfo")) { 1031 } else if (!strcmp(longopts[longindex].name, "genbuildinfo")) {
1035 mode |= MODE_GENBUILDINFO; 1032 mode |= MODE_GENBUILDINFO;
1036 genheader_mode |= GENHEADER_BASE; 1033 genheader_mode |= GENHEADER_BASE;
1037 name = NULL; 1034 name = NULL;
1038 } else if (!strcmp(longopts[longindex].name, "gencontentslist")) { 1035 } else if (!strcmp(longopts[longindex].name, "gencontentslist")) {
1039 mode |= MODE_GENCONTENTSLIST; 1036 mode |= MODE_GENCONTENTSLIST;
1040 name = NULL; 1037 name = NULL;
1041 } 1038 }
1042 break; 1039 break;
1043 case 'a': 1040 case 'a':
1044 passed_arch = optarg; 1041 passed_arch = optarg;
1045 break; 1042 break;
1046 case 'c': 1043 case 'c':
1047 configfile = optarg; 1044 configfile = optarg;
1048 break; 1045 break;
1049 case 't': 1046 case 't':
1050 repository_tag = optarg; 1047 repository_tag = optarg;
1051 break; 1048 break;
1052 case 'h': 1049 case 'h':
1053 program_usage(0); 1050 program_usage(0);
1054 break; 1051 break;
1055 case 'q': 1052 case 'q':
1056 quietmode=1; 1053 quietmode=1;
1057 break; 1054 break;
1058 case 'v': 1055 case 'v':
1059 program_version(); 1056 program_version();
1060 exit(0); 1057 exit(0);
1061 break; 1058 break;
1062 case '?': 1059 case '?':
1063 /* program_usage(1); */ 1060 /* program_usage(1); */
1064 exit(1); 1061 exit(1);
1065 break; 1062 break;
1066 case 'd': 1063 case 'd':
1067 log_debug_set(1); 1064 log_debug_set(1);
1068 logmsg(LOG_DEBUG,"debug logging enabled"); 1065 logmsg(LOG_DEBUG,"debug logging enabled");
1069 break; 1066 break;
1070 default: 1067 default:
1071 fprintf(stderr, 1068 fprintf(stderr,
1072 "Fatal error while parsing command line arguments\n"); 1069 "Fatal error while parsing command line arguments\n");
1073 exit(1); 1070 exit(1);
1074 break; 1071 break;
1075 } 1072 }
1076 } 1073 }
1077 1074
1078 if (optind < argc) { 1075 if (optind < argc) {
1079 fprintf(stderr, "Non-option elements found: "); 1076 fprintf(stderr, "Non-option elements found: ");
1080 while (optind < argc) 1077 while (optind < argc)
1081 fprintf(stderr, "`%s' ", argv[optind++]); 1078 fprintf(stderr, "`%s' ", argv[optind++]);
1082 fprintf(stderr, "\n"); 1079 fprintf(stderr, "\n");
1083 exit(1); 1080 exit(1);
1084 } else if (syntaxerr || !mode || !repository_tag ) { 1081 } else if (syntaxerr || !mode || !repository_tag ) {
1085 program_usage(1); 1082 program_usage(1);
1086 } 1083 }
1087 1084
1088 /* if only target is sqlite3 db minimize operations */ 1085 /* if only target is sqlite3 db minimize operations */
1089 if (mode == MODE_SQLITE3 || mode == MODE_SQLITE3_FILES || mode == (MODE_SQLITE3 | MODE_SQLITE3_FILES)) { 1086 if (mode == MODE_SQLITE3 || mode == MODE_SQLITE3_FILES || mode == (MODE_SQLITE3 | MODE_SQLITE3_FILES)) {
1090 genheader_mode |= GENHEADER_CHANGELOG; 1087 genheader_mode |= GENHEADER_CHANGELOG;
1091 recursive_mode = 0; 1088 recursive_mode = 0;
1092 incremental_mode = 0; 1089 incremental_mode = 0;
1093 obsolete_packages = 0; 1090 obsolete_packages = 0;
1094 //resolve_dependencies = 0; 1091 //resolve_dependencies = 0;
1095 name = NULL; 1092 name = NULL;
1096 } 1093 }
1097 1094
1098 if (!configfile) { 1095 if (!configfile) {
1099 configfile = malloc(sizeof DEFAULT_CONFIGFILE); 1096 configfile = malloc(sizeof DEFAULT_CONFIGFILE);
1100 if (!configfile) { 1097 if (!configfile) {
1101 fprintf(stderr, "The system is out of memory\n"); 1098 fprintf(stderr, "The system is out of memory\n");
1102 exit(1); 1099 exit(1);
1103 } 1100 }
1104 strcpy(configfile, DEFAULT_CONFIGFILE); 1101 strcpy(configfile, DEFAULT_CONFIGFILE);
1105 } 1102 }
1106 1103
1107 firstconfigtag = read_configuration(configfile); 1104 firstconfigtag = read_configuration(configfile);
1108 if (!firstconfigtag) { 1105 if (!firstconfigtag) {
1109 fprintf(stderr, 1106 fprintf(stderr,
1110 "Fatal error while parsing config file %s; aborting.\n",configfile); 1107 "Fatal error while parsing config file %s; aborting.\n",configfile);
1111 exit(1); 1108 exit(1);
1112 } 1109 }
1113 1110
1114 configtag = findRepositoryByTag(repository_tag); 1111 configtag = findRepositoryByTag(repository_tag);
1115 if (!configtag) { 1112 if (!configtag) {
1116 fprintf(stderr, 1113 fprintf(stderr,
1117 "Fatal error: configuration missing for given tag\n"); 1114 "Fatal error: configuration missing for given tag\n");
1118 exit(1); 1115 exit(1);
1119 } 1116 }
1120 1117
1121 if (passed_arch) { 1118 if (passed_arch) {
1122 configtag->arch[0] = malloc(sizeof passed_arch); 1119 configtag->arch[0] = malloc(sizeof passed_arch);
1123 if (!configtag->arch[0]) { 1120 if (!configtag->arch[0]) {
1124 fprintf(stderr, "The system is out of memory\n"); 1121 fprintf(stderr, "The system is out of memory\n");
1125 exit(1); 1122 exit(1);
1126 } 1123 }
1127 strcpy(configtag->arch[0], passed_arch); 1124 strcpy(configtag->arch[0], passed_arch);
1128 configtag->arch[1] = NULL; 1125 configtag->arch[1] = NULL;
1129 } 1126 }
1130 1127
1131 rpminit(); 1128 rpminit();
1132 1129
1133 if (!quietmode) 1130 if (!quietmode)
1134 fprintf(stdout, "Starting operations on '%s' repository\n", configtag->tag); 1131 fprintf(stdout, "Starting operations on '%s' repository\n", configtag->tag);
1135 1132
1136 if (!repository_dir) 1133 if (!repository_dir)
1137 repository_dir = configtag->repository_dir; 1134 repository_dir = configtag->repository_dir;
1138 1135
1139 if (!quietmode) 1136 if (!quietmode)
1140 fprintf(stdout, "Scanning source packages...\n"); 1137 fprintf(stdout, "Scanning source packages...\n");
1141 else 1138 else
1142 logmsg(LOG_MARK,"Source packages check for %s:", configtag->tag); 1139 logmsg(LOG_MARK,"Source packages check for %s:", configtag->tag);
1143 1140
1144 if (generateSourceHeaderList(configtag, genheader_mode, incremental_mode)) { 1141 if (generateSourceHeaderList(configtag, genheader_mode, incremental_mode)) {
1145 fprintf(stderr, 1142 fprintf(stderr,
1146 "Fatal error: could not generate source header list\n"); 1143 "Fatal error: could not generate source header list\n");
1147 exit(1); 1144 exit(1);
1148 } 1145 }
1149 1146
1150 if (genheader_mode) { 1147 if (genheader_mode) {
1151 1148
1152 if (mode & MODE_HTML) { 1149 if (mode & MODE_HTML) {
1153 logmsg(LOG_DEBUG,"cleanHTMLPackagesFiles - start"); 1150 logmsg(LOG_DEBUG,"cleanHTMLPackagesFiles - start");
1154 cleanHTMLPackagesFiles(configtag); 1151 cleanHTMLPackagesFiles(configtag);
1155 logmsg(LOG_DEBUG,"cleanHTMLPackagesFiles - done"); 1152 logmsg(LOG_DEBUG,"cleanHTMLPackagesFiles - done");
1156 } 1153 }
1157 1154
1158 warning[0]=0; 1155 warning[0]=0;
1159 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) { 1156 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
1160 snprintf(&warning[strlen(warning)],sizeof(warning)-strlen(warning)," %s", configtag->arch[i]); 1157 snprintf(&warning[strlen(warning)],sizeof(warning)-strlen(warning)," %s", configtag->arch[i]);
1161 } 1158 }
1162 if (!quietmode) 1159 if (!quietmode)
1163 fprintf(stdout, "Scanning binary packages for archs:%s...\n",warning); 1160 fprintf(stdout, "Scanning binary packages for archs:%s...\n",warning);
1164 else 1161 else
1165 logmsg(LOG_MARK, "Binary packages check for archs:%s", warning); 1162 logmsg(LOG_MARK, "Binary packages check for archs:%s", warning);
1166 1163
1167 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) { 1164 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
1168 ptharg[i]=i; 1165 ptharg[i]=i;
1169 pthread_create(&pth[i],NULL,threadArchScan,&ptharg[i]); 1166 pthread_create(&pth[i],NULL,threadArchScan,&ptharg[i]);
1170 } // archs threads loop 1167 } // archs threads loop
1171 1168
1172 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) { 1169 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
1173 pthread_join(pth[i], NULL); 1170 pthread_join(pth[i], NULL);
1174 } 1171 }
1175 1172
1176 if (!passed_arch) { // can't do missing builds and ports check in single arch mode 1173 if (!passed_arch) { // can't do missing builds and ports check in single arch mode
1177 if (!quietmode) 1174 if (!quietmode)
1178 fprintf(stdout, "Checking for SRPMS with no builds and missing ports...\n"); 1175 fprintf(stdout, "Checking for SRPMS with no builds and missing ports...\n");
1179 else 1176 else
1180 logmsg(LOG_MARK, "Missing ports and SRPMS with no builds check"); 1177 logmsg(LOG_MARK, "Missing ports and SRPMS with no builds check");
1181 1178
1182 currheadersourcelist = configtag->headersourcelist; 1179 currheadersourcelist = configtag->headersourcelist;
1183 while (currheadersourcelist != NULL) { 1180 while (currheadersourcelist != NULL) {
1184 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) 1181 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++)
1185 hasbuilds[i] = 0; 1182 hasbuilds[i] = 0;
1186 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) { 1183 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
1187 if (currheadersourcelist->firstchild[i]) 1184 if (currheadersourcelist->firstchild[i])
1188 hasbuilds[i] = 1; 1185 hasbuilds[i] = 1;
1189 else if (currheadersourcelist->old && currheadersourcelist->old->firstchild[i]) 1186 else if (currheadersourcelist->old && currheadersourcelist->old->firstchild[i])
1190 hasbuilds[i] = -1; 1187 hasbuilds[i] = -1;
1191 } 1188 }
1192 warning[0] = '\0'; 1189 warning[0] = '\0';
1193 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) { 1190 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
1194 if (hasbuilds[i] == 1) { 1191 if (hasbuilds[i] == 1) {
1195 strncat(warning, " ", sizeof(warning) - strlen(warning)); 1192 strncat(warning, " ", sizeof(warning) - strlen(warning));
1196 strncat(warning, configtag->arch[i], sizeof(warning) - strlen(warning)); 1193 strncat(warning, configtag->arch[i], sizeof(warning) - strlen(warning));
1197 } 1194 }
1198 } 1195 }
1199 if (warning[0] == '\0') { 1196 if (warning[0] == '\0') {
1200 snprintf(warning, PATH_MAX, "SRPM does not have any valid RPM build"); 1197 snprintf(warning, PATH_MAX, "SRPM does not have any valid RPM build");
1201 logmsg(LOG_WARNING, "%s: %s", 1198 logmsg(LOG_WARNING, "%s: %s",
1202 currheadersourcelist->name, 1199 currheadersourcelist->name,
1203 warning); 1200 warning);
1204 addWarning(currheadersourcelist, warning); 1201 addWarning(currheadersourcelist, warning);
1205 } 1202 }
1206 1203
1207 warning[0] = '\0'; 1204 warning[0] = '\0';
1208 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) { 1205 for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
1209 if ((hasbuilds[i] == -1) && 1206 if ((hasbuilds[i] == -1) &&
1210 (currheadersourcelist->altrepository == configtag->repository_level)) { 1207 (currheadersourcelist->altrepository == configtag->repository_level)) {
1211 if (warning[0] == '\0') 1208 if (warning[0] == '\0')
1212 strncat(warning, "requires port to arch(s):", sizeof(warning) - strlen(warning)); 1209 strncat(warning, "requires port to arch(s):", sizeof(warning) - strlen(warning));
1213 strncat(warning," ", sizeof(warning) - strlen(warning)); 1210 strncat(warning," ", sizeof(warning) - strlen(warning));
1214 strncat(warning,configtag->arch[i], sizeof(warning) - strlen(warning)); 1211 strncat(warning,configtag->arch[i], sizeof(warning) - strlen(warning));
1215 } 1212 }
1216 } 1213 }
1217 if (warning[0] != '\0') { 1214 if (warning[0] != '\0') {
1218 logmsg(LOG_WARNING, "%s: %s", 1215 logmsg(LOG_WARNING, "%s: %s",
1219 currheadersourcelist->name, 1216 currheadersourcelist->name,
1220 warning); 1217 warning);
1221 addWarning(currheadersourcelist, warning); 1218 addWarning(currheadersourcelist, warning);
1222 } 1219 }
1223 1220
1224 warning[0] = '\0'; 1221 warning[0] = '\0';
1225 1222
1226 currrebuild = currheadersourcelist->firstrebuild; 1223 currrebuild = currheadersourcelist->firstrebuild;
1227 oldheadersourcelist = currheadersourcelist->old; 1224 oldheadersourcelist = currheadersourcelist->old;
1228 while (!currrebuild && oldheadersourcelist) { 1225 while (!currrebuild && oldheadersourcelist) {
1229 currrebuild = oldheadersourcelist->firstrebuild; 1226 currrebuild = oldheadersourcelist->firstrebuild;
1230 oldheadersourcelist = oldheadersourcelist->old; 1227 oldheadersourcelist = oldheadersourcelist->old;
1231 } 1228 }
1232 1229
1233 if (currrebuild) { 1230 if (currrebuild) {
1234 strncat(warning,"need to be rebuilt:", sizeof(warning) - strlen(warning)); 1231 strncat(warning,"need to be rebuilt:", sizeof(warning) - strlen(warning));
1235 while (currrebuild) { 1232 while (currrebuild) {
1236 strncat(warning," ", sizeof(warning) - strlen(warning)); 1233 strncat(warning," ", sizeof(warning) - strlen(warning));
1237 strncat(warning,currrebuild->sourceheader->name, sizeof(warning) - strlen(warning)); 1234 strncat(warning,currrebuild->sourceheader->name, sizeof(warning) - strlen(warning));
1238 strncat(warning,"(", sizeof(warning) - strlen(warning)); 1235 strncat(warning,"(", sizeof(warning) - strlen(warning));
1239 strncat(warning,currrebuild->provider->arch, sizeof(warning) - strlen(warning)); 1236 strncat(warning,currrebuild->provider->arch, sizeof(warning) - strlen(warning));
1240 strncat(warning,")", sizeof(warning) - strlen(warning)); 1237 strncat(warning,")", sizeof(warning) - strlen(warning));
1241 currrebuild = currrebuild->next; 1238 currrebuild = currrebuild->next;
1242 } 1239 }
1243 } 1240 }
1244 1241
1245 if (warning[0] != '\0') { 1242 if (warning[0] != '\0') {
1246 logmsg(LOG_WARNING, "%s: %s", 1243 logmsg(LOG_WARNING, "%s: %s",
1247 currheadersourcelist->name, 1244 currheadersourcelist->name,
1248 warning); 1245 warning);
1249 addWarning(currheadersourcelist, warning); 1246 addWarning(currheadersourcelist, warning);
1250 } 1247 }
1251 currheadersourcelist = currheadersourcelist->next; 1248 currheadersourcelist = currheadersourcelist->next;
1252 } 1249 }
1253 } 1250 }
1254 } // if (genheader_mode) 1251 } // if (genheader_mode)
1255 1252
1256 if (mode & MODE_SQLITE3) { 1253 if (mode & MODE_SQLITE3) {
1257 if (!quietmode) printf("Generating SQLite databases...\n"); 1254 if (!quietmode) printf("Generating SQLite databases...\n");
1258 logmsg(LOG_DEBUG,"generateSQLite3 - start"); 1255 logmsg(LOG_DEBUG,"generateSQLite3 - start");
1259 if (generateSQLite(configtag)) { 1256 if (generateSQLite(configtag)) {
1260 logmsg(LOG_ERROR, "could not generate SQLite databases; aborting."); 1257 logmsg(LOG_ERROR, "could not generate SQLite databases; aborting.");
1261 exit(1); 1258 exit(1);
1262 } 1259 }
1263 logmsg(LOG_DEBUG,"generateSQLite3 - done"); 1260 logmsg(LOG_DEBUG,"generateSQLite3 - done");
1264 } 1261 }
1265 1262
1266 if (mode & MODE_SQLITE3_FILES) { 1263 if (mode & MODE_SQLITE3_FILES) {
1267 if (!quietmode) printf("Generating sqlite3 files databases...\n"); 1264 if (!quietmode) printf("Generating sqlite3 files databases...\n");
1268 logmsg(LOG_DEBUG,"generateSQLite3_files - start"); 1265 logmsg(LOG_DEBUG,"generateSQLite3_files - start");
1269 if (generateSQLiteFiles(configtag)) { 1266 if (generateSQLiteFiles(configtag)) {
1270 logmsg(LOG_ERROR, "could not generate sqlite3 files databases; aborting."); 1267 logmsg(LOG_ERROR, "could not generate sqlite3 files databases; aborting.");
1271 exit(1); 1268 exit(1);
1272 } 1269 }
1273 logmsg(LOG_DEBUG,"generateSQLite3_files - done"); 1270 logmsg(LOG_DEBUG,"generateSQLite3_files - done");
1274 } 1271 }
1275 1272
1276 if (genheader_mode & GENHEADER_STATS) { 1273 if (genheader_mode & GENHEADER_STATS) {
1277 if (!quietmode) 1274 if (!quietmode)
1278 fprintf(stdout, " - generating source statistics...\n"); 1275 fprintf(stdout, " - generating source statistics...\n");
1279 1276
1280 logmsg(LOG_DEBUG,"generateHeaderSourceStats - start"); 1277 logmsg(LOG_DEBUG,"generateHeaderSourceStats - start");
1281 if (generateHeaderSourceStats(configtag)) { 1278 if (generateHeaderSourceStats(configtag)) {
1282 fprintf(stderr, 1279 fprintf(stderr,
1283 "Fatal error: could not generate statistic for headers\n"); 1280 "Fatal error: could not generate statistic for headers\n");
1284 exit(1); 1281 exit(1);
1285 } 1282 }
1286 logmsg(LOG_DEBUG,"generateHeaderSourceStats - done"); 1283 logmsg(LOG_DEBUG,"generateHeaderSourceStats - done");
1287 } 1284 }
1288 1285
1289 if (mode & MODE_FIND_DEPS) { 1286 if (mode & MODE_FIND_DEPS) {
1290 currheaderlist = findPackageByName(configtag->headerlist[i], name); 1287 currheaderlist = findPackageByName(configtag->headerlist[i], name);
1291 1288
1292 if (currheaderlist) { 1289 if (currheaderlist) {
1293 printf("%s: ", currheaderlist->name); 1290 printf("%s: ", currheaderlist->name);
1294 printRequireList(stdout,currheaderlist->requirelist); 1291 printRequireList(stdout,currheaderlist->requirelist);
1295 /* currrequirelist = currheaderlist->requirelist; */ 1292 /* currrequirelist = currheaderlist->requirelist; */
1296 printf("\n"); 1293 printf("\n");
1297 } else { 1294 } else {
1298 fprintf(stderr, "Error: package %s not found\n", name); 1295 fprintf(stderr, "Error: package %s not found\n", name);
1299 } 1296 }
1300 } 1297 }
1301 1298
1302 if (mode & MODE_CHANGELOG) { 1299 if (mode & MODE_CHANGELOG) {
1303 if (name) { 1300 if (name) {
1304 currheadersourcelist = 1301 currheadersourcelist =
1305 findSourcePackage(configtag->headersourcelist, name, 1302 findSourcePackage(configtag->headersourcelist, name,
1306 NULL, NULL,-1); 1303 NULL, NULL,-1);
1307 if (currheadersourcelist) { 1304 if (currheadersourcelist) {
1308 printChangelog(currheadersourcelist->changelog); 1305 printChangelog(currheadersourcelist->changelog);
1309 } else { 1306 } else {
1310 fprintf(stderr, "Error: package %s not found\n", name); 1307 fprintf(stderr, "Error: package %s not found\n", name);
1311 } 1308 }
1312 } else { 1309 } else {
1313 struct tm tmdate; 1310 struct tm tmdate;
1314 1311
1315 tmdate.tm_min = 0; 1312 tmdate.tm_min = 0;
1316 tmdate.tm_hour = 0; 1313 tmdate.tm_hour = 0;
1317 tmdate.tm_sec = 0; 1314 tmdate.tm_sec = 0;
1318 1315
1319 const char *cp; 1316 const char *cp;
1320 1317
1321 cp = (char *) strptime((const char *) date, "%m%d%y", &tmdate); 1318 cp = (char *) strptime((const char *) date, "%m%d%y", &tmdate);
1322 if (!cp) { 1319 if (!cp) {
1323 fprintf(stderr, "Error: date \"%s\" is invalid!\n", date); 1320 fprintf(stderr, "Error: date \"%s\" is invalid!\n", date);
1324 exit(1); 1321 exit(1);
1325 } 1322 }
1326 printChangelogSince(stdout,configtag, &tmdate, 0); 1323 printChangelogSince(stdout,configtag, &tmdate, 0);
1327 } 1324 }
1328 } 1325 }
1329 1326
1330 if (mode & MODE_HTML) { 1327 if (mode & MODE_HTML) {
1331 logmsg(LOG_DEBUG,"cleanHTMLFiles - start"); 1328 logmsg(LOG_DEBUG,"cleanHTMLFiles - start");
1332 cleanHTMLFiles(configtag); 1329 cleanHTMLFiles(configtag);
1333 logmsg(LOG_DEBUG,"cleanHTMLFiles - done"); 1330 logmsg(LOG_DEBUG,"cleanHTMLFiles - done");
1334 1331
1335 if (!quietmode) 1332 if (!quietmode)
1336 fprintf(stdout, "Generating HTML reports...\n"); 1333 fprintf(stdout, "Generating HTML reports...\n");
1337 generateHTMLMainIndex(firstconfigtag); 1334 generateHTMLMainIndex(firstconfigtag);
1338 1335
1339 // printf("Generating HTML files for source RPMs...\n"); 1336 // printf("Generating HTML files for source RPMs...\n");
1340 generateHTML_SRPMSFiles(configtag); 1337 generateHTML_SRPMSFiles(configtag);
1341 1338
1342 // printf("Generating Maintainers pages...\n"); 1339 // printf("Generating Maintainers pages...\n");
1343 generateMaintainersPages(configtag); 1340 generateMaintainersPages(configtag);
1344 1341
1345 } 1342 }
1346 1343
1347 // NOTE: generateStats must be called after generateHTML_SRPMSFiles for warnings to appear 1344 // NOTE: generateStats must be called after generateHTML_SRPMSFiles for warnings to appear
1348 if (mode & MODE_HTMLSTATS) { 1345 if (mode & MODE_HTMLSTATS) {
1349 logmsg(LOG_DEBUG,"generateStats - start"); 1346 logmsg(LOG_DEBUG,"generateStats - start");
1350 generateStats(configtag,i); 1347 generateStats(configtag,i);
1351 logmsg(LOG_DEBUG,"generateStats - done"); 1348 logmsg(LOG_DEBUG,"generateStats - done");
1352 } 1349 }
1353 1350
1354 if (mode & MODE_GENSRCPKGLIST) { 1351 if (mode & MODE_GENSRCPKGLIST) {
1355 /* currheaderlist = headerlist; */ 1352 /* currheaderlist = headerlist; */
1356 generateSrcPkgList(configtag); 1353 generateSrcPkgList(configtag);
1357 } 1354 }
1358 1355
1359 if (mode & MODE_GENBUILDINFO) { 1356 if (mode & MODE_GENBUILDINFO) {
1360 /* currheaderlist = headerlist; */ 1357 /* currheaderlist = headerlist; */
1361 printf("Generating build information files...\n"); 1358 printf("Generating build information files...\n");
1362 generateBuildInfo(configtag,0); 1359 generateBuildInfo(configtag,0);
1363 } 1360 }
1364 1361
1365 stop_time=time(NULL); 1362 stop_time=time(NULL);