freebsd-dev/release/scripts/X11/generate_tarballs.sh

80 lines
1.8 KiB
Bash
Raw Normal View History

#!/bin/sh
#
# This script takes a directory containing the base install of X, a directory
# containing the packing lists for the tarballs, and generates the distribution
# tarballs in a 3rd destination directory.
# generate_tarball <packing list> <tarball>
#
# Takes the packing list listed in the first argument and generates a
# corresponding tarball relative to the source directory in a file with the
# name listed in the second argument.
generate_tarball() {
echo "Generating $2 from $1..."
tar_arguments='cnTfp';
# handle gzip/bzip2/compress
case $2 in
*gz)
tar_arguments="${tar_arguments}z"
;;
*bz)
tar_arguments="${tar_arguments}y"
;;
*Z)
tar_arguments="${tar_arguments}Z"
;;
esac
cat $1 | (cd ${source_dir} ; tar ${tar_arguments} - - ) > $2
}
# output the usage
#
usage() {
echo "$0 <source_dir> <plist_dir> <tarball_dir>"
echo
echo "Where <source_dir> is a directory containing the X distribution,"
echo "<plist_dir> is the directory containing all of the packing lists"
echo "generated by generate_plists.sh, and <tarball_dir> is the"
echo "directory to put all the tarballs under."
exit 1
}
# copy the directory structure of the packing list directory over into the
# tarball directory
#
mirror_directories() {
echo "Creating tarball directory structure..."
find ${plist_dir} -type d | \
sed -e "s:^${plist_dir}:mkdir -p ${tarball_dir}:" | \
sh -x || exit 1
}
# build all the tarballs
#
build_tarballs() {
for plist in `find ${plist_dir} ! -type d`; do
archive=`echo ${plist} | \
sed -e "s:^${plist_dir}:${tarball_dir}:" \
-e 's/\.plist$//'`
generate_tarball ${plist} ${archive}
done
}
# check for enough arguments
if [ $# -ne 3 ]; then
usage
fi
# setup the variables
source_dir=$1
plist_dir=$2
tarball_dir=$3
# do all the work
if mirror_directories; then
build_tarballs
fi