#!/bin/sh
#
# This script creates fully reproducible, bytes-perfect tarball of the
# CPython 0.9.1 release (initial public release) as posted by Guido
# van Rossum to the Usenet "alt.sources" newsgroup
# (https://en.wikipedia.org/wiki/Usenet_newsgroup). This is not first
# attempt to recover the original 0.9.1 sources, but many previous
# attempts started from the Dejanews Usenet archives, later acquired
# by Google, which have whitespace issues (tabs converted to spaces).
# This script uses alternative archive source at ftp.fi.netbsd.org,
# which doesn't have whitespace issues.
#
# This script strives to produce fully reproducible archive, and for
# this explicitly sets GMT date of all files included in the archive.
# So, for as long as TAR and GZIP formats are themselves stable across
# systems, this script should produce bytes-exact archive files on any
# system.
#

set -e
# Index: http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/index.gz
cat >urls <<EOF
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910220.10.gz#Python 0.9.1 part 01/21 <2963@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910220.11.gz#Python 0.9.1 part 03/21 <2965@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.31.gz#Python 0.9.1 part 04/21 <2966@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.32.gz#Python 0.9.1 part 05/21 <2967@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.33.gz#Python 0.9.1 part 06/21 <2968@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.34.gz#Python 0.9.1 part 07/21 <2969@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.35.gz#Python 0.9.1 part 08/21 <2970@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.36.gz#Python 0.9.1 part 09/21 <2971@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.37.gz#Python 0.9.1 part 10/21 <2972@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.38.gz#Python 0.9.1 part 11/21 <2973@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.39.gz#Python 0.9.1 part 12/21 <2974@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.40.gz#Python 0.9.1 part 13/21 <2975@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.41.gz#Python 0.9.1 part 14/21 <2976@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.42.gz#Python 0.9.1 part 15/21 <2977@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.43.gz#Python 0.9.1 part 16/21 <2978@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.44.gz#Python 0.9.1 part 17/21 <2979@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.45.gz#Python 0.9.1 part 19/21 <2981@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.46.gz#Python 0.9.1 part 21/21 <2983@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.47.gz#Python 0.9.1 part 02/21 <2985@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.48.gz#Python 0.9.1 part 18/21 <2980@charon.cwi.nl>
http://ftp.fi.netbsd.org/pub/misc/archive/alt.sources/volume91/Feb/910224.49.gz#Python 0.9.1 part 20/21 <2982@charon.cwi.nl>
EOF
wget -i urls
gzip -d -f *.gz
rm -rf python-0.9.1
mkdir -p python-0.9.1
unshar -d python-0.9.1 [0-9]*.[0-9][0-9]
find python-0.9.1 -type f | xargs md5sum >MD5SUMS
# Set the modtime based on the date of the "part 01/21" message.
find python-0.9.1/ | xargs touch -d "19 Feb 1991 17:35:26 GMT"
# Set the date of the script itself (and MD5SUMS), to make 100% reproducible
# tarball. Use +30 years date. In reality, script was written a couple of days
# earlier.
touch -d "19 Feb 2021 17:35:26 GMT" python-0.9.1-create-tarball.sh MD5SUMS
# Create tarball, include this script itself as a documentation/reference.
tar cfz python-0.9.1.tar.gz python-0.9.1-create-tarball.sh MD5SUMS python-0.9.1/
touch -d "19 Feb 1991 17:35:26 GMT" python-0.9.1.tar.gz
md5sum python-0.9.1.tar.gz