X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm-add.c;h=86b289d9748d836aff391c7ef4f32f6f3d20bb4c;hb=4b448fbc77510c589cc7f367c05bef63acc07858;hp=8896e800511856af65b30740ccdda540967e9628;hpb=c791f82faa7e8ce6e2d391cedc50b273b42599ef;p=zpackage diff --git a/zpm-add.c b/zpm-add.c index 8896e80..86b289d 100644 --- a/zpm-add.c +++ b/zpm-add.c @@ -21,6 +21,7 @@ struct opts { int complete, addcontent, isconfig, opt_l, recursive, verbose; int followsymlinks; int xargs, noclear; + int striparg; mode_t clmode; char *cltype, *clhash, *clmtime, *prefix, *strip, *cltarget; @@ -199,6 +200,7 @@ int stat_file(struct zpm_file *file, char *path, struct opts *opt) { if (n >= sizeof linkval) { return 0; } + linkval[n] = 0; file->target = strdup(linkval); } } @@ -211,9 +213,9 @@ int stat_file(struct zpm_file *file, char *path, struct opts *opt) { } if (opt->clmode) { - file->mode = opt->clmode; + file->mode = opt->clmode & 07777; } else { - file->mode = st.st_mode; + file->mode = st.st_mode & 07777; } if (opt->cluser) { @@ -399,6 +401,7 @@ int main(int ac, char **av) { case 'N': opt.addcontent = 0; break; case 'P': opt.prefix = optarg; break; case 'S': opt.strip = optarg; break; + case 's': opt.striparg = 1; break; case 'T': opt.cltarget = optarg; break; case 'c': opt.isconfig = 1; break; case 'f': dbfile = optarg; break; @@ -437,7 +440,6 @@ int main(int ac, char **av) { char *pkgid; pkgstr = av[optind++]; pkgid = zpm_findpkg(&zpm, pkgstr, NULL); - /* TODO if not found, error */ if (!pkgid) { die("package %s not found\n", pkgstr); } @@ -464,6 +466,10 @@ int main(int ac, char **av) { die("can't stat %s: %s", av[i], strerror(errno)); } file.data = av[i]; + if (opt.striparg) { + opt.strip = av[i]; + } + if (add_file(&zpm, &file, &opt)) { free_file(&file); } else {