#!/bin/bash
#
# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
# 
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# Please add additional copyright information _after_ the line containing
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
# 
# ROCK Linux: rock-src/scripts/Create-SrcTar
# ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. A copy of the GNU General Public
# License can be found at Documentation/COPYING.
# 
# Many people helped and are helping developing ROCK Linux. Please
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
# file for details.
# 
# --- ROCK-COPYRIGHT-NOTE-END ---

eval "`grep -A 10 '\[BEGIN\]' scripts/parse-config | grep -B 10 '\[END\]'`"

echo -n 'Creating source tar ... '

# Create temp source base dir
#
src="`mktemp -d -p $PWD src.srctar.XXXXXXXXXX`"
rm -rf $src/rock-src-$rockver
mkdir -p $src/rock-src-$rockver
#
echo "ROCK Linux $rockver" > $src/rock-src-$rockver/VERSION
#
for x in README COPYING scripts target misc \
         package architecture Documentation
do
	[ -d $x ] && ln -s ../../$x $src/rock-src-$rockver/$x
	[ -f $x ] && cp -a $x $src/rock-src-$rockver/$x
done
#
mkdir -p $src/rock-src-$rockver/download
#cp download/INDEX $src/rock-src-$rockver/download/

#mkdir -p $src/rock-src-$rockver/CVS
#cp scripts/CVS/Root $src/rock-src-$rockver/CVS/
#cp scripts/CVS/Repository $src/rock-src-$rockver/CVS/
#cat << EOT > $src/rock-src-$rockver/CVS/Entries
#D/Documentation////
#D/architecture////
#D/misc////
#D/package////
#D/scripts////
#D/target////
#EOT

# Create tar file
#
(
	cd $src
	tar --use-compress-program=bzip2 --owner root --group root \
		-cf - rock-src-$rockver/*/* rock-src-$rockver/[CRV]*
) > ${1:-rock-src-$rockver.tar.bz2}

# Done.
#
rm -rf $src/
du -sh ${1:-rock-src-$rockver.tar.bz2} | tr '\t' ' '

