Last active
October 10, 2018 19:50
-
-
Save jberger/479011536639c7183b05b435e783f9b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Archive::Tar; | |
use CPAN::Meta; | |
use ExtUtils::Manifest qw/mkmanifest maniread/; | |
use Module::CPANfile; | |
use Module::Metadata; | |
use Module::Build::Tiny (); | |
use Time::Piece; | |
my $name = shift || die 'name is required'; | |
my $version = gmtime->strftime('%Y%m%d.%H%M%S'); | |
my $prereqs = Module::CPANfile->load('cpanfile')->prereq_specs; | |
$prereqs->{configure}{requires}{'Module::Build::Tiny'} //= $Module::Build::Tiny::VERSION; | |
my $provides = Module::Metadata->provides(version => 2, dir => 'lib'); | |
my $meta = CPAN::Meta->create({ | |
name => $name, | |
author => ['ServerCentral'], | |
version => $version, | |
abstract => shift || $name, | |
dynamic_config => 0, | |
license => [ 'restricted' ], | |
prereqs => $prereqs, | |
provides => $provides, | |
release_status => 'stable', | |
}); | |
$meta->save('META.json'); | |
maybe_spurt('Build.PL', <<'FILE'); | |
use Module::Build::Tiny; | |
Build_PL(); | |
FILE | |
maybe_spurt('MANIFEST.SKIP', <<'FILE'); | |
#!include_default | |
debian/ | |
FILE | |
mkmanifest(); | |
my $files = maniread(); | |
my $arch = Archive::Tar->new; | |
$arch->add_files(sort keys %$files); | |
my $file = "$name-$version.tar.gz"; | |
$arch->write($file, &Archive::Tar::COMPRESS_GZIP, $name); | |
sub maybe_spurt { | |
my ($file, $text) = @_; | |
return if -f $file; | |
open my $fh, '>', $file or die "Cannot open $file for writing\n"; | |
print $fh $text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment