I was writing a build script in Bash for one of the development projects and I wanted to have a list of patches that would be applied to a "clean" distribution of JBoss to create the fully configured app server. I needed something simple so the development team could continue to maintain and update the script. I came up with this idea while looking at RPM building.
#!/bin/bash
PATCH0=$SOURCES/jboss-4.2.3.GA.base.patch
PATCH1=$SOURCES/log4j-setup-append.patch
PATCH2=$SOURCES/jboss-set-call-by-value.patch
PATCH3=$SOURCES/add-security-policy-login.patch
MAXPATCHES=100 #The script searches for PATCH{value}= lines from zero to this number
echo "Applying patches"
i=0
while [ $i -lt $MAXPATCHES ] ; do
PATCH=$(eval echo $echo PATCH${i});
if [ ! "$PATCH" == "" ] ; then
echo "Applying patch: $PATCH"
patch -p0 < $PATCH
fi
i=$[$i+1]
done;
In the end it might have been simpler to use a datafile, or a language with Array support, but this works well enough and is fairly usable.

Leave a comment