mirror of
https://github.com/Project-OSS-Revival/alien.git
synced 2026-04-24 14:00:17 +00:00
* Removed an obsolete note from the man page.
* Set locale to C while using rpm to pick at the .rpm file we are going to
convert, Closes: #42282
* Moved /usr/lib/alien to /usr/share/alien
* Added --nopatch option, Closes: #47069
This commit is contained in:
@@ -28,16 +28,20 @@ sub GetFields { my ($self,$file)=@_;
|
||||
# These fields need no translation.
|
||||
my $field;
|
||||
foreach $field ('NAME','VERSION','RELEASE','ARCH','CHANGELOGTEXT','SUMMARY',
|
||||
'DESCRIPTION', 'COPYRIGHT', 'DEFAULTPREFIX') {
|
||||
'DESCRIPTION', 'COPYRIGHT', 'PREFIXES') {
|
||||
$fieldtrans{$field}=$field;
|
||||
}
|
||||
|
||||
# Use --queryformat to pull out all the fields we need.
|
||||
foreach $field (keys(%fieldtrans)) {
|
||||
$_=`rpm -qp $file --queryformat \%{$field}`;
|
||||
$_=`LANG=C rpm -qp $file --queryformat \%{$field}`;
|
||||
$fields{$fieldtrans{$field}}=$_ if $_ ne '(none)';
|
||||
}
|
||||
|
||||
# DEFAULTPREFIX is special because it only exists in old versions of rpm.
|
||||
$_=`rpm -qp $file --queryformat \%{PREFIXES} 2>/dev/null`;
|
||||
$fields{PREFIXES}=$_ if $_ ne '' && $_ ne '(none)';
|
||||
|
||||
if ($main::scripts) {
|
||||
# Fix up the scripts - they are always shell scripts, so make them so.
|
||||
foreach $field ('PREINST','POSTINST','PRERM','POSTRM') {
|
||||
@@ -46,13 +50,14 @@ sub GetFields { my ($self,$file)=@_;
|
||||
}
|
||||
|
||||
# Get the conffiles list.
|
||||
# TOCHECK: if this is a relocatable package and DEFAULTPREFIX is set,
|
||||
# do we need to prepend DEFAULTPREFIX to each of these filenames?
|
||||
$fields{CONFFILES}=`rpm -qcp $file`;
|
||||
|
||||
# Include the output of rpm -qi in the copyright file.
|
||||
$fields{COPYRIGHT_EXTRA}=`rpm -qpi $file`;
|
||||
|
||||
# Get the filelist, it's used in the parent directory check in Unpack().
|
||||
$fields{FILELIST}=`rpm -qpl $file`;
|
||||
|
||||
# Sanity check fields.
|
||||
if (!$fields{SUMMARY}) {
|
||||
# Older rpms will have no summary, but will have a
|
||||
@@ -89,6 +94,17 @@ sub GetFields { my ($self,$file)=@_;
|
||||
$fields{ARCH}='all';
|
||||
}
|
||||
|
||||
# Treat 486, 586, etc, as 386.
|
||||
if ($fields{ARCH}=~m/i\d86/) {
|
||||
$fields{ARCH}='i386';
|
||||
}
|
||||
|
||||
|
||||
# Treat ppc as powerpc.
|
||||
if ($fields{ARCH} eq 'ppc') {
|
||||
$fields{ARCH} = 'powerpc';
|
||||
}
|
||||
|
||||
if ($fields{RELEASE} eq undef || $fields{VERSION} eq undef|| !$fields{NAME}) {
|
||||
Alien::Error("Error querying rpm file.");
|
||||
}
|
||||
@@ -103,26 +119,63 @@ sub GetFields { my ($self,$file)=@_;
|
||||
sub Unpack { my ($self,$file,%fields)=@_;
|
||||
Alien::SafeSystem("(cd ..;rpm2cpio $file) | cpio --extract --make-directories --no-absolute-filenames --preserve-modification-time",
|
||||
"Error unpacking $file\n");
|
||||
if ($fields{DEFAULTPREFIX} ne undef) {
|
||||
print "Moving unpacked files into $fields{DEFAULTPREFIX}\n";
|
||||
|
||||
# We have extracted the package, but it's in the wrong place. Move it
|
||||
# to be under the DEFAULTPREFIX directory.
|
||||
# First, get a list of files to move.
|
||||
|
||||
# If the package is relocatable. We'd like to move it to be under the
|
||||
# PREFIXES directory. However, it's possible that that directory is in the
|
||||
# package - it seems some rpm's are marked as relocatable and unpack already
|
||||
# in the directory they can relocate to, while some are marked relocatable
|
||||
# and the directory they can relocate to is removed from all filenames in the
|
||||
# package. I suppose this is due to some change between versions of rpm, but
|
||||
# none of this is adequatly documented, so we'll just muddle through.
|
||||
#
|
||||
# Test to see if the package contains the PREFIXES directory already.
|
||||
if ($fields{PREFIXES} ne undef && ! -e "./$fields{PREFIXES}") {
|
||||
print "Moving unpacked files into $fields{PREFIXES}\n";
|
||||
|
||||
# Get the files to move.
|
||||
my $filelist=join ' ',glob('*');
|
||||
|
||||
|
||||
# Now, make the destination directory.
|
||||
my $collect=undef;
|
||||
foreach (split(m:/:,$fields{DEFAULTPREFIX})) {
|
||||
foreach (split(m:/:,$fields{PREFIXES})) {
|
||||
if ($_ ne undef) { # this keeps us from using anything but relative paths.
|
||||
$collect.="$_/";
|
||||
mkdir $collect,0755 || Alien::Error("Unable to make directory: $collect: $!");
|
||||
}
|
||||
}
|
||||
# Now move all files in the package to the directory we made.
|
||||
Alien::SafeSystem("mv $filelist ./$fields{DEFAULTPREFIX}",
|
||||
Alien::SafeSystem("mv $filelist ./$fields{PREFIXES}",
|
||||
"Error moving unpacked files into the default prefix directory\n");
|
||||
}
|
||||
|
||||
# When cpio extracts the file, any child directories that are present, but
|
||||
# whose parent directories are not, end up mode 700. This next block corrects
|
||||
# that to 755, which is more reasonable.
|
||||
#
|
||||
# Of course, this whole thing assumes we get the filelist in sorted order.
|
||||
my $lastdir=undef;
|
||||
foreach $file (split(/\n/,$fields{FILELIST})) {
|
||||
$file=~s/^\///;
|
||||
if (($lastdir && $file=~m:^\Q$lastdir\E/[^/]*$: eq undef) || !$lastdir) {
|
||||
# We've found one of the nasty directories. Fix it up.
|
||||
#
|
||||
# Note that I strip the trailing filename off $file here, for two
|
||||
# reasons. First, it makes the loop easier, we don't need to fix the
|
||||
# perms on the last file, after all! Second, it makes the -d test below
|
||||
# fire, which saves us from trying to fix a parent directory twice.
|
||||
($file)=$file=~m:(.*)/.*?:;
|
||||
my $dircollect=undef;
|
||||
my $dir;
|
||||
foreach $dir (split(/\//,$file)) {
|
||||
$dircollect.="$dir/";
|
||||
chmod 0755,$dircollect; # TADA!
|
||||
}
|
||||
}
|
||||
if (-d "./$file") {
|
||||
$lastdir=$file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
|
||||
|
||||
17
lib/Todeb.pm
17
lib/Todeb.pm
@@ -14,6 +14,17 @@ sub FixFields { my ($self,%fields)=@_;
|
||||
$fields{NAME} =~ tr/_/-/;
|
||||
$fields{NAME} =~ s/[^a-z0-9-\.\+]//g;
|
||||
|
||||
# make sure the version contains digets.
|
||||
if ($fields{VERSION} !~ m/[0-9]/) {
|
||||
# drat. well, add some. dpkg-deb won't work
|
||||
# on a version w/o numbers.
|
||||
$fields{VERSION}.="0";
|
||||
}
|
||||
# same with revision.
|
||||
if ($fields{RELEASE} !~ m/[0-9]/) {
|
||||
$fields{RELEASE}.="-1";
|
||||
}
|
||||
|
||||
# Fix up the description field to Debian standards (indented at
|
||||
# least one space, no empty lines.)
|
||||
my $description=undef;
|
||||
@@ -36,7 +47,7 @@ sub FixFields { my ($self,%fields)=@_;
|
||||
}
|
||||
|
||||
# Create debian/* files, either from a patch, or automatically.
|
||||
sub Convert { my ($self,$workdir,%fields)=@_;
|
||||
sub Convert { my ($self,$workdir,$nopatch,%fields)=@_;
|
||||
if ($main::generate && !$main::single) {
|
||||
Alien::SafeSystem("cp -fa $workdir $workdir.orig", "Error creating $workdir.orig");
|
||||
}
|
||||
@@ -46,7 +57,7 @@ sub Convert { my ($self,$workdir,%fields)=@_;
|
||||
|| Alien::Error("Unable to make debian directory");
|
||||
my $patchfile=$main::patchfile;
|
||||
$patchfile=Alien::GetPatch($fields{NAME},$fields{VERSION},$fields{RELEASE}) if !$patchfile;
|
||||
if ($patchfile) {
|
||||
if ($patchfile && ! $nopatch) {
|
||||
Alien::Patch($patchfile,$workdir);
|
||||
}
|
||||
else {
|
||||
@@ -87,7 +98,7 @@ sub AutoDebianize { my ($self,$workdir,%fields)=@_;
|
||||
foreach $script ('postinst','postrm','preinst','prerm') {
|
||||
if ($fields{uc($script)}) {
|
||||
open (OUT,">$workdir/debian/$script") ||
|
||||
Alien::Error("$workdir/debian/$script: $!");;
|
||||
Alien::Error("$workdir/debian/$script: $!");
|
||||
print OUT $fields{uc($script)};
|
||||
close OUT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user