pkgmaker.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121
  1. /*
  2. * pkgmaker - create package meta-data for OpenADK buildsystem
  3. *
  4. * Copyright (C) 2010-2013 Waldemar Brodkorb <wbx@openadk.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <ctype.h>
  20. #include <dirent.h>
  21. #include <fcntl.h>
  22. #include <stdlib.h>
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <unistd.h>
  26. #include <sys/stat.h>
  27. #include <sys/types.h>
  28. #include "sortfile.h"
  29. #include "strmap.h"
  30. #define MAXLINE 4096
  31. #define MAXVALUE 168
  32. #define MAXVAR 64
  33. #define MAXPATH 320
  34. #define HASHSZ 32
  35. static int nobinpkgs;
  36. #define fatal_error(...) { \
  37. fprintf(stderr, "Fatal error. "); \
  38. fprintf(stderr, __VA_ARGS__); \
  39. fprintf(stderr, "\n"); \
  40. exit(1); \
  41. }
  42. static int parse_var_hash(char *buf, const char *varname, StrMap *strmap) {
  43. char *key, *value, *string;
  44. string = strstr(buf, varname);
  45. if (string != NULL) {
  46. string[strlen(string)-1] = '\0';
  47. key = strtok(string, ":=");
  48. value = strtok(NULL, "=\t");
  49. if (value != NULL)
  50. strmap_put(strmap, key, value);
  51. return(0);
  52. }
  53. return(1);
  54. }
  55. static int parse_var(char *buf, const char *varname, char *pvalue, char **result) {
  56. char *pkg_var;
  57. char *key, *value, *string;
  58. char pkg_str[MAXVAR];
  59. if ((pkg_var = malloc(MAXLINE)) != NULL)
  60. memset(pkg_var, 0, MAXLINE);
  61. else {
  62. perror("Can not allocate memory");
  63. exit(EXIT_FAILURE);
  64. }
  65. if (snprintf(pkg_str, MAXVAR, "%s:=", varname) < 0)
  66. perror("can not create path variable.");
  67. string = strstr(buf, pkg_str);
  68. if (string != NULL) {
  69. string[strlen(string)-1] = '\0';
  70. key = strtok(string, ":=");
  71. value = strtok(NULL, "=\t");
  72. if (value != NULL) {
  73. strncat(pkg_var, value, strlen(value));
  74. *result = strdup(pkg_var);
  75. } else {
  76. nobinpkgs = 1;
  77. *result = NULL;
  78. }
  79. free(pkg_var);
  80. return(0);
  81. } else {
  82. if (snprintf(pkg_str, MAXVAR, "%s+=", varname) < 0)
  83. perror("can not create path variable.");
  84. string = strstr(buf, pkg_str);
  85. if (string != NULL) {
  86. string[strlen(string)-1] = '\0';
  87. key = strtok(string, "+=");
  88. value = strtok(NULL, "=\t");
  89. if (pvalue != NULL)
  90. strncat(pkg_var, pvalue, strlen(pvalue));
  91. strncat(pkg_var, " ", 1);
  92. if (value != NULL)
  93. strncat(pkg_var, value, strlen(value));
  94. *result = strdup(pkg_var);
  95. free(pkg_var);
  96. return(0);
  97. }
  98. }
  99. free(pkg_var);
  100. return(1);
  101. }
  102. static int parse_var_with_pkg(char *buf, const char *varname, char *pvalue, char **result, char **pkgname, int varlen) {
  103. char *pkg_var, *check;
  104. char *key, *value, *string;
  105. if ((pkg_var = malloc(MAXLINE)) != NULL)
  106. memset(pkg_var, 0, MAXLINE);
  107. else {
  108. perror("Can not allocate memory");
  109. exit(EXIT_FAILURE);
  110. }
  111. check = strstr(buf, ":=");
  112. if (check != NULL) {
  113. string = strstr(buf, varname);
  114. if (string != NULL) {
  115. string[strlen(string)-1] = '\0';
  116. key = strtok(string, ":=");
  117. *pkgname = strdup(key+varlen);
  118. value = strtok(NULL, "=\t");
  119. if (value != NULL) {
  120. strncat(pkg_var, value, strlen(value));
  121. *result = strdup(pkg_var);
  122. }
  123. free(pkg_var);
  124. return(0);
  125. }
  126. } else {
  127. string = strstr(buf, varname);
  128. if (string != NULL) {
  129. string[strlen(string)-1] = '\0';
  130. key = strtok(string, "+=");
  131. value = strtok(NULL, "=\t");
  132. if (pvalue != NULL)
  133. strncat(pkg_var, pvalue, strlen(pvalue));
  134. strncat(pkg_var, " ", 1);
  135. if (value != NULL)
  136. strncat(pkg_var, value, strlen(value));
  137. *result = strdup(pkg_var);
  138. free(pkg_var);
  139. return(0);
  140. }
  141. }
  142. free(pkg_var);
  143. return(1);
  144. }
  145. #if 0
  146. static void iter_debug(const char *key, const char *value, const void *obj) {
  147. fprintf(stderr, "HASHMAP key: %s value: %s\n", key, value);
  148. }
  149. #endif
  150. static int hash_str(char *string) {
  151. int i;
  152. int hash;
  153. hash = 0;
  154. for (i=0; i<(int)strlen(string); i++) {
  155. hash += string[i];
  156. }
  157. return(hash);
  158. }
  159. static void iter(const char *key, const char *value, const void *obj) {
  160. FILE *config, *section;
  161. int hash;
  162. char *valuestr, *pkg, *subpkg;
  163. char buf[MAXPATH];
  164. char infile[MAXPATH];
  165. char outfile[MAXPATH];
  166. valuestr = strdup(value);
  167. config = fopen("package/Config.in.auto", "a");
  168. if (config == NULL)
  169. fatal_error("Can not open file package/Config.in.auto");
  170. hash = hash_str(valuestr);
  171. snprintf(infile, MAXPATH, "package/pkglist.d/sectionlst.%d", hash);
  172. snprintf(outfile, MAXPATH, "package/pkglist.d/sectionlst.%d.sorted", hash);
  173. if (access(infile, F_OK) == 0) {
  174. valuestr[strlen(valuestr)-1] = '\0';
  175. fprintf(config, "menu \"%s\"\n", valuestr);
  176. sortfile(infile, outfile);
  177. /* avoid duplicate section entries */
  178. unlink(infile);
  179. section = fopen(outfile, "r");
  180. while (fgets(buf, MAXPATH, section) != NULL) {
  181. buf[strlen(buf)-1] = '\0';
  182. if (buf[strlen(buf)-1] == '@') {
  183. buf[strlen(buf)-1] = '\0';
  184. fprintf(config, "source \"package/%s/Config.in.manual\"\n", buf);
  185. } else {
  186. subpkg = strtok(buf, "|");
  187. subpkg[strlen(subpkg)-1] = '\0';
  188. pkg = strtok(NULL, "|");
  189. fprintf(config, "source \"package/pkgconfigs.d/%s/Config.in.%s\"\n", pkg, subpkg);
  190. }
  191. }
  192. fprintf(config, "endmenu\n\n");
  193. fclose(section);
  194. }
  195. fclose(config);
  196. }
  197. static char *tolowerstr(char *string) {
  198. int i;
  199. char *str;
  200. /* transform to lowercase variable name */
  201. str = strdup(string);
  202. for (i=0; i<(int)strlen(str); i++) {
  203. if (str[i] == '_')
  204. str[i] = '-';
  205. str[i] = tolower(str[i]);
  206. }
  207. return(str);
  208. }
  209. static char *toupperstr(char *string) {
  210. int i;
  211. char *str;
  212. /* transform to uppercase variable name */
  213. str = strdup(string);
  214. for (i=0; i<(int)strlen(str); i++) {
  215. if (str[i] == '+')
  216. str[i] = 'X';
  217. if (str[i] == '-')
  218. str[i] = '_';
  219. /* remove negation here, useful for package host depends */
  220. if (str[i] == '!')
  221. str[i] = '_';
  222. str[i] = toupper(str[i]);
  223. }
  224. return(str);
  225. }
  226. int main() {
  227. DIR *pkgdir, *pkglistdir;
  228. struct dirent *pkgdirp;
  229. FILE *pkg, *cfg, *menuglobal, *section;
  230. char hvalue[MAXVALUE];
  231. char buf[MAXPATH];
  232. char tbuf[MAXPATH];
  233. char path[MAXPATH];
  234. char spath[MAXPATH];
  235. char dir[MAXPATH];
  236. char variable[2*MAXVAR];
  237. char *key, *value, *token, *cftoken, *sp, *hkey, *val, *pkg_fd;
  238. char *pkg_name, *pkg_depends, *pkg_section, *pkg_descr, *pkg_url;
  239. char *pkg_cxx, *pkg_subpkgs, *pkg_cfline, *pkg_dflt, *pkg_multi;
  240. char *pkg_need_cxx, *pkg_need_java, *pkgname;
  241. char *pkg_libc_depends, *pkg_host_depends, *pkg_system_depends, *pkg_arch_depends, *pkg_flavours, *pkg_flavours_string, *pkg_choices, *pseudo_name;
  242. char *packages, *pkg_name_u, *pkgs, *pkg_opts, *pkg_libname;
  243. char *saveptr, *p_ptr, *s_ptr, *pkg_helper;
  244. int result;
  245. StrMap *pkgmap, *sectionmap;
  246. pkg_name = NULL;
  247. pkg_descr = NULL;
  248. pkg_section = NULL;
  249. pkg_url = NULL;
  250. pkg_depends = NULL;
  251. pkg_opts = NULL;
  252. pkg_libname = NULL;
  253. pkg_flavours = NULL;
  254. pkg_flavours_string = NULL;
  255. pkg_choices = NULL;
  256. pkg_subpkgs = NULL;
  257. pkg_arch_depends = NULL;
  258. pkg_system_depends = NULL;
  259. pkg_host_depends = NULL;
  260. pkg_libc_depends = NULL;
  261. pkg_cxx = NULL;
  262. pkg_dflt = NULL;
  263. pkg_cfline = NULL;
  264. pkg_multi = NULL;
  265. pkg_need_cxx = NULL;
  266. pkg_need_java = NULL;
  267. pkgname = NULL;
  268. pkg_helper = NULL;
  269. p_ptr = NULL;
  270. s_ptr = NULL;
  271. unlink("package/Config.in.auto");
  272. /* open global sectionfile */
  273. menuglobal = fopen("package/Config.in.auto.global", "w");
  274. if (menuglobal == NULL)
  275. fatal_error("global section file not writable.");
  276. /* read section list and create a hash table */
  277. section = fopen("package/section.lst", "r");
  278. if (section == NULL)
  279. fatal_error("section listfile is missing");
  280. sectionmap = strmap_new(HASHSZ);
  281. while (fgets(tbuf, MAXPATH, section) != NULL) {
  282. key = strtok(tbuf, "\t");
  283. value = strtok(NULL, "\t");
  284. strmap_put(sectionmap, key, value);
  285. }
  286. fclose(section);
  287. if (mkdir("package/pkgconfigs.d", S_IRWXU) > 0)
  288. fatal_error("creation of package/pkgconfigs.d failed.");
  289. if (mkdir("package/pkgconfigs.d/gcc", S_IRWXU) > 0)
  290. fatal_error("creation of package/pkgconfigs.d/gcc failed.");
  291. if (mkdir("package/pkglist.d", S_IRWXU) > 0)
  292. fatal_error("creation of package/pkglist.d failed.");
  293. /* delete Config.in.dev */
  294. if (snprintf(path, MAXPATH, "package/pkgconfigs.d/gcc/Config.in.dev") < 0)
  295. fatal_error("failed to create path variable.");
  296. unlink(path);
  297. cfg = fopen(path, "w");
  298. if (cfg == NULL)
  299. fatal_error("Config.in.dev can not be opened");
  300. fprintf(cfg, "config ADK_PACKAGE_GLIBC_DEV\n");
  301. fprintf(cfg, "\tprompt \"glibc-dev............ development files for glibc\"\n");
  302. fprintf(cfg, "\ttristate\n");
  303. fprintf(cfg, "\tdefault n\n");
  304. fprintf(cfg, "\tdepends on ADK_TARGET_LIB_GLIBC\n");
  305. fprintf(cfg, "\thelp\n");
  306. fprintf(cfg, "\t GNU C library header files.\n\n");
  307. fprintf(cfg, "config ADK_PACKAGE_EGLIBC_DEV\n");
  308. fprintf(cfg, "\tprompt \"eglibc-dev........... development files for eglibc\"\n");
  309. fprintf(cfg, "\ttristate\n");
  310. fprintf(cfg, "\tdefault n\n");
  311. fprintf(cfg, "\tdepends on ADK_TARGET_LIB_EGLIBC\n");
  312. fprintf(cfg, "\thelp\n");
  313. fprintf(cfg, "\t GNU C library header files.\n\n");
  314. fprintf(cfg, "config ADK_PACKAGE_UCLIBC_DEV\n");
  315. fprintf(cfg, "\tprompt \"uclibc-dev........... development files for uclibc\"\n");
  316. fprintf(cfg, "\ttristate\n");
  317. fprintf(cfg, "\tdefault n\n");
  318. fprintf(cfg, "\tdepends on ADK_TARGET_LIB_UCLIBC\n");
  319. fprintf(cfg, "\thelp\n");
  320. fprintf(cfg, "\t C library header files.\n\n");
  321. fprintf(cfg, "config ADK_PACKAGE_MUSL_DEV\n");
  322. fprintf(cfg, "\tprompt \"musl-dev............. development files for musl\"\n");
  323. fprintf(cfg, "\ttristate\n");
  324. fprintf(cfg, "\tdefault n\n");
  325. fprintf(cfg, "\tdepends on ADK_TARGET_LIB_MUSL\n");
  326. fprintf(cfg, "\thelp\n");
  327. fprintf(cfg, "\t C library header files.\n\n");
  328. fclose(cfg);
  329. /* read Makefile's for all packages */
  330. pkgdir = opendir("package");
  331. while ((pkgdirp = readdir(pkgdir)) != NULL) {
  332. /* skip dotfiles */
  333. if (strncmp(pkgdirp->d_name, ".", 1) > 0) {
  334. if (snprintf(path, MAXPATH, "package/%s/Makefile", pkgdirp->d_name) < 0)
  335. fatal_error("can not create path variable.");
  336. pkg = fopen(path, "r");
  337. if (pkg == NULL)
  338. continue;
  339. /* skip manually maintained packages */
  340. if (snprintf(path, MAXPATH, "package/%s/Config.in.manual", pkgdirp->d_name) < 0)
  341. fatal_error("can not create path variable.");
  342. if (!access(path, F_OK)) {
  343. while (fgets(buf, MAXPATH, pkg) != NULL) {
  344. if ((parse_var(buf, "PKG_SECTION", NULL, &pkg_section)) == 0)
  345. continue;
  346. }
  347. memset(hvalue, 0 , MAXVALUE);
  348. result = strmap_get(sectionmap, pkg_section, hvalue, sizeof(hvalue));
  349. if (result == 1) {
  350. if (snprintf(spath, MAXPATH, "package/pkglist.d/sectionlst.%d", hash_str(hvalue)) < 0)
  351. fatal_error("can not create path variable.");
  352. section = fopen(spath, "a");
  353. if (section != NULL) {
  354. fprintf(section, "%s@\n", pkgdirp->d_name);
  355. fclose(section);
  356. }
  357. } else
  358. fatal_error("Can not find section description for package %s.",
  359. pkgdirp->d_name);
  360. fclose(pkg);
  361. continue;
  362. }
  363. nobinpkgs = 0;
  364. /* create output directories */
  365. if (snprintf(dir, MAXPATH, "package/pkgconfigs.d/%s", pkgdirp->d_name) < 0)
  366. fatal_error("can not create dir variable.");
  367. if (mkdir(dir, S_IRWXU) > 0)
  368. fatal_error("can not create directory.");
  369. /* allocate memory */
  370. hkey = malloc(MAXVAR);
  371. memset(hkey, 0, MAXVAR);
  372. memset(variable, 0, 2*MAXVAR);
  373. pkgmap = strmap_new(HASHSZ);
  374. /* parse package Makefile */
  375. while (fgets(buf, MAXPATH, pkg) != NULL) {
  376. /* just read variables prefixed with PKG */
  377. if (strncmp(buf, "PKG", 3) == 0) {
  378. if ((parse_var(buf, "PKG_NAME", NULL, &pkg_name)) == 0)
  379. continue;
  380. if (pkg_name != NULL)
  381. pkg_name_u = toupperstr(pkg_name);
  382. else
  383. pkg_name_u = toupperstr(pkgdirp->d_name);
  384. snprintf(variable, MAXVAR, "PKG_CFLINE_%s", pkg_name_u);
  385. if ((parse_var(buf, variable, pkg_cfline, &pkg_cfline)) == 0)
  386. continue;
  387. snprintf(variable, MAXVAR, "PKG_DFLT_%s", pkg_name_u);
  388. if ((parse_var(buf, variable, NULL, &pkg_dflt)) == 0)
  389. continue;
  390. if ((parse_var(buf, "PKG_LIBC_DEPENDS", NULL, &pkg_libc_depends)) == 0)
  391. continue;
  392. if ((parse_var(buf, "PKG_HOST_DEPENDS", NULL, &pkg_host_depends)) == 0)
  393. continue;
  394. if ((parse_var(buf, "PKG_ARCH_DEPENDS", NULL, &pkg_arch_depends)) == 0)
  395. continue;
  396. if ((parse_var(buf, "PKG_SYSTEM_DEPENDS", NULL, &pkg_system_depends)) == 0)
  397. continue;
  398. if ((parse_var(buf, "PKG_DESCR", NULL, &pkg_descr)) == 0)
  399. continue;
  400. if ((parse_var(buf, "PKG_SECTION", NULL, &pkg_section)) == 0)
  401. continue;
  402. if ((parse_var(buf, "PKG_URL", NULL, &pkg_url)) == 0)
  403. continue;
  404. if ((parse_var(buf, "PKG_CXX", NULL, &pkg_cxx)) == 0)
  405. continue;
  406. if ((parse_var(buf, "PKG_NEED_CXX", NULL, &pkg_need_cxx)) == 0)
  407. continue;
  408. if ((parse_var(buf, "PKG_NEED_JAVA", NULL, &pkg_need_java)) == 0)
  409. continue;
  410. if ((parse_var(buf, "PKG_MULTI", NULL, &pkg_multi)) == 0)
  411. continue;
  412. if ((parse_var(buf, "PKG_DEPENDS", pkg_depends, &pkg_depends)) == 0)
  413. continue;
  414. if ((parse_var(buf, "PKG_LIBNAME", pkg_libname, &pkg_libname)) == 0)
  415. continue;
  416. if ((parse_var(buf, "PKG_OPTS", pkg_opts, &pkg_opts)) == 0)
  417. continue;
  418. if ((parse_var_with_pkg(buf, "PKG_FLAVOURS_STRING_", pkg_flavours_string, &pkg_flavours_string, &pkgname, 20)) == 0)
  419. continue;
  420. if ((parse_var_with_pkg(buf, "PKG_FLAVOURS_", pkg_flavours, &pkg_flavours, &pkgname, 13)) == 0)
  421. continue;
  422. if ((parse_var_hash(buf, "PKGFD_", pkgmap)) == 0)
  423. continue;
  424. if ((parse_var_hash(buf, "PKGFX_", pkgmap)) == 0)
  425. continue;
  426. if ((parse_var_hash(buf, "PKGFS_", pkgmap)) == 0)
  427. continue;
  428. if ((parse_var_hash(buf, "PKGFC_", pkgmap)) == 0)
  429. continue;
  430. if ((parse_var_with_pkg(buf, "PKG_CHOICES_", pkg_choices, &pkg_choices, &pkgname, 12)) == 0)
  431. continue;
  432. if ((parse_var_hash(buf, "PKGCD_", pkgmap)) == 0)
  433. continue;
  434. if ((parse_var_hash(buf, "PKGCS_", pkgmap)) == 0)
  435. continue;
  436. if ((parse_var(buf, "PKG_SUBPKGS", pkg_subpkgs, &pkg_subpkgs)) == 0)
  437. continue;
  438. if ((parse_var_hash(buf, "PKGSD_", pkgmap)) == 0)
  439. continue;
  440. if ((parse_var_hash(buf, "PKGSS_", pkgmap)) == 0)
  441. continue;
  442. if ((parse_var_hash(buf, "PKGSC_", pkgmap)) == 0)
  443. continue;
  444. }
  445. }
  446. /* when PKG_LIBNAME exist use this instead of PKG_NAME, but only for !libmix */
  447. if (pkg_libname != NULL)
  448. if (strstr(pkg_opts, "libmix") == NULL)
  449. pkg_name = strdup(pkg_libname);
  450. /* end of package Makefile parsing */
  451. if (fclose(pkg) != 0)
  452. perror("Failed to close file stream for Makefile");
  453. #if 0
  454. if (pkg_name != NULL)
  455. fprintf(stderr, "Package name is %s\n", pkg_name);
  456. if (pkg_libname != NULL)
  457. fprintf(stderr, "Package library name is %s\n", pkg_libname);
  458. if (pkg_section != NULL)
  459. fprintf(stderr, "Package section is %s\n", pkg_section);
  460. if (pkg_descr != NULL)
  461. fprintf(stderr, "Package description is %s\n", pkg_descr);
  462. if (pkg_depends != NULL)
  463. fprintf(stderr, "Package dependencies are %s\n", pkg_depends);
  464. if (pkg_subpkgs != NULL)
  465. fprintf(stderr, "Package subpackages are %s\n", pkg_subpkgs);
  466. if (pkg_flavours != NULL && pkgname != NULL)
  467. fprintf(stderr, "Package flavours for %s are %s\n", pkgname, pkg_flavours);
  468. if (pkg_flavours_string != NULL && pkgname != NULL)
  469. fprintf(stderr, "Package string flavours for %s are %s\n", pkgname, pkg_flavours_string);
  470. if (pkg_choices != NULL && pkgname != NULL)
  471. fprintf(stderr, "Package choices for %s are %s\n", pkgname, pkg_choices);
  472. if (pkg_url != NULL)
  473. fprintf(stderr, "Package homepage is %s\n", pkg_url);
  474. if (pkg_cfline != NULL)
  475. fprintf(stderr, "Package cfline is %s\n", pkg_cfline);
  476. if (pkg_multi != NULL)
  477. fprintf(stderr, "Package multi is %s\n", pkg_multi);
  478. if (pkg_opts != NULL)
  479. fprintf(stderr, "Package options are %s\n", pkg_opts);
  480. strmap_enum(pkgmap, iter_debug, NULL);
  481. #endif
  482. /* generate master source Config.in file */
  483. if (snprintf(path, MAXPATH, "package/pkgconfigs.d/%s/Config.in", pkgdirp->d_name) < 0)
  484. fatal_error("path variable creation failed.");
  485. fprintf(menuglobal, "source \"%s\"\n", path);
  486. /* recreating file is faster than truncating with w+ */
  487. unlink(path);
  488. cfg = fopen(path, "w");
  489. if (cfg == NULL)
  490. continue;
  491. pkgs = NULL;
  492. if (pkg_subpkgs != NULL)
  493. pkgs = strdup(pkg_subpkgs);
  494. fprintf(cfg, "config ADK_COMPILE_%s\n", toupperstr(pkgdirp->d_name));
  495. fprintf(cfg, "\ttristate\n");
  496. if (nobinpkgs == 0) {
  497. fprintf(cfg, "\tdepends on ");
  498. if (pkgs != NULL) {
  499. if (pkg_multi != NULL)
  500. if (strncmp(pkg_multi, "1", 1) == 0)
  501. fprintf(cfg, "ADK_HAVE_DOT_CONFIG || ");
  502. token = strtok(pkgs, " ");
  503. fprintf(cfg, "ADK_PACKAGE_%s", token);
  504. token = strtok(NULL, " ");
  505. while (token != NULL) {
  506. fprintf(cfg, " || ADK_PACKAGE_%s", token);
  507. token = strtok(NULL, " ");
  508. }
  509. fprintf(cfg, "\n");
  510. } else {
  511. fprintf(cfg, "ADK_PACKAGE_%s\n", toupperstr(pkg_name));
  512. }
  513. }
  514. fprintf(cfg, "\tdefault n\n");
  515. fclose(cfg);
  516. free(pkgs);
  517. /* skip packages without binary package output */
  518. if (nobinpkgs == 1)
  519. continue;
  520. /* generate binary package specific Config.in files */
  521. if (pkg_subpkgs != NULL)
  522. packages = tolowerstr(pkg_subpkgs);
  523. else
  524. packages = strdup(pkg_name);
  525. token = strtok_r(packages, " ", &p_ptr);
  526. while (token != NULL) {
  527. strncat(hkey, "PKGSC_", 6);
  528. strncat(hkey, toupperstr(token), strlen(token));
  529. memset(hvalue, 0 , MAXVALUE);
  530. result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  531. memset(hkey, 0 , MAXVAR);
  532. if (result == 1)
  533. pkg_section = strdup(hvalue);
  534. strncat(hkey, "PKGSD_", 6);
  535. strncat(hkey, toupperstr(token), strlen(token));
  536. memset(hvalue, 0 , MAXVALUE);
  537. result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  538. memset(hkey, 0 , MAXVAR);
  539. if (result == 1)
  540. pkg_descr = strdup(hvalue);
  541. pseudo_name = malloc(MAXLINE);
  542. memset(pseudo_name, 0, MAXLINE);
  543. strncat(pseudo_name, token, strlen(token));
  544. while (strlen(pseudo_name) < 20)
  545. strncat(pseudo_name, ".", 1);
  546. if (snprintf(path, MAXPATH, "package/pkgconfigs.d/%s/Config.in.%s", pkgdirp->d_name, token) < 0)
  547. fatal_error("failed to create path variable.");
  548. /* create temporary section files */
  549. memset(hvalue, 0 , MAXVALUE);
  550. result = strmap_get(sectionmap, pkg_section, hvalue, sizeof(hvalue));
  551. if (result == 1) {
  552. if (snprintf(spath, MAXPATH, "package/pkglist.d/sectionlst.%d", hash_str(hvalue)) < 0)
  553. fatal_error("failed to create path variable.");
  554. section = fopen(spath, "a");
  555. if (section != NULL) {
  556. fprintf(section, "%s |%s\n", token, pkgdirp->d_name);
  557. fclose(section);
  558. }
  559. } else
  560. fatal_error("Can not find section description for package %s.", pkgdirp->d_name);
  561. unlink(path);
  562. cfg = fopen(path, "w");
  563. if (cfg == NULL)
  564. perror("Can not open Config.in file");
  565. if (pkg_need_cxx != NULL) {
  566. fprintf(cfg, "comment \"%s... %s (disabled, c++ missing)\"\n", token, pkg_descr);
  567. fprintf(cfg, "depends on !ADK_TOOLCHAIN_GCC_CXX\n\n");
  568. }
  569. fprintf(cfg, "config ADK_PACKAGE_%s\n", toupperstr(token));
  570. /* no prompt for devonly packages */
  571. if (pkg_opts != NULL) {
  572. if (strstr(pkg_opts, "devonly") != NULL) {
  573. fprintf(cfg, "\t#prompt \"%s. %s\"\n", pseudo_name, pkg_descr);
  574. } else {
  575. fprintf(cfg, "\tprompt \"%s. %s\"\n", pseudo_name, pkg_descr);
  576. }
  577. } else {
  578. fprintf(cfg, "\tprompt \"%s. %s\"\n", pseudo_name, pkg_descr);
  579. }
  580. fprintf(cfg, "\ttristate\n");
  581. if (pkg_multi != NULL)
  582. if (strncmp(pkg_multi, "1", 1) == 0)
  583. if (strncmp(toupperstr(token), toupperstr(pkgdirp->d_name), strlen(token)) != 0)
  584. fprintf(cfg, "\tdepends on ADK_PACKAGE_%s\n", toupperstr(pkgdirp->d_name));
  585. free(pseudo_name);
  586. /* print custom cf line */
  587. if (pkg_cfline != NULL) {
  588. cftoken = strtok_r(pkg_cfline, "@", &saveptr);
  589. while (cftoken != NULL) {
  590. fprintf(cfg, "\t%s\n", cftoken);
  591. cftoken = strtok_r(NULL, "@", &saveptr);
  592. }
  593. free(pkg_cfline);
  594. pkg_cfline = NULL;
  595. }
  596. /* add sub package dependencies */
  597. strncat(hkey, "PKGSS_", 6);
  598. strncat(hkey, toupperstr(token), strlen(token));
  599. memset(hvalue, 0, MAXVALUE);
  600. result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  601. if (result == 1) {
  602. val = strtok_r(hvalue, " ", &saveptr);
  603. while (val != NULL) {
  604. if (strncmp(val, "kmod", 4) == 0)
  605. fprintf(cfg, "\tselect ADK_KPACKAGE_%s\n", toupperstr(val));
  606. else
  607. fprintf(cfg, "\tselect ADK_PACKAGE_%s\n", toupperstr(val));
  608. val = strtok_r(NULL, " ", &saveptr);
  609. }
  610. }
  611. memset(hkey, 0, MAXVAR);
  612. /* create package target system dependency information */
  613. if (pkg_system_depends != NULL) {
  614. pkg_helper = strdup(pkg_system_depends);
  615. token = strtok(pkg_helper, " ");
  616. fprintf(cfg, "\tdepends on ");
  617. sp = "";
  618. while (token != NULL) {
  619. if(strncmp(token, "!", 1) == 0) {
  620. fprintf(cfg, "%s!ADK_TARGET_SYSTEM%s", sp, toupperstr(token));
  621. sp = " && ";
  622. } else {
  623. fprintf(cfg, "%sADK_TARGET_SYSTEM_%s", sp, toupperstr(token));
  624. sp = " || ";
  625. }
  626. token = strtok(NULL, " ");
  627. }
  628. fprintf(cfg, "\n");
  629. free(pkg_helper);
  630. pkg_helper = NULL;
  631. }
  632. /* create package host dependency information */
  633. if (pkg_host_depends != NULL) {
  634. pkg_helper = strdup(pkg_host_depends);
  635. token = strtok(pkg_helper, " ");
  636. fprintf(cfg, "\tdepends on ");
  637. sp = "";
  638. while (token != NULL) {
  639. if(strncmp(token, "!", 1) == 0) {
  640. fprintf(cfg, "%s!ADK_HOST%s", sp, toupperstr(token));
  641. sp = " && ";
  642. } else {
  643. fprintf(cfg, "%sADK_HOST_%s", sp, toupperstr(token));
  644. sp = " || ";
  645. }
  646. token = strtok(NULL, " ");
  647. }
  648. fprintf(cfg, "\n");
  649. free(pkg_helper);
  650. pkg_helper = NULL;
  651. }
  652. /* create package libc dependency information */
  653. if (pkg_libc_depends != NULL) {
  654. pkg_helper = strdup(pkg_libc_depends);
  655. token = strtok(pkg_helper, " ");
  656. fprintf(cfg, "\tdepends on ");
  657. sp = "";
  658. while (token != NULL) {
  659. if(strncmp(token, "!", 1) == 0) {
  660. fprintf(cfg, "%s!ADK_TARGET_LIB_%s", sp, toupperstr(token));
  661. sp = " && ";
  662. } else {
  663. fprintf(cfg, "%sADK_TARGET_LIB_%s", sp, toupperstr(token));
  664. sp = " || ";
  665. }
  666. token = strtok(NULL, " ");
  667. }
  668. fprintf(cfg, "\n");
  669. free(pkg_helper);
  670. pkg_helper = NULL;
  671. }
  672. /* create package target architecture dependency information */
  673. if (pkg_arch_depends != NULL) {
  674. pkg_helper = strdup(pkg_arch_depends);
  675. token = strtok(pkg_helper, " ");
  676. fprintf(cfg, "\tdepends on ");
  677. sp = "";
  678. while (token != NULL) {
  679. if(strncmp(token, "!", 1) == 0) {
  680. fprintf(cfg, "%s!ADK_LINUX%s", sp, toupperstr(token));
  681. sp = " && ";
  682. } else {
  683. fprintf(cfg, "%sADK_LINUX_%s", sp, toupperstr(token));
  684. sp = " || ";
  685. }
  686. token = strtok(NULL, " ");
  687. }
  688. fprintf(cfg, "\n");
  689. free(pkg_helper);
  690. pkg_helper = NULL;
  691. }
  692. /* create package dependency information */
  693. if (pkg_depends != NULL) {
  694. token = strtok(pkg_depends, " ");
  695. while (token != NULL) {
  696. if (strncmp(token, "kmod", 4) == 0)
  697. fprintf(cfg, "\tselect ADK_KPACKAGE_%s\n", toupperstr(token));
  698. else
  699. fprintf(cfg, "\tselect ADK_PACKAGE_%s\n", toupperstr(token));
  700. token = strtok(NULL, " ");
  701. }
  702. free(pkg_depends);
  703. pkg_depends = NULL;
  704. }
  705. if (pkg_need_cxx != NULL) {
  706. fprintf(cfg, "\tdepends on ADK_TOOLCHAIN_GCC_CXX\n");
  707. }
  708. if (pkg_need_java != NULL) {
  709. fprintf(cfg, "\tdepends on ADK_TOOLCHAIN_GCC_JAVA\n");
  710. pkg_need_java = NULL;
  711. }
  712. fprintf(cfg, "\tselect ADK_COMPILE_%s\n", toupperstr(pkgdirp->d_name));
  713. if (pkg_dflt != NULL) {
  714. fprintf(cfg, "\tdefault %s\n", pkg_dflt);
  715. pkg_dflt = NULL;
  716. } else {
  717. fprintf(cfg, "\tdefault n\n");
  718. }
  719. fprintf(cfg, "\thelp\n");
  720. fprintf(cfg, "\t %s\n\n", pkg_descr);
  721. if (pkg_url != NULL)
  722. fprintf(cfg, "\t WWW: %s\n", pkg_url);
  723. /* handle special C++ packages */
  724. if (pkg_cxx != NULL) {
  725. fprintf(cfg, "\nchoice\n");
  726. fprintf(cfg, "prompt \"C++ library to use\"\n");
  727. fprintf(cfg, "depends on ADK_COMPILE_%s\n\n", toupperstr(pkgdirp->d_name));
  728. fprintf(cfg, "default ADK_COMPILE_%s_WITH_STDCXX if ADK_TARGET_LIB_GLIBC || ADK_TARGET_LIB_EGLIBC\n", pkg_cxx);
  729. fprintf(cfg, "default ADK_COMPILE_%s_WITH_UCLIBCXX if ADK_TARGET_LIB_UCLIBC\n\n", pkg_cxx);
  730. fprintf(cfg, "config ADK_COMPILE_%s_WITH_STDCXX\n", pkg_cxx);
  731. fprintf(cfg, "\tbool \"GNU C++ library\"\n");
  732. fprintf(cfg, "\tselect ADK_PACKAGE_LIBSTDCXX\n\n");
  733. fprintf(cfg, "config ADK_COMPILE_%s_WITH_UCLIBCXX\n", pkg_cxx);
  734. fprintf(cfg, "\tbool \"uClibc++ library\"\n");
  735. fprintf(cfg, "\tselect ADK_PACKAGE_UCLIBCXX\n\n");
  736. fprintf(cfg, "endchoice\n");
  737. free(pkg_cxx);
  738. pkg_cxx = NULL;
  739. }
  740. /* package flavours */
  741. if (pkg_flavours != NULL) {
  742. token = strtok(pkg_flavours, " ");
  743. while (token != NULL) {
  744. fprintf(cfg, "\nconfig ADK_PACKAGE_%s_%s\n", pkgname, toupperstr(token));
  745. // process default value
  746. strncat(hkey, "PKGFX_", 6);
  747. strncat(hkey, token, strlen(token));
  748. memset(hvalue, 0 , MAXVALUE);
  749. strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  750. memset(hkey, 0 , MAXVAR);
  751. pkg_fd = strdup(hvalue);
  752. if (strlen(pkg_fd) > 0)
  753. fprintf(cfg, "\tdefault %s\n", pkg_fd);
  754. else
  755. fprintf(cfg, "\tdefault n\n");
  756. // process flavour cfline
  757. strncat(hkey, "PKGFC_", 6);
  758. strncat(hkey, token, strlen(token));
  759. memset(hvalue, 0 , MAXVALUE);
  760. strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  761. memset(hkey, 0 , MAXVAR);
  762. pkg_fd = strdup(hvalue);
  763. if (strlen(pkg_fd) > 0)
  764. fprintf(cfg, "\t%s\n", pkg_fd);
  765. fprintf(cfg, "\tboolean ");
  766. strncat(hkey, "PKGFD_", 6);
  767. strncat(hkey, token, strlen(token));
  768. memset(hvalue, 0 , MAXVALUE);
  769. strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  770. memset(hkey, 0 , MAXVAR);
  771. pkg_fd = strdup(hvalue);
  772. fprintf(cfg, "\"%s\"\n", pkg_fd);
  773. fprintf(cfg, "\tdepends on ADK_PACKAGE_%s\n", pkgname);
  774. strncat(hkey, "PKGFS_", 6);
  775. strncat(hkey, token, strlen(token));
  776. result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  777. if (result == 1) {
  778. val = strtok_r(hvalue, " ", &saveptr);
  779. while (val != NULL) {
  780. if (strncmp(val, "kmod", 4) == 0)
  781. fprintf(cfg, "\tselect ADK_KPACKAGE_%s\n", toupperstr(val));
  782. else
  783. fprintf(cfg, "\tselect ADK_PACKAGE_%s\n", toupperstr(val));
  784. val = strtok_r(NULL, " ", &saveptr);
  785. }
  786. }
  787. memset(hkey, 0, MAXVAR);
  788. fprintf(cfg, "\thelp\n");
  789. fprintf(cfg, "\t %s\n", pkg_fd);
  790. token = strtok(NULL, " ");
  791. }
  792. free(pkg_flavours);
  793. pkg_flavours = NULL;
  794. }
  795. /* package flavours string */
  796. if (pkg_flavours_string != NULL) {
  797. token = strtok(pkg_flavours_string, " ");
  798. while (token != NULL) {
  799. fprintf(cfg, "\nconfig ADK_PACKAGE_%s_%s\n", pkgname, toupperstr(token));
  800. // process default value
  801. strncat(hkey, "PKGFX_", 6);
  802. strncat(hkey, token, strlen(token));
  803. memset(hvalue, 0 , MAXVALUE);
  804. strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  805. memset(hkey, 0 , MAXVAR);
  806. pkg_fd = strdup(hvalue);
  807. if (strlen(pkg_fd) > 0)
  808. fprintf(cfg, "\tdefault \"%s\"\n", pkg_fd);
  809. // process flavour cfline
  810. strncat(hkey, "PKGFC_", 6);
  811. strncat(hkey, token, strlen(token));
  812. memset(hvalue, 0 , MAXVALUE);
  813. strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  814. memset(hkey, 0 , MAXVAR);
  815. pkg_fd = strdup(hvalue);
  816. if (strlen(pkg_fd) > 0)
  817. fprintf(cfg, "\t%s\n", pkg_fd);
  818. fprintf(cfg, "\tstring ");
  819. strncat(hkey, "PKGFD_", 6);
  820. strncat(hkey, token, strlen(token));
  821. memset(hvalue, 0 , MAXVALUE);
  822. strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  823. memset(hkey, 0 , MAXVAR);
  824. pkg_fd = strdup(hvalue);
  825. fprintf(cfg, "\"%s\"\n", pkg_fd);
  826. fprintf(cfg, "\tdepends on ADK_PACKAGE_%s\n", pkgname);
  827. strncat(hkey, "PKGFS_", 6);
  828. strncat(hkey, token, strlen(token));
  829. result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  830. if (result == 1) {
  831. val = strtok_r(hvalue, " ", &saveptr);
  832. while (val != NULL) {
  833. if (strncmp(val, "kmod", 4) == 0)
  834. fprintf(cfg, "\tselect ADK_KPACKAGE_%s\n", toupperstr(val));
  835. else
  836. fprintf(cfg, "\tselect ADK_PACKAGE_%s\n", toupperstr(val));
  837. val = strtok_r(NULL, " ", &saveptr);
  838. }
  839. }
  840. memset(hkey, 0, MAXVAR);
  841. fprintf(cfg, "\thelp\n");
  842. fprintf(cfg, "\t %s\n", pkg_fd);
  843. token = strtok(NULL, " ");
  844. }
  845. free(pkg_flavours_string);
  846. pkg_flavours_string = NULL;
  847. }
  848. /* package choices */
  849. if (pkg_choices != NULL) {
  850. fprintf(cfg, "\nchoice\n");
  851. fprintf(cfg, "prompt \"Package flavour choice\"\n");
  852. fprintf(cfg, "depends on ADK_PACKAGE_%s\n\n", pkgname);
  853. token = strtok(pkg_choices, " ");
  854. while (token != NULL) {
  855. fprintf(cfg, "config ADK_PACKAGE_%s_%s\n", pkgname, toupperstr(token));
  856. fprintf(cfg, "\tbool ");
  857. strncat(hkey, "PKGCD_", 6);
  858. strncat(hkey, token, strlen(token));
  859. memset(hvalue, 0 , MAXVALUE);
  860. strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  861. memset(hkey, 0 , MAXVAR);
  862. fprintf(cfg, "\"%s\"\n", hvalue);
  863. strncat(hkey, "PKGCS_", 6);
  864. strncat(hkey, token, strlen(token));
  865. memset(hvalue, 0, MAXVALUE);
  866. result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue));
  867. if (result == 1) {
  868. val = strtok_r(hvalue, " ", &saveptr);
  869. while (val != NULL) {
  870. if (strncmp(val, "kmod", 4) == 0)
  871. fprintf(cfg, "\tselect ADK_KPACKAGE_%s\n", toupperstr(val));
  872. else
  873. fprintf(cfg, "\tselect ADK_PACKAGE_%s\n", toupperstr(val));
  874. val = strtok_r(NULL, " ", &saveptr);
  875. }
  876. }
  877. memset(hkey, 0, MAXVAR);
  878. token = strtok(NULL, " ");
  879. }
  880. fprintf(cfg, "\nendchoice\n");
  881. free(pkg_choices);
  882. pkg_choices = NULL;
  883. }
  884. /* close file descriptor for Config.in file */
  885. fclose(cfg);
  886. /* create Config.in files for development packages */
  887. if (pkg_opts != NULL) {
  888. if (strstr(pkg_opts, "dev") != NULL) {
  889. if (snprintf(path, MAXPATH, "package/pkgconfigs.d/gcc/Config.in.dev") < 0)
  890. fatal_error("failed to create path variable.");
  891. cfg = fopen(path, "a");
  892. if (cfg == NULL)
  893. perror("Can not open Config.in.dev file");
  894. if (pkg_libname == NULL)
  895. pkg_libname = strdup(pkg_name);
  896. fprintf(cfg, "\n");
  897. fprintf(cfg, "config ADK_PACKAGE_%s_DEV\n", toupperstr(pkg_libname));
  898. pseudo_name = malloc(MAXLINE);
  899. memset(pseudo_name, 0, MAXLINE);
  900. strncat(pseudo_name, pkg_libname, strlen(pkg_libname));
  901. strncat(pseudo_name, "-dev", 4);
  902. while (strlen(pseudo_name) < 20)
  903. strncat(pseudo_name, ".", 1);
  904. fprintf(cfg, "\tprompt \"%s. development files for %s\"\n", pseudo_name, pkg_libname);
  905. fprintf(cfg, "\ttristate\n");
  906. /* create package target architecture dependency information */
  907. if (pkg_arch_depends != NULL) {
  908. pkg_helper = strdup(pkg_arch_depends);
  909. token = strtok(pkg_helper, " ");
  910. fprintf(cfg, "\tdepends on ");
  911. sp = "";
  912. while (token != NULL) {
  913. if(strncmp(token, "!", 1) == 0) {
  914. fprintf(cfg, "%s!ADK_LINUX%s", sp, toupperstr(token));
  915. sp = " && ";
  916. } else {
  917. fprintf(cfg, "%sADK_LINUX_%s", sp, toupperstr(token));
  918. sp = " || ";
  919. }
  920. token = strtok(NULL, " ");
  921. }
  922. fprintf(cfg, "\n");
  923. free(pkg_helper);
  924. pkg_helper = NULL;
  925. }
  926. fprintf(cfg, "\tdepends on ADK_PACKAGE_GCC\n");
  927. fprintf(cfg, "\tselect ADK_PACKAGE_%s\n", toupperstr(pkg_libname));
  928. fprintf(cfg, "\tdefault n\n");
  929. fclose(cfg);
  930. free(pseudo_name);
  931. free(pkg_libname);
  932. pkg_libname = NULL;
  933. }
  934. pkg_opts = NULL;
  935. }
  936. /* parse next package */
  937. token = strtok_r(NULL, " ", &p_ptr);
  938. }
  939. /* end of package output generation */
  940. free(packages);
  941. packages = NULL;
  942. pkg_need_cxx = NULL;
  943. pkg_need_java = NULL;
  944. /* reset flags, free memory */
  945. free(pkg_name);
  946. free(pkg_descr);
  947. free(pkg_section);
  948. free(pkg_url);
  949. free(pkg_depends);
  950. free(pkg_flavours);
  951. free(pkg_flavours_string);
  952. free(pkg_choices);
  953. free(pkg_subpkgs);
  954. free(pkg_arch_depends);
  955. free(pkg_system_depends);
  956. free(pkg_host_depends);
  957. free(pkg_libc_depends);
  958. free(pkg_cxx);
  959. free(pkg_dflt);
  960. free(pkg_cfline);
  961. free(pkg_multi);
  962. pkg_name = NULL;
  963. pkg_descr = NULL;
  964. pkg_section = NULL;
  965. pkg_url = NULL;
  966. pkg_depends = NULL;
  967. pkg_flavours = NULL;
  968. pkg_flavours_string = NULL;
  969. pkg_choices = NULL;
  970. pkg_subpkgs = NULL;
  971. pkg_arch_depends = NULL;
  972. pkg_system_depends = NULL;
  973. pkg_host_depends = NULL;
  974. pkg_libc_depends = NULL;
  975. pkg_cxx = NULL;
  976. pkg_dflt = NULL;
  977. pkg_cfline = NULL;
  978. pkg_multi = NULL;
  979. strmap_delete(pkgmap);
  980. nobinpkgs = 0;
  981. free(hkey);
  982. }
  983. }
  984. /* add menu to gcc package */
  985. if (snprintf(path, MAXPATH, "package/pkgconfigs.d/gcc/Config.in.gcc") < 0)
  986. fatal_error("failed to create path variable.");
  987. cfg = fopen(path, "a");
  988. if (cfg == NULL)
  989. perror("Can not open Config.in.gcc file");
  990. fprintf(cfg, "menu \"Development packages\"\n");
  991. fprintf(cfg, "depends on ADK_PACKAGE_GCC\n");
  992. fprintf(cfg, "source \"package/pkgconfigs.d/gcc/Config.in.dev\"\n");
  993. fprintf(cfg, "endmenu\n");
  994. fclose(cfg);
  995. /* create Config.in.auto */
  996. strmap_enum(sectionmap, iter, NULL);
  997. strmap_delete(sectionmap);
  998. fclose(menuglobal);
  999. closedir(pkgdir);
  1000. /* remove temporary section files */
  1001. pkglistdir = opendir("package/pkglist.d");
  1002. while ((pkgdirp = readdir(pkglistdir)) != NULL) {
  1003. if (strncmp(pkgdirp->d_name, "sectionlst.", 11) == 0) {
  1004. if (snprintf(path, MAXPATH, "package/pkglist.d/%s", pkgdirp->d_name) < 0)
  1005. fatal_error("creating path variable failed.");
  1006. if (unlink(path) < 0)
  1007. fatal_error("removing file failed.");
  1008. }
  1009. }
  1010. closedir(pkglistdir);
  1011. return(0);
  1012. }