export TODAY=`date +%Y-%m-%d`
export REPO=${HOME}/shipwright-sd-${TODAY}.git/
#export REPO=/tmp/shipwright-sd-${TODAY}.git/
export SHIPWRIGHT_REPOSITORY="git:file://$REPO"
export MIN_PERL=5.008006
export SKIP="--skip=Pod::Simple,Module::Signature,Test::Pod,Test::Most,Quantum::SuperPositions,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,Module::Build,Test::Warn,Test::MockTime,Test::MockModule,Test::MockObject,Test::Warn,HTTP::Cookies,HTTP::Request::Common,JSON::DWIW"
export IMPORT="shipwright import --min-perl-version=$MIN_PERL $SKIP --log-file - --log-level debug"
rm -rf $REPO
shipwright create
# 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:Term::ReadLine::Perl \
cpan:JSON::XS \
cpan:Net::Bonjour \
cpan:Term::ReadKey \
cpan:Config::GitLike \
cpan:XSLoader \
git:http://github.com/bestpractical/prophet.git \
cpan:RT::Client::REST \
cpan:Email::Address \
cpan:Net::GitHub \
cpan:Net::Jifty \
cpan:Net::Trac \
cpan:Net::Google::Code \
git:http://github.com/bestpractical/sd.git
cd /tmp
#shipwright update cpan-Module-Build --add-deps cpan-Pod-Simple
#shipwright update cpan-IO-Compress-Base --add-deps cpan-Scalar-List-Utils
shipwright update cpan-Mouse --add-deps cpan-XSLoader
shipwright update prophet.git --add-deps cpan-Term-ReadLine-Perl,cpan-TermReadKey,cpan-DBD-SQLite,cpan-File-ShareDir,cpan-HTTP-Server-Simple,cpan-JSON-XS,cpan-Config::GitLike
shipwright update 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 --update-order
cd /tmp
git clone file://${REPO} hack-$$
cd /tmp/hack-$$/sources/cpan-Lingua-EN-Inflect/vendor
git mv Build.pl Build.PL
cd /tmp/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
cd /tmp/hack-$$/scripts/cpan-Net-DNS
perl -pi -e 's/make:/make: COMMAND_MODE=unix2003/' build
git commit -m 'hack COMMAND_MODE to make Net-DNS happy on mac' build
git push
cd /tmp/
rm -rf hack-$$
git clone file://$REPO /tmp/sdex-$$
cd /tmp/sdex-$$
rm -rf .git
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
rm -rf /tmp/sdex-$$