

Code: Select all
# Slackware is not Gentoo.Leonardo.b wrote:I do not trust Slackware shell scripts.
They give me the impression to be sloppy.

I have been summoned.pjp wrote:nothing stood out as immediately bad. I'm no expert on "bad," but at least it wasn't bad enough that I noticed.
Code: Select all
1 #!/bin/bash
47 cd $(dirname $0) ; CWD=$(pwd)Code: Select all
$ cat /tmp/demo/sub\ dir/a.sh
#!/bin/sh
cd $(dirname $0)
pwd
$ bash -x /tmp/demo/sub\ dir/a.sh
++ dirname /tmp/demo/sub dir/a.sh
+ cd /tmp/demo dir
/tmp/demo/sub dir/a.sh: line 3: cd: too many arguments
+ pwd
/tmpCode: Select all
54 LOGDIR=$TMP/make_world
56 mkdir -p $LOGDIR/lockCode: Select all
$ TMP=/tmp/demo/sub\ dir/ bash -x a.sh
+ LOGDIR='/tmp/demo/sub dir//make_world'
+ mkdir -p /tmp/demo/sub dir//make_world/lockCode: Select all
62 # Make sure this ends in '/':
63 if [ ! "$(echo $SLACKWARE_SOURCE_DIRECTORY | rev | cut -b 1)" = "/" ]; then
Code: Select all
77 # Be kind, don't hit control-c! If you do, you might leave broken packages,
78 # logfiles, and locks in $TMP that will cause problems for you later. If you're
79 # not in a huge hurry to quit, create this file (replace with $TMP if needed):
80 # /tmp/make_world/lock/abort
81 # This will cause all instances of make_world.sh to exit when they complete the
82 # task they are working on.
83 rm -f $LOGDIR/lock/abortCode: Select all
85 BUILDLIST=${BUILDLIST:-$LOGDIR/buildlist}
86 if [ ! -r $BUILDLIST -a ! -r ${BUILDLIST}.lock ]; thenCode: Select all
$ a=/tmp/demo/sub\ dir/a.sh
$ if [ ! -r $a -a ! -r $a.x ]; then echo a; else echo b; fi
-bash: [: too many arguments
bCode: Select all
90 touch ${BUILDLIST} ${BUILDLIST}.lockCode: Select all
95 if [ "$uname -m)" = "x86_64" -a "$(basename $(echo $script | cut -f 1 -d ' '))" = "isapnptools.SlackBuild" ]; thenCode: Select all
107 # You might want to do this to comment some build scripts out first, or if
108 # you'd like to sort it into a "magic build order". ;-) This script is pretty
109 # good at just brute-forcing things, though (with a few runs).Code: Select all
117 while [ 0 ]; do
118 if [ ! -r ${BUILDLIST}.lock ]; then
Code: Select all
174 cat $BUILDLIST | grep -v "^$" | grep -v "^#" | sort | uniq | cut -f 1 -d ' ' | rev | cut -f 1 -d / | rev > $LOGDIR/tmp-pkgs-to-build.$$Code: Select all
193 for findconfigure in */configure ; do
194 rm -rf "$(dirname $findconfigure)"
195 done
196 for findautogen in */autogen.sh ; do
197 rm -rf "$(dirname $findautogen)"
198 doneCode: Select all
227 HELD_BY="$(cat $LOGDIR/lock/lock.global)"Code: Select all
230 sleep 10Code: Select all
235 if [ ! "${HELD_BY}" = "$(cat $LOGDIR/lock/lock.global)" ]; then
236 HELD_BY="$(cat $LOGDIR/lock/lock.global)"Code: Select all
243 if [ -r $OUTPUT_LOCATION/$(PRINT_PACKAGE_NAME=foo $buildscript | head -n 1) -a $FORCE_BUILD = no ]; thenCode: Select all
247 # Use flock to only allow one instance of this script to work on a given
248 # SlackBuild script at a time.Code: Select all
260 # pkgtools, x11, and KDE all trigger the detection above, but none of them
261 # really need the global lock. So only request the lock if the build
262 # script is not one of those.Code: Select all
268 ( flock 9 || exit 11
271 ) 9> $LOGDIR/lock/lock.globalCode: Select all
272 # Remove lock file:
273 rm -f $LOGDIR/lock/lock.global

++Leonardo.b wrote::)Hu wrote:I have been summoned.pjp wrote:nothing stood out as immediately bad. I'm no expert on "bad," but at least it wasn't bad enough that I noticed. :)
Or similar? Because you've mentioned using -eu, I've been doing that for a while now. I won't go line by line, but I've also tried to quote everything. Thanks for the script reviews that you do. I try to absorb what I can.Hu wrote:First non-comment line is not set -eu or similar.
Is there a better way than using 'sudo -u ... -g ... /bin/sh -c ...'? su probably works I suppose... not sure why I went with sudo, maybe habit.Leonardo.b wrote:Also, the script runs all the buildings as root; it would be good to drop privileges at a certain point.

Boh. I don't know. su is granted to be installed for everyone.pjp wrote:Is there a better way than using 'sudo -u ... -g ... /bin/sh -c ...'? su probably works I suppose... not sure why I went with sudo, maybe habit.Leonardo.b wrote:Also, the script runs all the buildings as root; it would be good to drop privileges at a certain point.
This is true for all slackware package building scripts since the dawn of time. Originally because files in the final tarball had to be owned as root, back when fakeroot didn't exist, and fakeroot can't really set some permissions either. Might as well do everything as root instead of juggling with root permissions or whatever. Are you starting to get why it's called "slack"ware yet?Leonardo.b wrote:Also, the script runs all the buildings as root; it would be good to drop privileges at a certain point.
Permanent link to the script: http://mirror.slackware.hr/slackware/sl ... e_world.sh

I like most those scripts that politely insult me, every time I ask them to do odd things.mid-kid wrote:Errors are checked when necessary, not throughout the entire script. This is true for many gentoo scripts as well, as it allows more freedom in how errors are handled.
Code: Select all
command || trueThe metadatas in the tarball must say root:root; it is enough to ask tar to ignore the ownerships while creating the tarball. No need to really touch the files.Originally because files in the final tarball had to be owned as root, back when fakeroot didn't exist, and fakeroot can't really set some permissions either.
Yes. I don't complain.Are you starting to get why it's called "slack"ware yet?
Until very recently (somewhere in the last 3ish years) it still used tar-1.13 for compatibility reasons. I'm not sure if that version supported the option.Leonardo.b wrote: The metadatas in the tarball must say root:root; it is enough to ask tar to ignore the ownerships while creating the tarball. No need to really touch the files.