By using sed's extended regular expression capability (-r) it is possible to do a slightly neater patch to removepkg to work with my patched makepkg:
Code:
--- removepkg.orig Code:
--- removepkg.orig |
Quote:
I tested the current regex against the one from my last example as follows: Code:
diff <(sed -n 's,^( *cd \([^ ;][^ ;]*\) *; *rm -rf \([^ )][^ )]*\) *) *$,\1/\2,p' /var/log/scripts/*) <(sed -n 's,^( *cd \([^;]*[!-~]\) *; *rm -rf \([^)]*[!-~]\) *) *$,\1/\2,p' /var/log/scripts/*) I also checked to see if there was a large speed difference between them but there isn't: Code:
$ time sed -n 's,^( *cd \([^ ;][^ ;]*\) *; *rm -rf \([^ )][^ )]*\) *) *$,\1/\2,p' /var/log/scripts/* >/dev/null Now I'll try and find a way to extensively test my suggested makepkg improvements and report back if I come up with something. EDIT: P.S. I also checked the extended regex variant. It works as well, though it is a little bit slower. |
Ok, I worked out a nice way of testing my makepkg changes against my 1271 installed packages. Firstly, I extracted out the code from the original/official makepkg that does the link display and shell script conversion and tweaked it just enough to make a short test script that looks as follows:
Code:
#!/bin/sh Code:
# time ./makepkg-test > original-test Code:
26c26 Code:
# time ./makepkg-test > updated-test The only other major consideration is that my updated version would have a problem if a package contained symlinks with "@@ARROW@@" or "@@SPACE@@" in their names, though IMHO this would be less likely than having spaces in the name. If this is a concern however, these keywords could be switched to something else. EDIT: P.S. If anyone is curious: Code:
$ wc -l updated-test |
While we're on this topic, we could also make use of:
Code:
echo "( cd -- $LINKGOESIN ; rm -rf -- $LINKNAMEIS )" |
Quote:
|
Quote:
That said, removepkg itself could probably accommodate the old way, with space escaping and TommyC7's proposal using a regex like this: Code:
s|^( *cd\( --\)\{,1\} \([^;]*[!-~]\) *; *rm -rf\( --\)\{,1\} \([^)]*[!-~]\) *) *$|\2/\4|p |
Ah poo. :(
|
Quote:
Code:
--- makepkg.orig When converting large numbers of links, this is indeed many times faster. EDIT: I recreated the ./makepkg-test experiment from above and this time I was able to complete the conversion of 16548 symlinks (from 1271 packages) in 1.4 seconds, while the old make_install_script function takes around 10 minutes. I also diff'ed the output created by both methods and it is identical. EDIT: removed the regex 's,^./,,' because it is possible to achieve the same with 'find *', instead of 'find .' |
Thanks ruario... i applied the following patches based on your suggestions and the kawoken-package seem to build/install/remove fine. I will now patch a clean install of Slackware 14 and test building some packages to see how well it works.
makepkg also seem to be much faster now too, thanks :D For the record, here are the patches i applied to makepkg and removepkg on Slackware 14.0. Code:
--- makepkg.orig 2009-06-02 06:12:30.000000000 +0200 Code:
--- removepkg.orig 2009-04-28 22:44:26.000000000 +0200 |
Cool, thanks for testing as well! Makre sure to report back even if you don't have problems. Just to confirm that the changes really are OK.
Although one suggested change. I get the feeling that the birthday boy does not want to alter the formatting of the shell script code based on his comment above (also, whilst TommyC7's suggestion is certainly nice, packages containing symlinks/directories starting with - have not been reported yet). Therefore you don't really need the more complex regex in removepkg, s,^( *cd \([^;]*[!-~]\) *; *rm -rf \([^)]*[!-~]\) *) *$,\1/\2,p should be enough. |
Of course if Patrick is open to accepting -- and && as improvements within the shell script generation code, you can make a regex for removepkg that should deal with all variants and remain pretty false positive resistant. Here is a fake doinst.sh with various different formatting possibilities (as allowed by the current regex, plus support for escaped spaces and the proposed -- and && improvements):
Code:
( cd usr/bin ; rm -rf link\ 1 ) It would produce the following output: Code:
usr/bin/link\ 1 Code:
diff <(sed -n 's,^( *cd \([^ ;][^ ;]*\) *; *rm -rf \([^ )][^ )]*\) *) *$,\1/\2,p' /var/log/scripts/*) <(sed -n 's#^( *cd\( --\)\{,1\} \([^;&]*[!-~]\) *\(&&\|;\) *rm -rf\( --\)\{,1\} \([^)]*[!-~]\) *) *$#\2/\5#p' /var/log/scripts/*) That said, I am really starting to appreciate why Patrick is reluctant to allow too many changes to the output formatting of the symlink shell script code from makepkg. The more variation that is allowed the greater the complexity of the regex in removepkg to handle it. This increases the likelihood of false positives and a false positive could potentially mean a file that shouldn't be removed is removed. Additionally, there is an argument to be made that whilst support for -- and && and the benefits they bring would be nice to have, you aren't gonna need it given that thus far the current formatting has worked well for years. In the case of handling spaces in symlink names however a bug has now been reported, so it makes sense to try and handle that. Hence s,^( *cd \([^;]*[!-~]\) *; *rm -rf \([^)]*[!-~]\) *) *$,\1/\2,p is probably still the best regex to test with, as I suspect it has the best chance of making its way into removepkg of the suggestions I have made thus far. |
Don't forget 'ln -fs' as opposed to 'ln -sf'...
I am a bit surprised that Patrick expressed any desire to change from ';' to using '&&'. I figured that the use of ';' was kept so that it would be obvious when link-creation lines were failing, by leaving the faulty links in the root of '/'. Either way, seeing the commotion makes me glad I use package-creation software which pretty much guarantees the consistency of the code in doinst.sh scripts. It's worth mentioning that (src2pkg) also verifies that links are valid and converts any absolute paths to relative paths. |
Quote:
Code:
$ wget -qO- http://mirrors.slackware.com/slackware/slackware-current/source/a/pkgtools/scripts/makepkg | grep -n 'ln ' |
Quote:
I also tried to remove a package created with the patched makepkg tool and spaces in links with the old removepkg command and that failed. The files with spaces in filenames will not get removed. |
Quote:
|
All times are GMT -5. The time now is 02:31 PM. |