-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add amove #92
feat: add amove #92
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return error instead of silently do nothing
In general, i have been hesitant to add functions like this, because I want keep it easy to understand what is going on when you read the APKBUILDs. I don't want end up as gentoo with a ton of magic functions and you have no clue of what is actually going on behind the scene. However, we have grown much and we need to make maintenance easier, and I think this will do so. But we should probably think, what other |
I would say it should be a matter of how common something is. |
So is there anything left/needed to do here? |
Looks good to me. Just need the big penguin to approve. |
I'm not sure I like the API. Wouldn't it be nicer with: amove 'usr/lib/libfoo.so.*' Something like: amove() {
local subdir=${1%/*} # directory part
local fpattern=${1##*/} # pattern
...
cd "$pkgdir"
 mkdir -p "$subpkgdir/$subdir"
 find "$subdir" ! -path "$subdir" -prune ! -type d -name "$fpattern" \
 -exec mv '{}' "$subpkgdir/$subdir/" \;
 ...
}
But we may want be able to move dirs too: |
I have doubts about the API. What do you think about having a single arg only, but takes a pattern: amove() {
...
cd "$pkgdir"
local f
for f in $1; do
# only create dir if needed
if [ "${f%/*}" != "$f" ]; then
mkdir -p "$subpkgdir/${f%/*}"
fi
mv "$pkgdir"/$f "$subpkgdir/${f%/*}"
done
...
} then we can do things like: amove 'usr/lib/libfoo.so.*'
amove 'usr/lib/python3*' That way we don't need to have the second option variant at all. |
I'm not sure why the API is suddenly a problem a whole half year after the design phase, and almost 3 months into the review. If you just don't want to merge this, you can just say so and close it. |
It would be great if you could dig up the tests. What are the cornercases that you are trying to handle?
What I'm thinking is that instead of having the function take one or two options, it only takes one:
It handles the cornercase when there are no
Sorry for taking long time. It took me a while to think if we want this in the first place and I concluded that we do. But I want sure that we do it the best possible way, because once this is introduced, it may be difficult or impossible to change the behavior. So I want make sure its done right. And I am not convinced that two different behavior depending on the number of arguments is the best way to handle this. I believe we can cover all our needs with only one arg. |
Okay.
I believe this is a case of misunderstanding semantics - the behavior is (from the user's perspective) the same.
I did in fact manage to find them - https://minio.toast.cafe/shared/amove-tests.tgz
.a files are a significant one, but see the tests for further details.
I think this has a couple of downsides:
As it is now, it's the "simplest possible building block" with as few side-effects as possible.
When I have time (likely later today) I'll expand the test suite and correct anything needed, posting a new comment. |
Amove is a utility function for subpackage splitting. It takes up to 2 arguments: $1 is a relative directory (or file) (/ is dropped if present) $2 is a regex-like format, as taken by find(1p)/-name If only $1 is specified, it will move $1 from pkgdir to subpkgdir, creating what is needed and cleaning up after itself appropriately. If $2 is specified, $1 should be a directory (not checked - unneeded). When $2 is specified and $1 is a directory, all files directly inside of $1 that match the $2 namespec will be copied instead.
This was actually the original mode of operation. Using non-relative directories (e.g I also updated the test suite to check sanity re: |
Thanks for the test suite! I have played around with the tests and with the amove function. My conclusion is that it should be:
That way we can do things like:
If user actually wants
|
moving files and directories from $pkgdir to $subpkgdir is a common pattern, so make a helper function for this. usage: amove FILESPEC... FILESPEC is a list of files or patterns/globs that will be exanded by the shell. amove will clean up empty directories after moving the files/dirs. Example usage: amove 'usr/lib/lib*.a' amove 'etc/*.d' # moves both etc/conf.d and etc/init.d amove 'lib/*.so' 'usr/lib/*.so' cd "$pkgdir" find usr -name '*.h' | xargs amove This is based on the work of Chloe Kudryavtsev: #92
This was fixed with aa86438. Thank you for your work on this, and thank you for your patience. |
Amove is a utility function for subpackage splitting.
It takes up to 2 arguments:
$1 is a relative directory (or file)
$2 (optional) is a regex-like format, as taken by find(1p)/-name
If only $1 is specified, it will move $1 from pkgdir to subpkgdir,
creating what is needed and cleaning up after itself appropriately.
If $2 is specified, $1 should be a directory (not checked - unneeded).
When $2 is specified and $1 is a directory, all files directly inside of
$1 that match the $2 namespec will be copied instead.