Recording a file-containing package into an eXtended ATTRibute.
by Lockywolf from LinuxQuestions.org on (#54QK3)
Hello, everyone.
This topic is not actually a question but if someone is feeling adventurous, beta-testers welcome.
I I got tired of grepping /var/lib/pkgtools/packages/* , and wanted to implement the O(1) method of finding "what package this file belongs to".
So I added the following into /sbin/installpkg at line 659 (after the untar-if):
Code: while read -r
do
#pkg_files+=("$REPLY")
if [[ -f "$ROOT/$REPLY" ]]
then
setfattr -n user.beta.slackware.pkgtools.package \
-v "$shortname" \
-h \
"$ROOT/$REPLY"
fi
done < <(cat "$TMP/$shortname")I also changed the shebang of the file from "/bin/sh" to "/bin/bash", for the "<(..)" to work. It's possible to rewrite this more portably, but I don't think many people actually have sh that is not bash. If anybody really wants it, ping me.
It's kinda slower for numFiles-bound packages. On kernel-source it's:
Code:
No xattr: Package kernel-source-5.4.46-noarch-1.txz installed.
real 0m48.604s
user 0m44.882s
sys 0m17.139s
xattr: Package kernel-source-5.4.46-noarch-1.txz installed.
real 4m37.083s
user 3m21.302s
sys 1m32.191sFor me the difference of 5 minutes on the package that has probably the largest number of files doesn't matter too much. ( I guess if I had a patch for tar to append an xattr manually, it would have no performance penalty. )
I guess this could also be offloaded to "makepkg", which would only incur this penalty once on the packager's machine.
If anybody finds this useful, I can make this patch for makepkg too, and even suggest including in the mainline.
Tests on filesystems that don't support xattrs are wecome. It's likely that the script will just complain, and nothing more, I have no FAT machines to test.


This topic is not actually a question but if someone is feeling adventurous, beta-testers welcome.
I I got tired of grepping /var/lib/pkgtools/packages/* , and wanted to implement the O(1) method of finding "what package this file belongs to".
So I added the following into /sbin/installpkg at line 659 (after the untar-if):
Code: while read -r
do
#pkg_files+=("$REPLY")
if [[ -f "$ROOT/$REPLY" ]]
then
setfattr -n user.beta.slackware.pkgtools.package \
-v "$shortname" \
-h \
"$ROOT/$REPLY"
fi
done < <(cat "$TMP/$shortname")I also changed the shebang of the file from "/bin/sh" to "/bin/bash", for the "<(..)" to work. It's possible to rewrite this more portably, but I don't think many people actually have sh that is not bash. If anybody really wants it, ping me.
It's kinda slower for numFiles-bound packages. On kernel-source it's:
Code:
No xattr: Package kernel-source-5.4.46-noarch-1.txz installed.
real 0m48.604s
user 0m44.882s
sys 0m17.139s
xattr: Package kernel-source-5.4.46-noarch-1.txz installed.
real 4m37.083s
user 3m21.302s
sys 1m32.191sFor me the difference of 5 minutes on the package that has probably the largest number of files doesn't matter too much. ( I guess if I had a patch for tar to append an xattr manually, it would have no performance penalty. )
I guess this could also be offloaded to "makepkg", which would only incur this penalty once on the packager's machine.
If anybody finds this useful, I can make this patch for makepkg too, and even suggest including in the mainline.
Tests on filesystems that don't support xattrs are wecome. It's likely that the script will just complain, and nothing more, I have no FAT machines to test.