Linux "install" command for wildcard installation
Is there a way to use "install" for installing multiple files at once using a "wildcard" pattern (and still have "install" create the leading directory hierarchy)?
I've tried several different ways:
install -D -t /dest/path /source/path/*.py
install -D -t /dest/path/ /source/path/*.py
install开发者_如何转开发 -D /source/path/*.py /dest/path
install -D /source/path/*.py /dest/path/
Please help... for each trial it takes a lot of time (I am using pbuilder
to test my package each time).
Use the following to create the directory hierarchy, before installing:
install -d /dest/path
and then use:
install -D /source/path/*.py /dest/path
to "install" all the files.
Maybe use a simple outer for loop around the install call? So how about
for f in /source/path/*.py; do \
install -D -t /dest/path $$f; \
done
That said, you can always take the logic out of your Makefile, debian/rules file, ... and test it standalone without having to run pbuilder
.
Otherwise of course props for using pbuilder
for internal projects!
I don't know anything about pbuilder, but for my case (PKGBUILD for Arch Linux) I'm using a BASH for-loop with find:
for file in $(find source -type f -name *.py); do
install -m 644 -D ${file} dest/${file#source/}
done
The find command can be suited to taste to be more or less specific about what gets copied. In the above example all regular files ending in .py anywhere below source/ would be selected.
Okay, maybe I'm reviving an old post, but I think it's worth for future research. From the example given by nharward (I also use arch linux and PKGBUILD), I modified so that I did not have to worry about the mode/permissions (-m) of the file, regardless of the directory structure.
for file in $(find ${srcdir} -type f); do
install -m $(stat -c%a ${file}) -D ${file} ${pkgdir}/${file#${srcdir}}
done
man install shows that the DEST must be existing if copy multiple files.
... In the first three forms, copy SOURCE to DEST or multiple SOURCE(s) to the existing DIRECTORY, while setting permission modes and owner/group. In the 4th form, create all components of the given DIRECTORY(ies). ...
精彩评论