bin/cpan2tpkg in tpkg-2.2.4 vs bin/cpan2tpkg in tpkg-2.3.0
- old
+ new
@@ -1,9 +1,8 @@
#!/opt/tpkg/bin/perl
##############################################################################
# tpkg package management system
-# Copyright 2009, 2010, 2011 AT&T Interactive
# License: MIT (http://www.opensource.org/licenses/mit-license.php)
##############################################################################
use warnings;
use strict;
@@ -76,11 +75,11 @@
my @extradepsopts = split(/,/, $extradepsopts);
while (scalar @extradepsopts)
{
my $dep = shift @extradepsopts;
# These are optional, shift will return undef if they aren't present
- # and we'll handle that properly when creating tpkg.xml
+ # and we'll handle that properly when creating tpkg.yml
my $depminver = shift @extradepsopts;
my $depmaxver = shift @extradepsopts;
$extradeps{$dep} = {};
$extradeps{$dep}{minimum_version} = $depminver;
$extradeps{$dep}{maximum_version} = $depmaxver;
@@ -88,11 +87,11 @@
my @nativedepsopts = split(/,/, $nativedepsopts);
while (scalar @nativedepsopts)
{
my $dep = shift @nativedepsopts;
# These are optional, shift will return undef if they aren't present
- # and we'll handle that properly when creating tpkg.xml
+ # and we'll handle that properly when creating tpkg.yml
my $depminver = shift @nativedepsopts;
my $depmaxver = shift @nativedepsopts;
$nativedeps{$dep} = {};
$nativedeps{$dep}{minimum_version} = $depminver;
$nativedeps{$dep}{maximum_version} = $depmaxver;
@@ -313,27 +312,33 @@
chomp($packlistfile);
# Chop off $workdir
$packlistfile =~ s/^$workdir//;
# Make directory tree in $tpkgdir
mkpath("$tpkgdir/root/" . dirname($packlistfile));
+
# Copy file
- copy("$workdir/$packlistfile", "$tpkgdir/root/$packlistfile");
+ my $src = "$workdir/$packlistfile";
+ my $dst = "$tpkgdir/root/$packlistfile";
+ copy($src, $dst);
+
+ # preserve permissions
+ # (avoiding dependency on File::Copy::Recursive::fcopy)
+ my $mode = (stat($src))[2];
+ chmod($mode & 07777, $dst);
+
if ($packlistfile =~ quotemeta($Config{archname}))
{
$nativefile = 1;
}
}
- # Create tpkg.xml
- open(my $xmlfh, '>', "$tpkgdir/tpkg.xml") or die;
- print $xmlfh '<?xml version="1.0" encoding="UTF-8"?>', "\n";
- print $xmlfh '<!DOCTYPE tpkg SYSTEM "http://tpkg.sourceforge.net/tpkg-1.0.dtd">', "\n";
- print $xmlfh '<tpkg>', "\n";
- print $xmlfh " <name>cpan-perl$majorminor-$pkgname</name>", "\n";
- print $xmlfh " <version>$ver</version>", "\n";
- print $xmlfh " <package_version>$pkgver</package_version>", "\n";
- print $xmlfh " <description>cpan package for $pkgname</description>", "\n";
- print $xmlfh ' <maintainer>cpan2tpkg</maintainer>', "\n";
+ # Create tpkg.yml
+ open(my $ymlfh, '>', "$tpkgdir/tpkg.yml") or die;
+ print $ymlfh "name: cpan-perl$majorminor-$pkgname", "\n";
+ print $ymlfh "version: $ver", "\n";
+ print $ymlfh "package_version: $pkgver", "\n";
+ print $ymlfh "description: cpan package for $pkgname", "\n";
+ print $ymlfh 'maintainer: cpan2tpkg', "\n";
# If the package has native code then it needs to be flagged as
# specific to the OS and architecture
if ($nativefile)
{
my $os;
@@ -358,71 +363,61 @@
}
# Packages built on Red Hat should work on CentOS and
# vice-versa
if ($os =~ /RedHat-(.*)/)
{
- $os = $os . ",CentOS-$1";
+ $os = $os . ", CentOS-$1";
}
elsif ($os =~ /CentOS-(.*)/)
{
- $os = $os . ",RedHat-$1";
+ $os = $os . ", RedHat-$1";
}
- print $xmlfh " <operatingsystem>$os</operatingsystem>", "\n";
- print $xmlfh " <architecture>$arch</architecture>", "\n";
+ print $ymlfh "operatingsystem: [$os]", "\n";
+ print $ymlfh "architecture: [$arch]", "\n";
}
# Insert appropriate dependencies into the package
- print $xmlfh ' <dependencies>', "\n";
+ print $ymlfh 'dependencies:', "\n";
foreach my $dep (keys %deps)
{
- print $xmlfh ' <dependency>', "\n";
- print $xmlfh " <name>cpan-perl$majorminor-$dep</name>", "\n";
+ print $ymlfh " - name: cpan-perl$majorminor-$dep", "\n";
if ($deps{$dep}{minimum_version})
{
- print $xmlfh " <minimum_version>$deps{$dep}{minimum_version}</minimum_version>", "\n";
+ print $ymlfh " minimum_version: $deps{$dep}{minimum_version}", "\n";
}
if ($deps{$dep}{maximum_version})
{
- print $xmlfh " <maximum_version>$deps{$dep}{maximum_version}</maximum_version>", "\n";
+ print $ymlfh " maximum_version: $deps{$dep}{maximum_version}", "\n";
}
- print $xmlfh ' </dependency>', "\n";
}
foreach my $extradep (keys %extradeps)
{
- print $xmlfh ' <dependency>', "\n";
- print $xmlfh " <name>$extradep</name>", "\n";
+ print $ymlfh " - name: $extradep", "\n";
if ($extradeps{$extradep}{minimum_version})
{
- print $xmlfh " <minimum_version>$extradeps{$extradep}{minimum_version}</minimum_version>", "\n";
+ print $ymlfh " minimum_version: $extradeps{$extradep}{minimum_version}", "\n";
}
if ($extradeps{$extradep}{maximum_version})
{
- print $xmlfh " <maximum_version>$extradeps{$extradep}{maximum_version}</maximum_version>", "\n";
+ print $ymlfh " maximum_version: $extradeps{$extradep}{maximum_version}", "\n";
}
- print $xmlfh ' </dependency>', "\n";
}
foreach my $nativedep (keys %nativedeps)
{
- print $xmlfh ' <dependency>', "\n";
- print $xmlfh " <name>$nativedep</name>", "\n";
+ print $ymlfh " - name: $nativedep", "\n";
if ($nativedeps{$nativedep}{minimum_version})
{
- print $xmlfh " <minimum_version>$nativedeps{$nativedep}{minimum_version}</minimum_version>", "\n";
+ print $ymlfh " minimum_version: $nativedeps{$nativedep}{minimum_version}", "\n";
}
if ($nativedeps{$nativedep}{maximum_version})
{
- print $xmlfh " <maximum_version>$nativedeps{$nativedep}{maximum_version}</maximum_version>", "\n";
+ print $ymlfh " maximum_version: $nativedeps{$nativedep}{maximum_version}", "\n";
}
- print $xmlfh ' <native/>', "\n";
- print $xmlfh ' </dependency>', "\n";
+ print $ymlfh ' native: true', "\n";
}
# Insert an appropriate dependency on Perl itself
- print $xmlfh ' <dependency>', "\n";
- print $xmlfh " <name>perl</name>", "\n";
- print $xmlfh " <minimum_version>", sprintf("%vd", $^V), "</minimum_version>", "\n";
- print $xmlfh " <maximum_version>$majordotminor.9999</maximum_version>", "\n";
- print $xmlfh ' </dependency>', "\n";
- print $xmlfh ' </dependencies>', "\n";
- print $xmlfh '</tpkg>', "\n";
+ print $ymlfh ' - name: perl', "\n";
+ print $ymlfh ' minimum_version: ', sprintf("%vd", $^V), "\n";
+ print $ymlfh " maximum_version: $majordotminor.9999", "\n";
# Build package
system("tpkg --make $tpkgdir");
}
# Pass in an expanded module (CPAN::Shell->expand), get back a name