8bd67f
#!/bin/sh
8bd67f
#
8bd67f
# Splits NSS into nss-util 
8bd67f
# Takes as command line input the version of nss
8bd67f
# and assumes that a file nss-${nss_version}-stripped.tar.bz2
8bd67f
# exits in the current directory
8bd67f
8bd67f
set -e
8bd67f
8bd67f
if test -z $1
8bd67f
then
8bd67f
  echo "usage: $0 nss-version"
8bd67f
  exit
8bd67f
fi
8bd67f
8bd67f
export name=nss
8bd67f
export version=$1
8bd67f
8bd67f
echo "Extracting ${name}-${version}.tar.gz"
8bd67f
8bd67f
tar -xzf ${name}-${version}.tar.gz
8bd67f
8bd67f
# the directory will be named ${name}-${version}
8bd67f
8bd67f
nss_source_dir=${name}-${version}
8bd67f
util_dir=${name}-util-${version}
8bd67f
softokn_dir=${name}-softokn-${version}
8bd67f
8bd67f
# make_nss_util
8bd67f
#-------------------------------------------------
8bd67f
# create the nss-util subset consisting of
8bd67f
#   nss/dbm      --- full directory
8bd67f
#   nss/coreconf --- full directory
8bd67f
#   nss          --- top files only
8bd67f
#   nss/lib      --- top files only
8bd67f
#   nss/lib/util --- full directory
8bd67f
#--------------------------------------------------
8bd67f
8bd67f
UTIL_WORK=${util_dir}-work
8bd67f
rm -rf ${UTIL_WORK}
8bd67f
mkdir ${UTIL_WORK}
8bd67f
8bd67f
# copy everything
8bd67f
cp -a ${nss_source_dir} ${UTIL_WORK}/${util_dir}
8bd67f
8bd67f
# remove subdirectories that we don't want
8bd67f
rm -rf ${UTIL_WORK}/${util_dir}/nss/cmd
8bd67f
rm -rf ${UTIL_WORK}/${util_dir}/nss/tests
8bd67f
rm -rf ${UTIL_WORK}/${util_dir}/nss/lib
8bd67f
rm -rf ${UTIL_WORK}/${util_dir}/nss/automation
8bd67f
rm -rf ${UTIL_WORK}/${util_dir}/nss/external_tests
8bd67f
rm -rf ${UTIL_WORK}/${util_dir}/nss/doc
8bd67f
8bd67f
# start with an empty cmd lib directories to be filled selectively
8bd67f
mkdir ${UTIL_WORK}/${util_dir}/nss/cmd
8bd67f
cp ${nss_source_dir}/nss/cmd/Makefile ${UTIL_WORK}/${util_dir}/nss/cmd
8bd67f
cp ${nss_source_dir}/nss/cmd/manifest.mn ${UTIL_WORK}/${util_dir}/nss/cmd
8bd67f
cp ${nss_source_dir}/nss/cmd/platlibs.mk ${UTIL_WORK}/${util_dir}/nss/cmd
8bd67f
cp ${nss_source_dir}/nss/cmd/platrules.mk ${UTIL_WORK}/${util_dir}/nss/cmd
8bd67f
8bd67f
mkdir ${UTIL_WORK}/${util_dir}/nss/lib
8bd67f
# copy some files at the top and the util subdirectory recursively
8bd67f
cp ${nss_source_dir}/nss/lib/Makefile ${UTIL_WORK}/${util_dir}/nss/lib
8bd67f
cp ${nss_source_dir}/nss/lib/manifest.mn ${UTIL_WORK}/${util_dir}/nss/lib
8bd67f
cp -a ${nss_source_dir}/nss/lib/util ${UTIL_WORK}/${util_dir}/nss/lib/util
8bd67f
8bd67f
# plus common and gtests from nss/tests
8bd67f
mkdir ${UTIL_WORK}/${util_dir}/nss/tests
8bd67f
topFilesT=`find ${nss_source_dir}/nss/tests/ -maxdepth 1 -mindepth 1 -type f`
8bd67f
for f in $topFilesT; do
8bd67f
  cp -p $f ${UTIL_WORK}/${util_dir}/nss/tests/
8bd67f
done
8bd67f
keepers="common gtests"
8bd67f
for t in $keepers; do
8bd67f
  cp -a ${nss_source_dir}/nss/tests/$t ${UTIL_WORK}/${util_dir}/nss/tests/$t
8bd67f
done
8bd67f
8bd67f
pushd ${UTIL_WORK}
8bd67f
# the compressed tar ball for nss-util
8bd67f
tar -czf ../${name}-util-${version}.tar.gz ${util_dir}
8bd67f
popd
8bd67f
8bd67f
# cleanup after ourselves
8bd67f
rm -fr ${nss_source_dir}
8bd67f
rm -fr ${UTIL_WORK}
8bd67f
8bd67f
8bd67f