summaryrefslogtreecommitdiff
path: root/adk/tools/pkgmaker.c
diff options
context:
space:
mode:
Diffstat (limited to 'adk/tools/pkgmaker.c')
-rw-r--r--adk/tools/pkgmaker.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/adk/tools/pkgmaker.c b/adk/tools/pkgmaker.c
index 451300548..e4306d7cc 100644
--- a/adk/tools/pkgmaker.c
+++ b/adk/tools/pkgmaker.c
@@ -19,6 +19,7 @@
#include <ctype.h>
#include <dirent.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
@@ -290,22 +291,44 @@ static char *tolowerstr(char *string) {
static char *toupperstr(char *string) {
+ static char *sdup = NULL;
+ static int sduplen = 0;
int i;
- char *str;
-
+
+ if (!string) {
+ free(sdup);
+ sduplen = 0;
+ return NULL;
+ }
+
+ if (sduplen <= strlen(string)) {
+ sduplen = strlen(string) + 1;
+ sdup = realloc(sdup, sduplen);
+ if (!sdup)
+ fatal_error("%s: memory allocation failed: %s\n",
+ __func__, strerror(errno));
+ }
+
/* transform to uppercase variable name */
- str = strdup(string);
- for (i=0; i<(int)strlen(str); i++) {
- if (str[i] == '+')
- str[i] = 'X';
- if (str[i] == '-')
- str[i] = '_';
- /* remove negation here, useful for package host depends */
- if (str[i] == '!')
- str[i] = '_';
- str[i] = toupper(str[i]);
+ for (i = 0; i < strlen(string) + 1; i++) {
+ switch (string[i]) {
+ case '+':
+ sdup[i] = 'X';
+ break;
+ case '-':
+ sdup[i] = '_';
+ break;
+ case '!':
+ sdup[i] = '_';
+ break;
+ case '\0':
+ sdup[i] = '\0';
+ break;
+ default:
+ sdup[i] = toupper(string[i]);
+ }
}
- return(str);
+ return sdup;
}
@@ -330,7 +353,7 @@ int main() {
char *pkg_name, *pkg_depends, *pkg_kdepends, *pkg_needs, *pkg_depends_system, *pkg_depends_libc, *pkg_section, *pkg_descr, *pkg_url;
char *pkg_subpkgs, *pkg_cfline, *pkg_dflt;
char *pkgname, *sysname, *pkg_debug, *pkg_bb;
- char *pkg_libc_depends, *pkg_host_depends, *pkg_system_depends, *pkg_arch_depends, *pkg_flavours, *pkg_flavours_string, *pkg_choices, *pseudo_name;
+ char *pkg_libc_depends, *pkg_system_depends, *pkg_arch_depends, *pkg_flavours, *pkg_flavours_string, *pkg_choices, *pseudo_name;
char *packages, *pkg_name_u, *pkgs, *pkg_opts, *pkg_libname;
char *saveptr, *p_ptr, *s_ptr, *pkg_helper, *sname, *sname2;
int result;
@@ -354,7 +377,6 @@ int main() {
pkg_subpkgs = NULL;
pkg_arch_depends = NULL;
pkg_system_depends = NULL;
- pkg_host_depends = NULL;
pkg_libc_depends = NULL;
pkg_dflt = NULL;
pkg_cfline = NULL;
@@ -463,10 +485,12 @@ int main() {
icfg = fopen(runtime, "a");
if (icfg == NULL)
continue;
- if (strncmp("busybox", sname, 7) == 0)
- fprintf(icfg, "config ADK_RUNTIME_START_%s_%s\n", toupperstr(sname), toupperstr(sname2));
- else
+ if (strncmp("busybox", sname, 7) == 0) {
+ fprintf(icfg, "config ADK_RUNTIME_START_%s", toupperstr(sname));
+ fprintf(icfg, "_%s\n", toupperstr(sname2));
+ } else {
fprintf(icfg, "config ADK_RUNTIME_START_%s\n", toupperstr(sname));
+ }
fprintf(icfg, "\tprompt \"Start %s on boot\"\n", sname2);
fprintf(icfg, "\ttristate\n");
if (strncmp("busybox", sname, 7) == 0)
@@ -549,8 +573,6 @@ int main() {
continue;
if ((parse_var(buf, "PKG_LIBC_DEPENDS", NULL, &pkg_libc_depends)) == 0)
continue;
- if ((parse_var(buf, "PKG_HOST_DEPENDS", NULL, &pkg_host_depends)) == 0)
- continue;
if ((parse_var(buf, "PKG_ARCH_DEPENDS", NULL, &pkg_arch_depends)) == 0)
continue;
if ((parse_var(buf, "PKG_SYSTEM_DEPENDS", NULL, &pkg_system_depends)) == 0)
@@ -813,7 +835,7 @@ int main() {
if (result == 1) {
val = strtok_r(hvalue, " ", &saveptr);
while (val != NULL) {
- fprintf(cfg, "\tselect ADK_KERNEL_%s\n", toupperstr(val));
+ fprintf(cfg, "\tselect ADK_LINUX_KERNEL_%s\n", toupperstr(val));
val = strtok_r(NULL, " ", &saveptr);
}
}
@@ -839,26 +861,6 @@ int main() {
free(pkg_helper);
pkg_helper = NULL;
}
- /* create package host dependency information */
- if (pkg_host_depends != NULL) {
- pkg_helper = strdup(pkg_host_depends);
- token = strtok(pkg_helper, " ");
- fprintf(cfg, "\tdepends on ");
- sp = "";
- while (token != NULL) {
- if(strncmp(token, "!", 1) == 0) {
- fprintf(cfg, "%s!ADK_HOST%s", sp, toupperstr(token));
- sp = " && ";
- } else {
- fprintf(cfg, "%sADK_HOST_%s", sp, toupperstr(token));
- sp = " || ";
- }
- token = strtok(NULL, " ");
- }
- fprintf(cfg, "\n");
- free(pkg_helper);
- pkg_helper = NULL;
- }
/* create package libc dependency information */
if (pkg_libc_depends != NULL) {
@@ -1223,7 +1225,6 @@ int main() {
free(pkg_subpkgs);
free(pkg_arch_depends);
free(pkg_system_depends);
- free(pkg_host_depends);
free(pkg_libc_depends);
free(pkg_dflt);
free(pkg_cfline);
@@ -1241,7 +1242,6 @@ int main() {
pkg_subpkgs = NULL;
pkg_arch_depends = NULL;
pkg_system_depends = NULL;
- pkg_host_depends = NULL;
pkg_libc_depends = NULL;
pkg_dflt = NULL;
pkg_cfline = NULL;
@@ -1282,6 +1282,7 @@ int main() {
fatal_error("removing file failed.");
}
}
+ toupperstr(NULL);
closedir(pkglistdir);
return(0);
}