source: devel/pb/lib/distro.pm @ 22

Last change on this file since 22 was 22, checked in by bruno, 12 years ago

Begin to work on pkg2build
Cope the module Linux::Distribution in the project as it's not packages for my distro
Will make delivery much easier.

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/usr/bin/perl -w
2#
3# Creates common environment for distributions
4#
5# $Id$
6#
7
8use strict;
9use LinuxDistribution qw (distribution_name distribution_version);
10
11sub distro_init {
12
13my $ddir = shift;
14my $dver = shift;
15my $dfam = "unknown";
16my $dtype = "unknown";
17my $dsuf = "unknown";
18
19# If we don't know which distribution we're on, then guess it
20$ddir = distribution_name() if (not defined $ddir);
21$dver = distribution_version() if (not defined $dver);
22
23# There shold be unicity of names between ddir dfam and dtype
24# In case of duplicate, bad things can happen
25if (($ddir =~ /debian/) ||
26    ($ddir =~ /ubuntu/)) {
27    $dfam="du";
28    $dtype="deb";
29    $dsuf=".$ddir$dver";
30} elsif ($ddir =~ /gentoo/) {
31    $dfam="gen";
32    $dtype="ebuild";
33    my $dver1 = $dver;
34    $dver1 =~ s/\.//;
35    $dsuf=".$ddir$dver1";
36} elsif ($ddir =~ /slackware/) {
37    $dfam="slack";
38    $dtype="tgz";
39    $dsuf=".$dfam$dver";
40} elsif (($ddir =~ /suse/) ||
41        ($ddir =~ /sles/)) {
42    $dfam="novell";
43    $dtype="rpm";
44    $dsuf=".$ddir$dver";
45} elsif (($ddir =~ /redhat/) ||
46        ($ddir =~ /rhel/) ||
47        ($ddir =~ /fedora/) ||
48        ($ddir =~ /centos/)) {
49    $dfam="rh";
50    $dtype="rpm";
51    my $dver1 = $dver;
52    $dver1 =~ s/\.//;
53    if ($ddir =~ /fedora/) {
54        $dsuf=".fc$dver1";
55    } elsif ($ddir =~ /redhat/) {
56        $dsuf=".rh$dver1";
57    } else {
58        $dsuf=".$ddir$dver1";
59    }
60} elsif (($ddir =~ /mandrake/) ||
61        ($ddir =~ /mandriva/)) {
62    $dfam="md";
63    $dtype="rpm";
64    if ($ddir =~ /mandrake/) {
65        my $dver1 = $dver;
66        $dver1 =~ s/\.//;
67        $dsuf=".mdk$dver1";
68    } else {
69        $dsuf=".mdv$dver";
70    }
71} elsif ($ddir =~ /freebsd/) {
72    $dfam="bsd";
73    $dtype="port";
74    my $dver1 = $dver;
75    $dver1 =~ s/\.//;
76    $dsuf=".$dfam$dver1";
77} else {
78    $dfam="unknown";
79    $dtype="unknown";
80    $dsuf="unknown";
81}
82
83return($ddir, $dver, $dfam, $dtype, $dsuf);
84}
851;
Note: See TracBrowser for help on using the repository browser.