Patch to fix spaces in java jar files

https://bugzilla.redhat.com/show_bug.cgi?id=872737
This commit is contained in:
Toshio Kuratomi 2012-11-09 13:49:08 -08:00 committed by Ville Skyttä
parent 1891cc0aeb
commit d22596b0c1

View File

@ -25,17 +25,19 @@ if [ ! -z "$JARS" ]; then
# unpack every jar, set the date of the files and directories and # unpack every jar, set the date of the files and directories and
# repack the jar # repack the jar
OLD_IFS="$IFS"
IFS=$(printf '\n\t')
for j in $JARS ; do for j in $JARS ; do
JARNAME=`basename $j` JARNAME=`basename "$j"`
JTMPDIR=`mktemp -d -p $RPM_BUILD_ROOT/tmp $JARNAME.tmpdir.XXXXXXXXXX` || exit 1 JTMPDIR=`mktemp -d -p $RPM_BUILD_ROOT/tmp "$JARNAME.tmpdir.XXXXXXXXXX"` || exit 1
JARDIR=`mktemp -d -p $RPM_BUILD_ROOT/tmp $JARNAME.jardir.XXXXXXXXXX` || exit 1 JARDIR=`mktemp -d -p $RPM_BUILD_ROOT/tmp "$JARNAME.jardir.XXXXXXXXXX"` || exit 1
TIMEREF=`mktemp -p $RPM_BUILD_ROOT/tmp $JARNAME.timeref.XXXXXXXXXX` || exit 1 TIMEREF=`mktemp -p $RPM_BUILD_ROOT/tmp "$JARNAME.timeref.XXXXXXXXXX"` || exit 1
pushd $JTMPDIR > /dev/null pushd "$JTMPDIR" > /dev/null
/usr/bin/unzip -qq -o $j /usr/bin/unzip -qq -o "$j"
find -type d -exec chmod a+rx {} \; find -type d -exec chmod a+rx {} \;
find -type f -exec chmod a+r {} \; find -type f -exec chmod a+r {} \;
rm -f $j rm -f "$j"
# Create the directories first. # Create the directories first.
find -type d | LC_ALL=C sort | while read d; do find -type d | LC_ALL=C sort | while read d; do
@ -76,24 +78,25 @@ if [ ! -z "$JARS" ]; then
done done
# make the jar # make the jar
pushd $JARDIR > /dev/null pushd "$JARDIR" > /dev/null
if [ -n "`find -not -name '.'`" ]; then if [ -n "`find -not -name '.'`" ]; then
if [ -e META-INF/MANIFEST.MF ]; then if [ -e META-INF/MANIFEST.MF ]; then
/usr/bin/zip -q -X -9 $j META-INF/MANIFEST.MF /usr/bin/zip -q -X -9 "$j" META-INF/MANIFEST.MF
fi fi
find * -not -name '.' | LC_ALL=C sort | /usr/bin/zip -u -q -X -9 $j -@ find * -not -name '.' | LC_ALL=C sort | /usr/bin/zip -u -q -X -9 "$j" -@
else else
# Put the empty jar back # Put the empty jar back
touch $j touch "$j"
fi fi
popd > /dev/null popd > /dev/null
# Cleanup. # Cleanup.
rm -rf $JTMPDIR rm -rf "$JTMPDIR"
rm -rf $JARDIR rm -rf "$JARDIR"
rm -f $TIMEREF rm -f "$TIMEREF"
done done
IFS="$OLD_IFS"
# remove $RPM_BUILD_ROOT/tmp if we created it # remove $RPM_BUILD_ROOT/tmp if we created it
if [ $rmtmp -eq 1 ]; then if [ $rmtmp -eq 1 ]; then