export TODAY=`date +%Y-%m-%d`
export REPO=${HOME}/shipwright-sd-${TODAY}.git/
#export REPO=/tmp/shipwright-sd-${TODAY}.git/

export GIT_PATH="git:file://$REPO"
export MIN_PERL=5.008006
export SKIP="--skip=Pod::Simple,Module::Signature,Test::Pod,Test::Pod::Coverage,Test::Distribution,Pod::Readme,Archive::Tar,HTML::Lint,Prophet,Encode,Date::Calc,Test::Cukes,Quantum::Superpositions,Test::Memory::Cycle,Text::Greeking,Test::HTTP::Server::Simple,Test::WWW::Mechanize,Config::GitLike,Module::Build,Test::Warn,Test::MockTime,Test::MockModule,Test::MockObject,Test::Warn"
export IMPORT="shipwright import --min-perl-version=$MIN_PERL $SKIP -r $GIT_PATH --log-file - --log-level debug"
rm -rf $REPO

shipwright create -r $GIT_PATH
# Optional deps we still want
$IMPORT \
 cpan:Scalar::Util \
 cpan:Template::Declare \
 cpan:HTTP::Server::Simple \
 cpan:File::ShareDir \
 cpan:DBI \
 cpan:DBD::SQLite \
 cpan:Net::GitHub \
 cpan:Term::ReadLine::Perl \
 cpan:JSON::XS \
 cpan:Net::Bonjour \
 cpan:Term::ReadKey \
 git://github.com/bestpractical/config-gitlike.git \
 git:git+ssh://fsck.com/git/prophet.git \
 cpan:RT::Client::REST \
 cpan:Email::Address \
 cpan:Net::Jifty \
 cpan:Net::Trac \
 cpan:Net::Google::Code \
 git:git+ssh://fsck.com/git/sd.git

cd /tmp
rm -rf sdex
#shipwright update -r $GIT_PATH cpan-Module-Build --add-deps cpan-Pod-Simple
#shipwright update -r $GIT_PATH cpan-IO-Compress-Base --add-deps cpan-Scalar-List-Utils
shipwright update -r $GIT_PATH prophet.git      --add-deps cpan-Term-ReadLine-Perl,cpan-TermReadKey,cpan-DBD-SQLite,cpan-File-ShareDir,cpan-HTTP-Server-Simple,cpan-JSON-XS,config-gitlike.git
shipwright update -r $GIT_PATH sd.git           --add-deps prophet.git,cpan-Net-Bonjour,cpan-Email-Address,cpan-Net-Trac,cpan-RT-Client-REST,cpan-Net-Google-Code
shipwright maintain -r $GIT_PATH --update-order

cd /tmp

git clone file://${REPO} hack-$$
cd hack-$$/scripts/cpan-DateTime-Format-Natural
perl -pi -e s'/Build test/Build/g' build
git config push.default matching
git commit -m 'Made DTFN not run its tests which add a slew of deps' build
git push
cd /tmp/
rm -rf hack-$$

git clone file://$REPO /tmp/sdex-$$
cd /tmp/sdex-$$ 
echo "# one argument per line
--skip-man-pages
--skip-test
--install-base=~/sd
" > __default_builder_options 
./bin/shipwright-utility --generate-tar-file /tmp/sd-image-${TODAY}.bin
