2011-07-24 03:16:38 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if test -z $1
|
|
|
|
then
|
|
|
|
echo "usage: $0 <input-tarball>"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
ORIGDIR=`pwd`
|
|
|
|
WORKDIR=nss_ecc_strip_working_dir
|
|
|
|
EXTENSION=`echo $1 | sed -r 's#^(.*)(.tar.bz2|.tbz2|.tar.gz|.tgz)$#\2#'`
|
|
|
|
BASE=`echo $1 | sed -r 's#^(.*)(.tar.bz2|.tbz2|.tar.gz|.tgz)$#\1#'`
|
|
|
|
COMPRESS=""
|
|
|
|
|
|
|
|
if test "x$EXTENSION" = "x.tar.bz2" || test "x$EXTENSION" = "x.tbz2"
|
|
|
|
then
|
|
|
|
COMPRESS="j"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "x$EXTENSION" = "x.tar.gz" || test "x$EXTENSION" = "x.tgz"
|
|
|
|
then
|
|
|
|
COMPRESS="z"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "x$COMPRESS" = "x"
|
|
|
|
then
|
|
|
|
echo "unable to process, input file $1 has unsupported extension"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "== extension is $EXTENSION - ok"
|
|
|
|
echo "== new extension will be $JEXTENSION"
|
|
|
|
echo "== cleaning old workdir $WORKDIR"
|
|
|
|
|
|
|
|
rm -rf $WORKDIR
|
|
|
|
mkdir $WORKDIR
|
|
|
|
|
|
|
|
echo "== extracting input archive $1"
|
|
|
|
tar -x -$COMPRESS -C $WORKDIR -f $1
|
|
|
|
|
|
|
|
echo "changing into $WORKDIR"
|
|
|
|
pushd $WORKDIR
|
|
|
|
|
|
|
|
DIRCOUNT=`ls -1 | wc -l`
|
|
|
|
if test $DIRCOUNT -ne 1
|
|
|
|
then
|
|
|
|
echo "unable to process, $1 contains more than one toplevel directory"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
TOPDIR=`ls -1`
|
2013-04-09 23:14:36 +00:00
|
|
|
if test "x$TOPDIR" != "xnss"
|
2011-07-24 03:16:38 +00:00
|
|
|
then
|
2013-04-09 23:14:36 +00:00
|
|
|
# try to deal with a single additional subdirectory above "nss"
|
2011-07-24 03:16:38 +00:00
|
|
|
echo "== skipping toplevel directory $TOPDIR"
|
|
|
|
cd $TOPDIR
|
|
|
|
fi
|
|
|
|
|
|
|
|
DIRCOUNT=`ls -1 | wc -l`
|
|
|
|
if test $DIRCOUNT -ne 1
|
|
|
|
then
|
|
|
|
echo "unable to process, $1 contains more than one second level directory"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
SINGLEDIR=`ls -1`
|
2013-04-09 23:14:36 +00:00
|
|
|
if test "x$SINGLEDIR" != "xnss"
|
2011-07-24 03:16:38 +00:00
|
|
|
then
|
2013-04-09 23:14:36 +00:00
|
|
|
echo "unable to process, first or second level directory is not nss"
|
2011-07-24 03:16:38 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "== input archive accepted, now processing"
|
|
|
|
|
2013-04-09 23:14:36 +00:00
|
|
|
REALFREEBLDIR=nss/lib/freebl
|
2011-07-24 03:16:38 +00:00
|
|
|
FREEBLDIR=./$REALFREEBLDIR
|
|
|
|
|
2013-04-09 23:14:36 +00:00
|
|
|
rm -rf ./nss/cmd/ecperf
|
2011-07-24 03:16:38 +00:00
|
|
|
|
|
|
|
mv ${FREEBLDIR}/ecl/ecl-exp.h ${FREEBLDIR}/save
|
|
|
|
rm -rf ${FREEBLDIR}/ecl/tests
|
|
|
|
rm -rf ${FREEBLDIR}/ecl/CVS
|
|
|
|
for i in ${FREEBLDIR}/ecl/* ; do
|
|
|
|
echo clobbering $i
|
|
|
|
> $i
|
|
|
|
done
|
|
|
|
mv ${FREEBLDIR}/save ${FREEBLDIR}/ecl/ecl-exp.h
|
|
|
|
|
|
|
|
for j in ${FREEBLDIR}/ec.*; do
|
|
|
|
echo unifdef $j
|
|
|
|
cat $j | \
|
|
|
|
awk 'BEGIN {ech=1; prt=0;} \
|
|
|
|
/^#[ \t]*ifdef.*NSS_ENABLE_ECC/ {ech--; next;} \
|
|
|
|
/^#[ \t]*if/ {if(ech < 1) ech--;} \
|
|
|
|
{if(ech>0) {;print $0};} \
|
|
|
|
/^#[ \t]*endif/ {if(ech < 1) ech++;} \
|
|
|
|
{if (prt && (ech<=0)) {;print $0}; } \
|
|
|
|
{if (ech>0) {prt=0;} } \
|
|
|
|
/^#[ \t]*else/ {if (ech == 0) prt=1;}' > $j.hobbled && \
|
|
|
|
mv $j.hobbled $j
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "== returning to original directory"
|
|
|
|
popd
|
|
|
|
|
|
|
|
JCOMPRESS=j
|
|
|
|
JEXTENSION=.tar.bz2
|
|
|
|
NEWARCHIVE=$BASE-stripped$JEXTENSION
|
|
|
|
echo "== finally producing new archive $NEWARCHIVE"
|
|
|
|
tar -c -$JCOMPRESS -C $WORKDIR -f $NEWARCHIVE $TOPDIR
|
|
|
|
|
|
|
|
echo "== all done, listing of old and new archive:"
|
|
|
|
ls -l $1
|
|
|
|
ls -l $NEWARCHIVE
|
|
|
|
|
|
|
|
LISTING_DIR=""
|
|
|
|
if test "x$TOPDIR" != "xmozilla"
|
|
|
|
then
|
|
|
|
LISTING_DIR="$TOPDIR/$REALFREEBLDIR/ecl"
|
|
|
|
else
|
|
|
|
LISTING_DIR="$REALFREEBLDIR/ecl"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "== FYI, producing listing of stripped dir in new archive"
|
|
|
|
tar -t -v -$JCOMPRESS -C $WORKDIR -f $NEWARCHIVE $LISTING_DIR
|
|
|
|
|
|
|
|
|