You are not logged in.
I'm creating a PKGBUILD for something that's not yet in the AUR and I've hit a dilemma.
(First, let it be known that I've only been using Arch for a couple days, so I'm still learning procedures and the best ways of doing things.)
The package I'm trying to create is for a TK script, the first line of which needs to be modified before it can be used. The script uses /usr/bin/wish, rather than the dummy place-holder value it uses by default.
My knee-jerk solution was to do the following in build() :
cd $startdir/pkg/usr/bin
_WISHPATH=`which wish`
sed -e "s_/dummy/path/wish_${_WISHPATH}_" < filename > filename.new
rm filename
mv filename.new filename
chmod 757 filename
Basically I just use sed to filter the file into a new temp file, replace the first line, and then rename the temp file to be the original file. (I could actually save a step by copying the initial file to be the temp file to start with, and I should use /tmp for the temp file .)
But then I read in the wiki that variables are frowned upon (I used the recommended preceding underscore to avoid potential conflict). Also, creating and then deleting a temp file seems inelegant.
My second solution was to create a patch to be applied in build(), but that forces the installation location for "wish" to be hard-coded into the patch file and no longer be decided at install-time, which I suppose is a safe assumption to make since the "tk" package puts "wish" in /usr/bin by default.
Thoughts on one verses the other? Alternate solutions?
Last edited by B-Con (2007-12-23 07:20:42)
Offline
Use the -i option to preform the sed operation in place. That removes the need for the temporary. Also, I'd just use /usr/bin/wish given that is where it is installed by tk and that will be a dependency.
Edit: Your chmod almost certianly wants to be 755.
Last edited by Allan (2007-12-23 07:51:46)
Offline
also, the install command (man install) allows you to move files and assign them some permissions, this further cleans up the PKGBUILD
Offline
Use the -i option to preform the sed operation in place. That removes the need for the temporary. Also, I'd just use /usr/bin/wish given that is where it is installed by tk and that will be a dependency.
Ah, nice, the man page says that -i does the temp file management for me.
Edit: Your chmod almost certianly wants to be 755.
No clue what I was thinking there. The source file starts with 755 and needs to stay 755... no idea why I did that
So if I use the -i switch and assume `which wish`=/usr/bin/wish, I only have one extra line to add to the build() function. Much cleaner. I'll just stick with doing sed last in build().
Last edited by B-Con (2007-12-24 03:15:10)
Offline