Changeset 974 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/Base.pm


Ignore:
Timestamp:
Feb 19, 2010, 4:17:46 AM (14 years ago)
Author:
Bruno Cornec
Message:
  • Adds function pb_check_requirements and use it in pb
  • Adds some conf params for rpmbootstrap in conf file
  • pb_distro_get_param now can expand some variables before returning a value
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Base.pm

    r873 r974  
    3737
    3838our @ISA = qw(Exporter);
    39 our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_get_uri pb_get_content pb_set_content pb_display_file pb_syntax_init pb_syntax pb_temp_init pb_get_arch $pbdebug $pbLOG $pbdisplaytype $pblocale);
     39our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_get_uri pb_get_content pb_set_content pb_display_file pb_syntax_init pb_syntax pb_temp_init pb_get_arch pb_check_requirements $pbdebug $pbLOG $pbdisplaytype $pblocale);
    4040
    4141=pod
     
    389389}
    390390
     391=item B<pb_check_requirements>
     392
     393This function checks that the commands needed for the subsystem are indeed present.
     394The required comands are passed as a coma separated string as first parameter.
     395The optional comands are passed as a coma separated string as second parameter.
     396
     397=cut
     398
     399sub pb_check_requirements {
     400
     401my $cmds = shift || "";
     402my $opts = shift || "";
     403
     404# cmds is a string of coma separated commands
     405foreach my $file (split(/,/,$cmds) {
     406    pb_check_req($file,0);
     407}
     408
     409# opts is a string of coma separated commands
     410foreach my $file (split(/,/,$opts) {
     411    pb_check_req($file,1);
     412}
     413}
     414
     415sub pb_check_req {
     416
     417my $file = shift;
     418my $opt = shift || 1;
     419my $found = 0;
     420
     421pb_log(2,"Checking availability of $file...");
     422# Check for all dirs in the PATH
     423foreach my $p (split(/:/,$ENV{'PATH'})) {
     424    $found = 1 if (-x "$p/$file");
     425}
     426if ($found eq 0) {
     427    pb_log(2,"KO\n");
     428    if ($opt eq 1) {
     429        pb_log(2,"Unable to find optional command $file\n");
     430    } else {
     431        die pb_log(0,"Unable to find required command $file\n");
     432    }
     433} else {
     434    pb_log(2,"OK\n");
     435}
     436}
     437
    391438=back
    392439
Note: See TracChangeset for help on using the changeset viewer.