diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-28 15:13:48 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-28 15:13:48 -0800 |
commit | 96faec945f39cab38403f60f515bff43660b4dab (patch) | |
tree | e6681330a42303bb34be80d347cd01ff79f5b80a /usr | |
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')
-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: return rc; } +static char *cpio_replace_env(char *new_location) +{ + char expanded[PATH_MAX + 1]; + char env_var[PATH_MAX + 1]; + char *start; + char *end; + + for (start = NULL; (start = strstr(new_location, "${")); ) { + end = strchr(start, '}'); + if (start < end) { + *env_var = *expanded = '\0'; + strncat(env_var, start + 2, end - start - 2); + strncat(expanded, new_location, start - new_location); + strncat(expanded, getenv(env_var), PATH_MAX); + strncat(expanded, end + 1, PATH_MAX); + strncpy(new_location, expanded, PATH_MAX); + } else + break; + } + + return new_location; +} + + static int cpio_mkfile_line(const char *line) { char name[PATH_MAX + 1]; @@ -415,7 +439,8 @@ static int cpio_mkfile_line(const char *line) } else { dname = name; } - rc = cpio_mkfile(dname, location, mode, uid, gid, nlinks); + rc = cpio_mkfile(dname, cpio_replace_env(location), + mode, uid, gid, nlinks); fail: if (dname_len) free(dname); return rc; @@ -439,6 +464,7 @@ void usage(const char *prog) "\n" "<name> name of the file/dir/nod/etc in the archive\n" "<location> location of the file in the current filesystem\n" + " expands shell variables quoted with ${}\n" "<target> link target\n" "<mode> mode/permissions of the file\n" "<uid> user id (0=root)\n" |