diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-28 18:13:48 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-28 18:13:48 -0500 |
commit | 96faec945f39cab38403f60f515bff43660b4dab (patch) | |
tree | e6681330a42303bb34be80d347cd01ff79f5b80a /usr/gen_init_cpio.c | |
parent | 2926328554fa740518e2a6585b2cefb01e5f65f3 (diff) | |
parent | 9bb482476c6c9d1ae033306440c51ceac93ea80c (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-next
* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-next: (25 commits)
allow stripping of generated symbols under CONFIG_KALLSYMS_ALL
kbuild: strip generated symbols from *.ko
kbuild: simplify use of genksyms
kernel-doc: check for extra kernel-doc notations
kbuild: add headerdep used to detect inclusion cycles in header files
kbuild: fix string equality testing in tags.sh
kbuild: fix make tags/cscope
kbuild: fix make incompatibility
kbuild: remove TAR_IGNORE
setlocalversion: add git-svn support
setlocalversion: print correct subversion revision
scripts: improve the decodecode script
scripts/package: allow custom options to rpm
genksyms: allow to ignore symbol checksum changes
genksyms: track symbol checksum changes
tags and cscope support really belongs in a shell script
kconfig: fix options to check-lxdialog.sh
kbuild: gen_init_cpio expands shell variables in file names
remove bashisms from scripts/extract-ikconfig
kbuild: teach mkmakfile to be silent
...
Diffstat (limited to 'usr/gen_init_cpio.c')
-rw-r--r-- | usr/gen_init_cpio.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c index 7abc07f0fcd2..f1d3fe34176a 100644 --- a/usr/gen_init_cpio.c +++ b/usr/gen_init_cpio.c | |||
@@ -370,6 +370,30 @@ error: | |||
370 | return rc; | 370 | return rc; |
371 | } | 371 | } |
372 | 372 | ||
373 | static char *cpio_replace_env(char *new_location) | ||
374 | { | ||
375 | char expanded[PATH_MAX + 1]; | ||
376 | char env_var[PATH_MAX + 1]; | ||
377 | char *start; | ||
378 | char *end; | ||
379 | |||
380 | for (start = NULL; (start = strstr(new_location, "${")); ) { | ||
381 | end = strchr(start, '}'); | ||
382 | if (start < end) { | ||
383 | *env_var = *expanded = '\0'; | ||
384 | strncat(env_var, start + 2, end - start - 2); | ||
385 | strncat(expanded, new_location, start - new_location); | ||
386 | strncat(expanded, getenv(env_var), PATH_MAX); | ||
387 | strncat(expanded, end + 1, PATH_MAX); | ||
388 | strncpy(new_location, expanded, PATH_MAX); | ||
389 | } else | ||
390 | break; | ||
391 | } | ||
392 | |||
393 | return new_location; | ||
394 | } | ||
395 | |||
396 | |||
373 | static int cpio_mkfile_line(const char *line) | 397 | static int cpio_mkfile_line(const char *line) |
374 | { | 398 | { |
375 | char name[PATH_MAX + 1]; | 399 | char name[PATH_MAX + 1]; |
@@ -415,7 +439,8 @@ static int cpio_mkfile_line(const char *line) | |||
415 | } else { | 439 | } else { |
416 | dname = name; | 440 | dname = name; |
417 | } | 441 | } |
418 | rc = cpio_mkfile(dname, location, mode, uid, gid, nlinks); | 442 | rc = cpio_mkfile(dname, cpio_replace_env(location), |
443 | mode, uid, gid, nlinks); | ||
419 | fail: | 444 | fail: |
420 | if (dname_len) free(dname); | 445 | if (dname_len) free(dname); |
421 | return rc; | 446 | return rc; |
@@ -439,6 +464,7 @@ void usage(const char *prog) | |||
439 | "\n" | 464 | "\n" |
440 | "<name> name of the file/dir/nod/etc in the archive\n" | 465 | "<name> name of the file/dir/nod/etc in the archive\n" |
441 | "<location> location of the file in the current filesystem\n" | 466 | "<location> location of the file in the current filesystem\n" |
467 | " expands shell variables quoted with ${}\n" | ||
442 | "<target> link target\n" | 468 | "<target> link target\n" |
443 | "<mode> mode/permissions of the file\n" | 469 | "<mode> mode/permissions of the file\n" |
444 | "<uid> user id (0=root)\n" | 470 | "<uid> user id (0=root)\n" |