From aa4c9a8b71000c3132ca26844d273843c8e5c123 Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 21 Apr 2000 06:40:08 +0000 Subject: [PATCH] renamed a method, plus, building now fully works for deb's --- Alien/Package.pm | 19 ++++++++++++++++--- Alien/Package/Deb.pm | 35 +++++++++++++++++++++++++++-------- Alien/Package/Rpm.pm | 3 ++- debian/changelog | 3 ++- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/Alien/Package.pm b/Alien/Package.pm index 48f979e..96f288d 100644 --- a/Alien/Package.pm +++ b/Alien/Package.pm @@ -160,7 +160,8 @@ sub init {} =item install -Simply installs the package. This has to be overridden in child classes. +Simply installs a package file. The filename is passed on standard input. +This has to be overridden in child classes. =cut @@ -168,7 +169,7 @@ sub install { my $this=shift; } -=item read_file +=item scan This method looks at the actual package file the package represents, and populates all the fields it can from that package file. The filename field @@ -179,7 +180,7 @@ something.) =cut -sub read_file { +sub scan { my $this=shift; my $file=$this->filename; @@ -221,6 +222,18 @@ to produce a suitable build tree. sub prep {} +=item build + +This method takes a prepped build tree, and simply builds a package from +it. It should put the package in the current directory, and should return +the filename of the generated package. + +(This is just a stub method that all child classes should override.) + +=cut + +sub build {} + =item DESTROY When an object is destroyed, it cleans some stuff up. In particular, if the diff --git a/Alien/Package/Deb.pm b/Alien/Package/Deb.pm index bcee10e..4987472 100644 --- a/Alien/Package/Deb.pm +++ b/Alien/Package/Deb.pm @@ -52,24 +52,25 @@ sub init { =item install -Install a deb with dpkg. +Install a deb with dpkg. Pass in the filename of the deb to install. =cut sub install { my $this=shift; + my $deb=shift; - system("dpkg --no-force-overwrite -i ".$this->filename) && + system("dpkg --no-force-overwrite -i $deb") && die "Unable to install: $!"; } -=item read_file +=item scan -Implement the read_file method to read a deb file. +Implement the scan method to read a deb file. =cut -sub read_file { +sub scan { my $this=shift; $this->SUPER::read_file(@_); my $file=$this->filename; @@ -196,7 +197,7 @@ file. sub prep { my $this=shift; - my $dir=$this->unpacked_tree; + my $dir=$this->unpacked_tree || die "The package must be unpacked first!"; mkdir "$dir/debian", 0755 || die "mkdir $dir/debian failed: $!"; @@ -239,7 +240,7 @@ sub prep { print OUT "Depends: \${shlibs:Depends}\n"; print OUT "Description: ".$this->summary."\n"; print OUT $this->description."\n"; - print OUT ".\n" + print OUT ".\n"; print OUT " (Converted from a .".$this->origformat." package by alien.)\n"; close OUT; @@ -322,6 +323,22 @@ EOF } } +=item build + +Build a .deb + +=cut + +sub build { + my $this=shift; + + chdir $this->unpacked_tree; + system("debian/rules binary") && die "package build failed: $!"; + chdir ".."; + + return $this->name."_".$this->version."-".$this->release."_".$this->arch.".deb"; +} + =item package Set/get package name. @@ -498,9 +515,11 @@ sub username { $username=~s/,.*//g; # The ultimate fallback. - if (!$username) { + if ($username eq '') { $username=$login; } + + return $username; } =head1 AUTHOR diff --git a/Alien/Package/Rpm.pm b/Alien/Package/Rpm.pm index 27fb8bd..edff27e 100644 --- a/Alien/Package/Rpm.pm +++ b/Alien/Package/Rpm.pm @@ -37,8 +37,9 @@ it are passed to rpm on its command line. sub install { my $this=shift; + my $rpm=shift; - system("rpm -ivh $ENV{RPMINSTALLOPT} ".$this->filename) && + system("rpm -ivh $ENV{RPMINSTALLOPT} $rpm") && die "Unable to install: $!"; } diff --git a/debian/changelog b/debian/changelog index f11370d..36a832d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,7 +10,7 @@ alien (6.99) unstable; urgency=low one: perl -e 'use Alien::Package::Deb; use Alien::Package::Rpm; \ $p=Alien::Package::Rpm->new(filename => shift); - $p->read_file; $p->unpack; + $p->scan; $p->unpack; bless($p, "Alien::Package::Deb"); $p->prep; $p->build;' * Almost every line of code has been rewritten. @@ -19,6 +19,7 @@ alien (6.99) unstable; urgency=low instance, generated .deb's now have more info in their copyright file. * The template files were all moved inside the objects, which is actually cleaner and is certainly easier to deal with. + * Usernames are now looked up the way POSIX intended. -- Joey Hess Thu, 20 Apr 2000 18:52:41 -0700