Changeset 316


Ignore:
Timestamp:
02/10/08 14:36:32 (5 years ago)
Author:
bruno
Message:
  • pb_get_pkg moved to Base and used in newver
  • some log improvements.
  • tests to follow
Location:
devel/pb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r315 r316  
    2323use ProjectBuilder::Distribution qw (pb_distro_init); 
    2424use ProjectBuilder::Version qw (pb_version_init); 
    25 use ProjectBuilder::Base qw (pb_conf_read pb_conf_get pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_filter_file_inplace pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout pb_get_date pb_log pb_log_init); 
     25use ProjectBuilder::Base qw (pb_conf_read pb_conf_get pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_filter_file_inplace pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout pb_get_date pb_log pb_log_init pb_get_pkg); 
    2626 
    2727my %opts;                   # CLI Options 
     
    857857} 
    858858 
    859 #  
    860 # Return the list of packages we are working on 
    861 # 
    862 sub pb_get_pkg { 
    863  
    864 my @pkgs; 
    865 my $defpkgdir = shift; 
    866 my $extpkgdir = shift; 
    867  
    868 # Get packages list 
    869 if (not defined $ARGV[0]) { 
    870     @pkgs = keys %$defpkgdir; 
    871 } elsif ($ARGV[0] =~ /^all$/) { 
    872     @pkgs = keys %$defpkgdir; 
    873     push(@pkgs, keys %$extpkgdir); 
    874 } else { 
    875     @pkgs = @ARGV; 
    876 } 
    877 pb_log(2,"Packages: ".join(',',@pkgs)."\n"); 
    878 return(\@pkgs); 
    879 } 
    880  
    881859# 
    882860# Return the list of VMs we are working on 
  • devel/pb/lib/ProjectBuilder/Base.pm

    r315 r316  
    5252    $proj = (keys %pbconf)[0]; 
    5353    if (defined $proj) { 
    54         pb_log(2,"WARNING: using $proj as default project as none has been specified\n"); 
    55         pb_log(2,"Please create a pbconf reference for project $proj in $ENV{'PBETC'}\nif you want to use another project\n"); 
     54        pb_log(0,"WARNING: using $proj as default project as none has been specified\n"); 
     55        pb_log(0,"Please create a pbconf reference for project $proj in $ENV{'PBETC'}\nif you want to use another project\n"); 
    5656    } 
    5757} 
     
    101101 
    102102if (not defined $ENV{'PBDIR'}) { 
    103     if (not defined ($pbdir{$ENV{'PBPROJ'}})) { 
    104         pb_log(2,"WARNING: no pbdir defined, using /var/cache\n"); 
    105         pb_log(2,"Please create a pbdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\nif you want to use another directory\n"); 
    106     } 
    107     # That's always the environment variable that will be used 
    108     $ENV{'PBDIR'} = $pbdir{$ENV{'PBPROJ'}}; 
     103    if ((not defined $pbdir) || (not defined $pbdir{$ENV{'PBPROJ'}})) { 
     104        pb_log(0,"WARNING: no pbdir defined, using /var/cache\n"); 
     105        pb_log(0,"Please create a pbdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\nif you want to use another directory\n"); 
     106        $ENV{'PBDIR'} = "/var/cache"; 
     107    } else { 
     108        # That's always the environment variable that will be used 
     109        $ENV{'PBDIR'} = $pbdir{$ENV{'PBPROJ'}}; 
     110    } 
    109111} 
    110112# Expand potential env variable in it 
     
    160162 
    161163if ((not -d "$ENV{'PBCONF'}") || (defined $pbinit)) { 
     164    pb_log(1,"Checking out pbconf\n"); 
    162165    pb_cms_checkout($scheme,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'}); 
    163166} else { 
     167    pb_log(1,"pbconf found, checking content\n"); 
    164168    my $cmsurl = pb_cms_getinfo($scheme,$ENV{'PBCONF'},"URL:"); 
    165169    if ($cmsurl !~ /^$scheme/) { 
     170        pb_log(1,"Content irrelevant, cleaning up and checking it out\n"); 
    166171        pb_rm_rf("$ENV{'PBCONF'}"); 
    167172        pb_cms_checkout($scheme,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'}); 
    168173    } elsif ($cmsurl ne $pbconf{$ENV{'PBPROJ'}}) { 
    169174        # The local content doesn't correpond to the repository 
    170         pb_log(2,"ERROR: Inconsistency detected:\n"); 
    171         pb_log(2,"* $ENV{'PBCONF'} refers to $cmsurl but\n"); 
    172         pb_log(2,"* $ENV{'PBETC'} refers to $pbconf{$ENV{'PBPROJ'}}\n"); 
     175        pb_log(0,"ERROR: Inconsistency detected:\n"); 
     176        pb_log(0,"* $ENV{'PBCONF'} refers to $cmsurl but\n"); 
     177        pb_log(0,"* $ENV{'PBETC'} refers to $pbconf{$ENV{'PBPROJ'}}\n"); 
    173178        die "Project $ENV{'PBPROJ'} is not Project-Builder compliant."; 
    174179    } else { 
     180        pb_log(1,"Content correct - doing nothing - you may want to update your repository however\n"); 
    175181        # they match - do nothing - there may be local changes 
    176182    } 
     
    194200        } 
    195201        closedir(DIR); 
    196         pb_log(2,"WARNING: no pbroot defined, using $ENV{'PBROOT'}\n"); 
    197         pb_log(2,"Please -r release if you want to use another release\n"); 
     202        die "No directory found under $ENV{'PBCONF'}" if (not defined $ENV{'PBROOT'}); 
     203        pb_log(0,"WARNING: no pbroot defined, using $ENV{'PBROOT'}\n"); 
     204        pb_log(0,"Please use -r release if you want to use another release\n"); 
    198205    } else { 
    199206        my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot"); 
    200207        # That's always the environment variable that will be used 
     208        die "Please remove inconsistent $ENV{'PBDESTDIR'}/pbrc" if ((not defined $pbroot) || (not defined $pbroot->{$ENV{'PBPROJ'}})); 
    201209        $ENV{'PBROOT'} = $pbroot->{$ENV{'PBPROJ'}}; 
    202210    } 
    203211} else { 
    204212    # transform in full path if relative 
    205     $ENV{'PBROOT'} = "$ENV{'PBCONF'}/$ENV{'PBROOT'}" if ($ENV{'PBROOT'} !~ /\//); 
     213    $ENV{'PBROOT'} = "$ENV{'PBCONF'}/$ENV{'PBROOT'}" if ($ENV{'PBROOT'} !~ /^\//); 
     214    die "$ENV{'PBROOT'} is not a directory" if (not -d $ENV{'PBROOT'}); 
    206215} 
    207216 
     
    253262} else { 
    254263    if (defined $pbinit) { 
     264        my $ptr = pb_get_pkg(); 
     265        @pkgs = @$ptr; 
     266        @pkgs = ("pkg1") if (not @pkgs); 
     267 
    255268        open(CONF,"> $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb") || die "Unable to create $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb"; 
    256269        print CONF << "EOF"; 
     
    263276 
    264277# 
    265 # Which CMS system is used (Subversion, CVS or tar file content extracted) 
    266 # 
    267 #cms $ENV{'PBPROJ'} = svn 
    268 #cms $ENV{'PBPROJ'} = cvs 
    269 #cms $ENV{'PBPROJ'} = flat 
     278# What is the project URL 
     279# 
     280#pbproj $ENV{'PBPROJ'} = svn://svn.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel 
     281#pbproj $ENV{'PBPROJ'} = svn://svn+ssh.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel 
     282#pbproj $ENV{'PBPROJ'} = cvs://cvs.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel 
     283#pbproj $ENV{'PBPROJ'} = http://www.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz 
     284#pbproj $ENV{'PBPROJ'} = ftp://ftp.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz 
     285#pbproj $ENV{'PBPROJ'} = file:///src/$ENV{'PBPROJ'}-devel.tar.gz 
    270286 
    271287# 
     
    319335#projtag $ENV{'PBPROJ'} = 1 
    320336 
     337# Hash of valid version names 
     338#version $ENV{'PBPROJ'} = devel,stable 
     339 
    321340# Adapt to your needs: 
    322341# Optional if you need to overwrite the global values above 
    323342# 
    324 #pkgver pkg1 = stable 
    325 #pkgtag pkg1 = 3 
    326 #pkgver nil 
    327 #pkgtag nil 
    328  
     343EOF 
     344         
     345        foreach my $pp (@pkgs) { 
     346            print CONF << "EOF"; 
     347#pkgver $pp = stable 
     348#pkgtag $pp = 3 
     349EOF 
     350        } 
     351        foreach my $pp (@pkgs) { 
     352            print CONF << "EOF"; 
    329353# Hash of default package/package directory 
    330354#defpkgdir pkg1 = pkg1dir 
    331  
     355EOF 
     356        } 
     357 
     358        print CONF << "EOF"; 
    332359# Hash of additional package/package directory 
    333 #extpkgdir pkg1-doc = pkg1-docdir 
    334  
    335 # Hash of valid version names 
    336 #version devel 
    337 #version stable 
     360#extpkgdir minor-pkg = minor-pkg-dir 
    338361 
    339362# List of files per pkg on which to apply filters 
    340363# Files are mentioned relatively to pbroot/defpkgdir 
    341 #filteredfiles pkg1 = Makefile.PL 
    342 #filteredfiles pkg1-doc = configure.in 
    343 #supfiles pkg1 = pkg1.init 
    344 EOF 
     364EOF 
     365        foreach my $pp (@pkgs) { 
     366            print CONF << "EOF"; 
     367#filteredfiles $pp = Makefile.PL,configure.in,install.sh,$pp.8 
     368#supfiles $pp = $pp.init 
     369EOF 
     370        } 
    345371        close(CONF); 
    346372        pb_mkdir_p("$ENV{'PBROOT'}/pbfilter") || die "Unable to create $ENV{'PBROOT'}/pbfilter"; 
     
    395421#filter PBGRP = Applications/Archiving 
    396422 
     423# PBLIC is replaced by the license of the application 
     424# Cf: http://fedoraproject.org/wiki/Licensing 
     425#filter PBLIC = GPL 
     426 
    397427# PBDEP is replaced by the list of dependencies 
    398428#filter PBDEP = 
     
    415445# PBGRP is replaced by the group of apps 
    416446#filter PBGRP = utils 
     447 
     448# PBLIC is replaced by the license of the application 
     449# Cf: 
     450#filter PBLIC = GPL 
    417451 
    418452# PBVER is replaced by the version (\$pbver in code) 
     
    442476        print CONF << "EOF"; 
    443477# Specific group for Mandriva for $ENV{'PBPROJ'} 
     478# Cf: http://wiki.mandriva.com/en/Development/Packaging/Groups 
    444479filter PBGRP = Archiving/Backup 
     480 
     481# PBLIC is replaced by the license of the application 
     482# Cf: http://wiki.mandriva.com/en/Development/Packaging/Licenses 
     483#filter PBLIC = GPL 
     484 
    445485EOF 
    446486        close(CONF); 
     
    448488        print CONF << "EOF"; 
    449489# Specific group for SuSE for $ENV{'PBPROJ'} 
     490# Cf: http://en.opensuse.org/SUSE_Package_Conventions/RPM_Groups 
    450491filter PBGRP = Productivity/Archiving/Backup 
     492 
     493# PBLIC is replaced by the license of the application 
     494# Cf: http://en.opensuse.org/Packaging/SUSE_Package_Conventions/RPM_Style#1.6._License_Tag 
     495#filter PBLIC = GPL 
     496 
    451497EOF 
    452498        close(CONF); 
    453         pb_mkdir_p("$ENV{'PBROOT'}/pkg1/deb") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb"; 
    454         open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/control") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/control"; 
    455         print CONF << "EOF"; 
     499        foreach my $pp (@pkgs) { 
     500            pb_mkdir_p("$ENV{'PBROOT'}/$pp/deb") || die "Unable to create $ENV{'PBROOT'}/$pp/deb"; 
     501            open(CONF,"> $ENV{'PBROOT'}/$pp/deb/control") || die "Unable to create $ENV{'PBROOT'}/$pp/deb/control"; 
     502            print CONF << "EOF"; 
    456503Source: PBPKG 
    457504Section: PBGRP 
     
    474521 
    475522EOF 
    476         close(CONF); 
    477         open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/copyright") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/copyright"; 
    478         print CONF << "EOF"; 
     523            close(CONF); 
     524            open(CONF,"> $ENV{'PBROOT'}/$pp/deb/copyright") || die "Unable to create $ENV{'PBROOT'}/$pp/deb/copyright"; 
     525            print CONF << "EOF"; 
    479526This package is debianized by PBPACKAGER 
    480527`date` 
     
    505552 
    506553EOF 
    507         close(CONF); 
    508         open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/changelog") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/changelog"; 
    509         print CONF << "EOF"; 
     554            close(CONF); 
     555            open(CONF,"> $ENV{'PBROOT'}/$pp/deb/changelog") || die "Unable to create $ENV{'PBROOT'}/$pp/deb/changelog"; 
     556            print CONF << "EOF"; 
    510557PBLOG 
    511558EOF 
    512         close(CONF); 
    513         open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/compat") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/compat"; 
    514         print CONF << "EOF"; 
     559            close(CONF); 
     560            open(CONF,"> $ENV{'PBROOT'}/$pp/deb/compat") || die "Unable to create $ENV{'PBROOT'}/$pp/deb/compat"; 
     561            print CONF << "EOF"; 
    5155624 
    516563EOF 
    517         close(CONF); 
    518         open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/pkg1.dirs") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/pkg1.dirs"; 
    519         print CONF << "EOF"; 
    520 EOF 
    521         close(CONF); 
    522         open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/pkg1.docs") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/pkg1.docs"; 
    523         print CONF << "EOF"; 
     564            close(CONF); 
     565            open(CONF,"> $ENV{'PBROOT'}/$pp/deb/pkg1.dirs") || die "Unable to create $ENV{'PBROOT'}/$pp/deb/$pp.dirs"; 
     566            print CONF << "EOF"; 
     567EOF 
     568            close(CONF); 
     569            open(CONF,"> $ENV{'PBROOT'}/$pp/deb/$pp.docs") || die "Unable to create $ENV{'PBROOT'}/$pp/deb/$pp.docs"; 
     570            print CONF << "EOF"; 
    524571INSTALL 
    525572COPYING 
     
    528575README 
    529576EOF 
    530         close(CONF); 
    531         open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/rules") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/rules"; 
    532         print CONF << 'EOF'; 
     577            close(CONF); 
     578            open(CONF,"> $ENV{'PBROOT'}/$pp/deb/rules") || die "Unable to create $ENV{'PBROOT'}/$pp/deb/rules"; 
     579            print CONF << 'EOF'; 
    533580#!/usr/bin/make -f 
    534581# -*- makefile -*- 
     
    665712 
    666713EOF 
    667         close(CONF); 
    668         pb_mkdir_p("$ENV{'PBROOT'}/pkg1/rpm") || die "Unable to create $ENV{'PBROOT'}/pkg1/rpm"; 
    669         open(CONF,"> $ENV{'PBROOT'}/pkg1/rpm/pkg1.spec") || die "Unable to create $ENV{'PBROOT'}/pkg1/rpm/pkg1.spec"; 
    670         print CONF << 'EOF'; 
     714            close(CONF); 
     715            pb_mkdir_p("$ENV{'PBROOT'}/$pp/rpm") || die "Unable to create $ENV{'PBROOT'}/$pp/rpm"; 
     716            open(CONF,"> $ENV{'PBROOT'}/$pp/rpm/$pp.spec") || die "Unable to create $ENV{'PBROOT'}/$pp/rpm/$pp.spec"; 
     717            print CONF << 'EOF'; 
    671718# 
    672719# $Id$ 
     
    679726Version:        PBVER 
    680727Release:        PBTAGPBSUF 
    681 License:        GPL 
     728License:        PBLIC 
    682729Group:          PBGRP 
    683730Url:            PBURL 
     
    715762 
    716763EOF 
    717         close(CONF); 
    718         pb_mkdir_p("$ENV{'PBROOT'}/pkg1/pbfilter") || die "Unable to create $ENV{'PBROOT'}/pkg1/pbfilter"; 
    719  
    720         pb_log(2,"\nDo not to forget to commit the pbconf directory in your CMS if needed\n"); 
    721         pb_log(2,"After having renamed the pkg1 directory to your package's name      \n\n"); 
     764            close(CONF); 
     765            pb_mkdir_p("$ENV{'PBROOT'}/$pp/pbfilter") || die "Unable to create $ENV{'PBROOT'}/$pp/pbfilter"; 
     766 
     767            pb_log(0,"\nDo not to forget to commit the pbconf directory in your CMS if needed\n"); 
     768        } 
    722769    } else { 
    723770        die "Unable to open $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb"; 
     
    13311378my $msg = shift; 
    13321379 
    1333 print $LOG "$msg\n" if ($dlevel >= $debug); 
     1380print $LOG "$msg\n" if ($dlevel <= $debug); 
     1381} 
     1382 
     1383#  
     1384# Return the list of packages we are working on 
     1385# 
     1386sub pb_get_pkg { 
     1387 
     1388my @pkgs = (); 
     1389my $defpkgdir = shift || undef; 
     1390my $extpkgdir = shift || undef; 
     1391 
     1392# Get packages list 
     1393if (not defined $ARGV[0]) { 
     1394    @pkgs = keys %$defpkgdir if (defined $defpkgdir); 
     1395} elsif ($ARGV[0] =~ /^all$/) { 
     1396    @pkgs = keys %$defpkgdir if (defined $defpkgdir; 
     1397    push(@pkgs, keys %$extpkgdir) if (defined $extpkgdir); 
     1398} else { 
     1399    @pkgs = @ARGV; 
     1400} 
     1401pb_log(0,"Packages: ".join(',',@pkgs)."\n"); 
     1402return(\@pkgs); 
    13341403} 
    13351404 
Note: See TracChangeset for help on using the changeset viewer.