Changeset 867


Ignore:
Timestamp:
10/21/09 11:48:11 (4 years ago)
Author:
bruno
Message:
  • Transition static distribution into a configuration file typically /etc/pb/pb.conf
  • function pb_distro_init adapted to use the new conf file
  • function pb_distro_get_param adapted to support osfamily and ostype
  • Adapt the package building of pb to the need of the new configuration file
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/Makefile.PL

    r539 r867  
    11use 5.006001; 
    22use ExtUtils::MakeMaker; 
     3use strict; 
    34 
    45# See lib/ExtUtils/MakeMaker.pm for details of how to influence 
    56# the contents of the Makefile that is written. 
    67WriteMakefile( 
    7     NAME         => 'PBPKG', 
    8     DISTNAME     => 'PBPKG', 
    9     VERSION      => 'PBVER', 
    10     INST_SCRIPT  => 'blib/bin', 
     8    NAME         => 'PBPKG', 
     9    DISTNAME     => 'PBPKG', 
     10    VERSION      => 'PBVER', 
     11    INST_SCRIPT  => 'blib/bin', 
    1112    INSTALLDIRS  => 'perl', 
    12     PREREQ_PM    => { 
     13    PREREQ_PM    => { 
    1314            #HTTP::Headers                    => 1.59, 
    1415            #Template                         => 0, 
    15     },    # e.g., Module::Name => 1.1 
     16    },    # e.g., Module::Name => 1.1 
    1617    #ABSTRACT_FROM => 'bin/pb',   # retrieve abstract from module 
    17     AUTHOR        => 'Bruno Cornec <bruno#project-builder.org>', 
     18    AUTHOR        => 'Bruno Cornec <bruno#project-builder.org>', 
    1819    EXE_FILES     => [ qw( bin/pbdistrocheck ) ], 
    1920    MAN3PODS      => {  'lib/ProjectBuilder/Distribution.pm' => '$(INST_MAN3DIR)/ProjectBuilder::Distribution.$(MAN3EXT)', 
     
    2223                        'lib/ProjectBuilder/Base.pm' => '$(INST_MAN3DIR)/ProjectBuilder::Base.$(MAN3EXT)', }, 
    2324); 
     25 
     26package MY; 
     27 
     28sub postamble { 
     29 
     30    # Determine location of etc conf files 
     31    my $text =""; 
     32 
     33    # Grab out any CONFDIR param 
     34    my $confdir = undef; 
     35 
     36    while (my $arg = shift @ARGV) { 
     37        my ($key, $value) = split /=/, $arg; 
     38        if ($key =~ /^CONFDIR$/) { 
     39            $confdir = $value; 
     40        } 
     41    } 
     42 
     43    my $etcdir = $confdir || "/usr/local/etc/pb"; 
     44 
     45    # Use that conf dir info to modify Distribution.pm 
     46    system("perl -pi -e \"s~CCCC~$etcdir~\" lib/ProjectBuilder/Distribution.pm"); 
     47 
     48    $text .= "install ::\n"; 
     49    $text .= "\t".'install -m 755 -d $(DESTDIR)'."$etcdir\n"; 
     50    $text .= "\t".'cp etc/pb.conf $(DESTDIR)'."$etcdir\n"; 
     51    return($text); 
     52} 
  • devel/pb-modules/etc/pb.conf

    r866 r867  
    1414# 
    1515# It should be noted that the list of all OS is the result of gathering  
    16 # all the keys from osrelfile and osrelambfile 
    17 # 
    18  
     16# all the keys from osrelfile and osrelambfile, and the values of osrelambfile 
     17# 
     18 
     19# 
     20# The following conf info are for pb_distro_get (man ProjectBuilder::Distribution) 
    1921# 
    2022# Those definitions are non-ambiguous (the file only exists for that OS) 
     
    131133osrelexpr solaris = Solaris (\d+)  
    132134 
     135# 
     136# The following conf info are for pb_distro_init (man ProjectBuilder::Distribution) 
     137# 
    133138# Ganularity is the following: 
    134139# 
     
    140145 
    141146# Group OS by family to handle common actions more easily (filtering, install command, ...) 
     147# Key is osname, Value is osfamily 
    142148osfamily debian = du 
    143149osfamily ubuntu = du 
     
    158164osfamily freebsd = bsd 
    159165osfamily solaris = sol 
    160 osfamily unknown = unknown 
    161166 
    162167# Group family by build types 
     168# Key is osfamily, Value is build type 
    163169ostype du = deb 
    164170ostype slack = tgz 
     
    169175ostype bsd = port 
    170176ostype sol = pkg 
    171 ostype unknown = unknown 
    172177 
    173178# From the most generic to the most specialized, in term of granularity, 
    174179# give the command to use to install on the OS 
    175180# If none is given, no install can takes place 
     181# key depends on granularity, value is install command 
     182 
     183# Chaining the commands allow to only test for what is able to be installed,  
     184# not the update of the repo which may well be unaccessible if too old 
    176185osupd du = sudo apt-get update ; sudo apt-get -y install  
    177186osupd gen = sudo emerge  
     
    182191osupd md = sudo urpmi.update -a ; sudo urpmi --auto  
    183192osupd novell = export TERM=linux ; export PATH=\$PATH:/sbin:/usr/sbin ; sudo yast2 -i  
    184 osupd unknown = unknown 
    185193 
    186194# From the most generic to the most specialized, in term of granularity, 
     
    189197# .osname and version  
    190198# osname being as defined upper as the keys of osrelfile and osrelambfile 
     199# depends on granularity, value is install command 
    191200 
    192201ossuffix slackware = slack 
     
    199208 
    200209# For that OS no need to keep the version 
     210# Key depends on granularity, value is boolean 
    201211osnover gentoo = true 
    202212 
    203 #  For that OS no need to keep the . in the version release 
     213# For that OS no need to keep the . in the version release 
     214# Key depends on granularity, value is boolean 
    204215osremovedotinver mandrake = true 
    205216osremovedotinver redhat = true 
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r768 r867  
    8484my $dsuf = "unknown"; 
    8585my $dupd = "unknown"; 
    86 my $arch = shift || undef; 
     86my $darch = shift || undef; 
     87my $dnover = "false"; 
     88my $drmdot = "false"; 
    8789 
    8890# If we don't know which distribution we're on, then guess it 
     
    9092 
    9193# Initialize arch 
    92 $arch=pb_get_arch() if (not defined $arch); 
    93  
    94 # There should be unicity of names between ddir dfam and dtype 
    95 # In case of duplicate, bad things can happen 
    96 if (($ddir =~ /debian/) || 
    97     ($ddir =~ /ubuntu/)) { 
    98     $dfam="du"; 
    99     $dtype="deb"; 
    100     $dsuf=".$ddir$dver"; 
    101     # Chaining the commands allow to only test for what is able o be installed,  
    102     # not the update of the repo which may well be unaccessible if too old 
    103     $dupd="sudo apt-get update ; sudo apt-get -y install "; 
    104 } elsif ($ddir =~ /gentoo/) { 
    105     $dfam="gen"; 
    106     $dtype="ebuild"; 
    107     $dver="nover"; 
    108     $dsuf=".$ddir"; 
    109     $dupd="sudo emerge "; 
    110 } elsif ($ddir =~ /slackware/) { 
    111     $dfam="slack"; 
    112     $dtype="tgz"; 
    113     $dsuf=".$dfam$dver"; 
    114 } elsif (($ddir =~ /suse/) || 
    115         ($ddir =~ /sles/)) { 
    116     $dfam="novell"; 
    117     $dtype="rpm"; 
    118     $dsuf=".$ddir$dver"; 
    119     $dupd="export TERM=linux ; export PATH=\$PATH:/sbin:/usr/sbin ; sudo yast2 -i "; 
    120 } elsif (($ddir =~ /redhat/) || 
    121         ($ddir =~ /rhel/) || 
    122         ($ddir =~ /fedora/) || 
    123         ($ddir =~ /vmware/) || 
    124         ($ddir =~ /asianux/) || 
    125         ($ddir =~ /centos/)) { 
    126     $dfam="rh"; 
    127     $dtype="rpm"; 
    128     my $dver1 = $dver; 
    129     $dver1 =~ s/\.//; 
    130  
    131     # By defaut propose yum 
    132     my $opt = ""; 
    133     if ($arch eq "x86_64") { 
    134         $opt="--exclude=*.i?86"; 
    135     } 
    136     $dupd="sudo yum clean all; sudo yum -y update ; sudo yum -y $opt install "; 
    137     if ($ddir =~ /fedora/) { 
    138         $dsuf=".fc$dver1"; 
    139     } elsif ($ddir =~ /redhat/) { 
    140         $dsuf=".rh$dver1"; 
    141         $dupd="unknown"; 
    142     } elsif ($ddir =~ /asianux/) { 
    143         $dsuf=".asianux$dver1"; 
    144     } elsif ($ddir =~ /vmware/) { 
    145         $dsuf=".vwm$dver1"; 
    146         $dupd="unknown"; 
    147     } else { 
    148         # older versions of rhel ran up2date 
    149         if ((($dver eq "2.1") || ($dver eq "3") || ($dver eq "4")) && ($ddir eq "rhel")) { 
    150             $dupd="sudo up2date -y "; 
    151         } 
    152         $dsuf=".$ddir$dver1"; 
    153     } 
    154 } elsif (($ddir =~ /mandrake/) || 
    155         ($ddir =~ /mandrakelinux/) || 
    156         ($ddir =~ /mandriva/)) { 
    157     $dfam="md"; 
    158     $dtype="rpm"; 
    159     if ($ddir =~ /mandrakelinux/) { 
    160         $ddir = "mandrake"; 
    161     } 
    162     if ($ddir =~ /mandrake/) { 
    163         my $dver1 = $dver; 
    164         $dver1 =~ s/\.//; 
    165         $dsuf=".mdk$dver1"; 
    166     } else { 
    167         $dsuf=".mdv$dver"; 
    168     } 
    169     # Chaining the commands allow to only test for what is able o be installed,  
    170     # not the update of the repo which may well be unaccessible if too old 
    171     $dupd="sudo urpmi.update -a ; sudo urpmi --auto "; 
    172 } elsif ($ddir =~ /freebsd/) { 
    173     $dfam="bsd"; 
    174     $dtype="port"; 
    175     my $dver1 = $dver; 
    176     $dver1 =~ s/\.//; 
    177     $dsuf=".$dfam$dver1"; 
     94$darch=pb_get_arch() if (not defined $darch); 
     95 
     96# Adds conf file for distribution description 
     97# the location of the conf file is finalyzed at install time 
     98# depending whether we deal with package install or tar file install 
     99pb_conf_add("CCCC/pb.conf"); 
     100my ($osfamily,$ostype,$osupd,$ossuffix,$osnover,$osremovedotinver) = pb_conf_get("osfamily","ostype","osupd","ossuffix","osnover","osremovedotinver"); 
     101 
     102$dfam = pb_distro_get_param($ddir,$dver,$darch,$osfamily); 
     103$dtype = $ostype->{$dfam} if (defined $ostype->{$dfam}); 
     104$dupd = pb_distro_get_param($ddir,$dver,$darch,$osupd,$dfam,$dtype); 
     105$dsuf = pb_distro_get_param($ddir,$dver,$darch,$ossuffix,$dfam,$dtype); 
     106$dnover = pb_distro_get_param($ddir,$dver,$darch,$osnover,$dfam,$dtype); 
     107$drmdot = pb_distro_get_param($ddir,$dver,$darch,$osremovedotinver,$dfam,$dtype); 
     108 
     109# Some OS have no interesting version 
     110$dver = "nover" if ($dnover eq "true"); 
     111 
     112# For some OS remove the . in version name 
     113$dver =~ s/\.// if ($drmdot eq "true"); 
     114 
     115if ((not defined $dsuf) || ($dsuf eq "unknown")) { 
     116    # By default suffix is a concatenation of .ddir and dver 
     117    $dsuf = ".$ddir$dver"  
    178118} else { 
    179     $dfam="unknown"; 
    180 } 
    181  
    182 return($ddir, $dver, $dfam, $dtype, $dsuf, $dupd, $arch); 
     119    # concat just the version to what has been found 
     120    $dsuf = ".$dsuf$dver"; 
     121} 
     122 
     123#   if ($arch eq "x86_64") { 
     124#   $opt="--exclude=*.i?86"; 
     125#   } 
     126 
     127return($ddir, $dver, $dfam, $dtype, $dsuf, $dupd, $darch); 
    183128} 
    184129 
     
    557502my $darch = shift; 
    558503my $opt = shift; 
     504my $dfam = shift || "unknown"; 
     505my $dtype = shift || "unknown"; 
    559506 
    560507if (defined $opt->{"$ddir-$dver-$darch"}) { 
     
    564511} elsif (defined $opt->{"$ddir"}) { 
    565512    $param = $opt->{"$ddir"}; 
     513} elsif (defined $opt->{$dfam}) { 
     514    $param = $opt->{$dfam}; 
     515} elsif (defined $opt->{$dtype}) { 
     516    $param = $opt->{$dtype}; 
    566517} elsif (defined $opt->{"default"}) { 
    567518    $param = $opt->{"default"}; 
    568519} else { 
    569     $param = ""; 
     520    $param = "unknown"; 
    570521} 
    571522return($param); 
  • pbconf/devel/ProjectBuilder/deb/project-builder.dirs

    r380 r867  
    22usr/share/perl 
    33usr/share/man 
     4etc/pb 
  • pbconf/devel/ProjectBuilder/deb/rules

    r541 r867  
    3535 
    3636        # Add here commands to compile the package. 
    37         perl Makefile.PL 
     37        perl Makefile.PL CONFDIR=/etc/pb 
    3838        $(MAKE) 
    3939        touch $@ 
  • pbconf/devel/ProjectBuilder/rpm/perl-ProjectBuilder.spec

    r637 r867  
    3030 
    3131%build 
    32 %{__perl} Makefile.PL INSTALLDIRS=vendor PBKEYWORD=${RPM_BUILD_ROOT}/PBFINALDIR 
     32%{__perl} Makefile.PL INSTALLDIRS=vendor PBKEYWORD=${RPM_BUILD_ROOT}/PBFINALDIR CONFDIR=%{_sysconfdir}/pb 
    3333make 
    3434 
     
    5454#%{_mandir}/man1/* 
    5555%{_mandir}/man3/* 
     56%{_sysconfdir}/pb 
    5657 
    5758%changelog 
Note: See TracChangeset for help on using the changeset viewer.