Changeset 1402 in ProjectBuilder


Ignore:
Timestamp:
Feb 3, 2012, 12:17:04 AM (12 years ago)
Author:
Bruno Cornec
Message:

r4487@cabanilles: bruno | 2012-02-01 16:21:48 +0100

  • Fix the -t option without param for pb
  • add a function to analyze busybox countent and create appropriate structure for pbmkbm
Location:
devel
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/etc/pb.conf

    r1374 r1402  
    343343
    344344# Where to store packages downloaded temporarily by rpmbootstrap
    345 rbscachedir default = /var/cache/rpmbootstrap
     345cachedir rpmbootstrap = /var/cache/rpmbootstrap
     346cachedir pbmkbm = /var/cache/rpmbootstrap
    346347
    347348# Options to pass to rpmbootstrap command. By default keep downloaded packages
     
    377378verpmtype pbmkbm = rpmbootstrap
    378379vedebtype pbmkbm = debbootstrap
     380
     381# Log command to use to have a sufficient understanding of the environment in which we oprate
     382logcmd pbmkbm = internal
     383# internal or sos, or cfg2html, or ...
     384logopt pbmkbm = --options
     385logfiles pbmkbm = /etc/raidtab,/proc/cmdline,/proc/swaps,/proc/partitions,/proc/filesystems,/proc/lvm,/dev/mapper
     386logcommands pbmkbm = mount,lsmod,esxcfg-module -l,df -T
     387
     388# Directories to create on the target media
     389targetdir pbmkbm = /bin,/usr/bin,/tmp
     390# Files to embed on the target media
     391mandatoryfiles pbmkbm =
     392optionalfiles pbmkbm =
     393
     394# Where are the ISO bootloader for this OS
     395mkbmisobl linux = /usr/lib/syslinux/isolinux.bin,/usr/lib64/syslinux/isolinux.bin
     396mkbmkbd mageia = /usr/lib/kbd
    379397
    380398# pb install dependencies per distro
     
    502520oscmd rpmbootstrap = rpm,rpm2cpio,wget
    503521#oscmdopt rpmbootstrap =
    504 #
     522oscmd pbmkbm =
     523oscmdopt pbmkbm =
     524#
     525# If busybox, which one is used (from mindi, or native, ...)
     526ospathcmd-busybox default = /usr/lib/mindi/rootfs/bin/busybox
    505527
    506528# Some path for commands may defer from one system to another
  • devel/pb-modules/lib/ProjectBuilder/Base.pm

    r1400 r1402  
    393393
    394394# On linux can also use /proc/sys/kernel/osrelease
    395 return(chomp(`uname -r`));
     395my $rel = `uname -m`;
     396chomp($rel);
     397return($rel);
    396398}
    397399
     
    480482} else {
    481483    pb_log(2,"OK\n");
    482     return($found);
    483 }
     484}
     485return($found);
    484486}
    485487
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r1212 r1402  
    560560
    561561This function gets the OS context passed as parameter and return the corresponding distribution hash
     562If passed undef or "" then auto-detects
    562563
    563564=cut
     
    569570my $pbos;
    570571
    571 if (defined $os) {
     572if ((defined $os) && ($os ne "")) {
    572573    my ($name,$ver,$darch) = split(/-/,$os);
    573574    pb_log(0,"Bad format for $os") if ((not defined $name) || (not defined $ver) || (not defined $darch)) ;
  • devel/pb/bin/pb

    r1401 r1402  
    544544if (defined $opts{'t'}) {
    545545    $pbtarget = $opts{'t'};
    546     # GetOptions may create an empty string, we use internally undef for that type of target
    547     if ($pbtarget eq "") {
    548         $pbtarget = undef;
    549     }
    550546}
    551547
     
    39993995
    40003996# Get list of distributions for which we need to generate build files if no target
    4001 if (not defined ($pbtarget)) {
     3997if (not defined $pbtarget) {
    40023998    my @pt = pb_conf_get_if("vmlist","velist","rmlist");
    40033999    if (defined $pt[0]->{$ENV{'PBPROJ'}}) {
  • devel/pbmkbm/bin/pbmkbm

    r1352 r1402  
    1616use File::Basename;
    1717use File::Copy;
     18use POSIX qw(strftime);
     19
    1820use ProjectBuilder::Version;
    1921use ProjectBuilder::Base;
     
    235237}
    236238pb_log_init($pbdebug, $pbLOG);
     239pb_log(1,"$appname Version $projectbuilderver-$projectbuilderrev\n");
     240my @date = pb_get_date();
     241my $pbdate = strftime("%Y-%m-%d %H:%M:%S", @date);
     242
     243pb_log(1,"Start: $pbdate\n");
    237244
    238245# Get VE name
     
    256263# Check for command requirements
    257264#
    258 my ($req,$opt) = pb_conf_get_if("mkbmcmd","mkbmcmdopt");
     265my ($req,$opt) = pb_conf_get_if("oscmd","oscmdopt");
    259266pb_check_requirements($req,$opt,$appname);
    260267
     
    265272# Where is our build target directory
    266273#
    267 
    268274if (not defined $targetdir) {
    269275    $targetdir = "/var/cache/pbmkbm";
    270276    my ($vestdpath) = pb_conf_get("mkbmpath");
    271277    $targetdir = "$vestdpath->{'default'}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}" if (defined $vestdpath->{'default'});
    272 }
    273 
    274 die pb_log(0,"No target-dir specified and no default mkbmpath found in $ENV{'PBETC'}\n") if (not defined $targetdir);
     278    pb_log(1,"No target-dir specified, using $targetdir\n");
     279}
    275280
    276281# Point to the right subdir and create it if needed
    277282pb_mkdir_p($targetdir) if (! -d $targetdir);
    278283
     284# Log information on our system
     285# TODO: this should be put in a subfunction
     286my ($logcmd) = pb_conf_get("logcmd");
     287my ($logopt) = pb_conf_get_if("logopt");
     288# check that the command is there first and then use it.
     289if ($logcmd->{$appname} ne "internal") {
     290    $logcmd = pb_check_req($logcmd->{$appname},1);
     291    if (not defined $logcmd) {
     292        pb_log(1,"INFO: command $logcmd->{$appname} doesn't exist. No log report is available\n");
     293    } else {
     294        my $c = $logcmd->{$appname};
     295        $c .= " $logopt->{$appname}" if (defined $logopt->{$appname});
     296        pb_system("$c","Creating a log report of your system");
     297    }
     298} else {
     299    # We provide our own internal log reporter as a std one isn't found
     300    my ($lcmds,$lfiles) = pb_conf_get_if("logcommands","logfiles");
     301    pb_log(1,"------------------\n");
     302    if (defined $lcmds->{$appname}) {
     303        foreach my $c (split(/,/,$lcmds->{$appname})) {
     304            my $lcmd = $c;
     305            $lcmd =~ s/ .*$//;
     306            $lcmd = pb_check_req($lcmd,1);
     307            if (not defined $lcmd) {
     308                pb_log(1,"INFO: command $lcmd (in $c) doesn't exist\n");
     309                pb_log(1,"------------------\n");
     310                next;
     311            }
     312            pb_log(1,"Execution of $c\n");
     313            pb_log(1,"------------------\n");
     314            pb_system($c,"",1);
     315            pb_log(1,"------------------\n");
     316        }
     317    }
     318    if (defined $lfiles->{$appname}) {
     319        foreach my $f (split(/,/,$lfiles->{$appname})) {
     320            if (! -e $f) {
     321                pb_log(1,"INFO: $f doesn't exist\n");
     322                pb_log(1,"------------------\n");
     323                next;
     324            }
     325            if (! -r $f) {
     326                pb_log(1,"INFO: $f isn't readable\n");
     327                pb_log(1,"------------------\n");
     328                next;
     329            }
     330            if ((-f $f) || (-l $f)) {
     331                if (! open(FILE,$f)) {
     332                    pb_log(1,"INFO: Unable to open $f\n");
     333                    pb_log(1,"------------------\n");
     334                    next;
     335                }
     336                pb_log(1,"Content of $f\n");
     337                pb_log(1,"------------------\n");
     338                while (<FILE>) {
     339                    pb_log(1,$_);
     340                }
     341                close(FILE);
     342                pb_log(1,"------------------\n");
     343            } elsif (-d $f) {
     344                my $dh;
     345                if (! opendir($dh,$f)) {
     346                    pb_log(1,"INFO: Unable to opendir $f\n");
     347                    pb_log(1,"------------------\n");
     348                    next;
     349                }
     350                pb_log(1,"Content of directory $f\n");
     351                pb_log(1,"----------------------------\n");
     352                while (readdir $dh) {
     353                    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$f/$_");
     354                    my $str = sprintf("%10s %2s %5s %5s %10s %14s %s",$mode,$ino,$uid,$gid,$size,$mtime,$_);
     355                    pb_log(1,"$str\n");
     356                }
     357                closedir($dh);
     358                pb_log(1,"------------------\n");
     359            } else {
     360                pb_log(1,"INFO: $f is special\n");
     361                pb_log(1,"------------------\n");
     362            }
     363        }
     364    }
     365}
    279366
    280367# Now the preparation is over, we need to do something useful :-)
     
    287374pb_mkbm_create_media();
    288375
     376@date = pb_get_date();
     377$pbdate = strftime("%Y-%m-%d %H:%M:%S", @date);
     378
     379pb_log(1,"End: $pbdate\n");
     380
    289381sub pb_mkbm_create_content {
    290382
     
    294386$opts{'b'} = "ve" if (not defined $opts{'b'});
    295387
     388# Hash of target content
     389# atribute could be, copy, remove, link, dir
     390my %targettree;
     391
    296392if ($opts{'b'} eq "ve") {
    297     # Use existing tools to create a good VE !
     393    # Use project-builder VE mecanism to create a good VE !
    298394    pb_ve_launch($ENV{'PBV'},1);
    299395} elsif ($opts{'b'} eq "native") {
    300396    # Use native tools to create a good VE !
     397} elsif ($opts{'b'} eq "drakut") {
     398    # Use drakut to create a good VE !
     399} elsif ($opts{'b'} eq "busybox") {
     400    # Use busybox to create a good VE !
     401    pb_mkbm_create_busybox_ve(\%targettree);
    301402} else {
    302403    die "Unknown method $opts{'b'} used to create the media content";
    303404}
    304405
     406# Create the directory structure needed on the target dir
     407$targettree->{"/bin"} = "dir";
     408
    305409# Once the environment is made, add what is needed for this boot media to it.
     410# Keyboard
     411# Terminfo
     412# List of commands
     413# List of dependencies
     414# Kernel
     415# Initrd
     416# init
     417# BootLoader and its configuration
     418# Additional data files coming from a potential caller (MondoRescue e.g. with fstab, LVM, mountlist, ...)
     419}
     420
     421sub pb_mkbm_create_busybox_ve {
     422
     423my $tgtree = shift;
     424
     425# First, check which are the supported command in that version of busybox
     426# and create the links for it in the target VE
     427
     428my $busycmd = pb_distro_get_param($pbos,pb_conf_get("ospathcmd-busybox"));
     429open(BUSY,"$busycmd |") || die "Unable to execute $busycmd";
     430my $cmdlist = 0;
     431while (<BUSY>) {
     432    pb_log(3,"busybox line : $_");
     433    chomp($_);
     434    # After these words, we have the list of functions, so trigger their analysis
     435    if ($_ =~ /defined functions:/) {
     436        $cmdlist = 1;
     437        next;
     438    }
     439    # Analyse the list of commands provided by that busybox (, separated)
     440    if ($cmdlist == 1) {
     441        pb_log(3,"Analyzing that busybox line\n");
     442        foreach my $c (split(/,/,$_)) {
     443            $c =~ s/\s*//g;
     444            # skip empty strings
     445            next if ($c =~ /^$/);
     446            my $c1 = pb_check_req($c,0);
     447            if (defined $c1) {
     448                $tgtree->{$c1} = "link:$busycmd";
     449            } else {
     450                # When not found on the system, create the link under /usr/bin by default
     451                $tgtree->{"/usr/bin/$c"} = "link:$busycmd";
     452            }
     453        }
     454    }
     455}
     456pb_log(2,"Target Tree is now: ".Dumper($tgtree)."\n");
     457close(BUSY);
    306458}
    307459
  • devel/pbmkbm/etc/pbmkbm.conf

    r1341 r1402  
    1212mkbmmindep fedora-4 = MAKEDEV,SysVinit,audit-libs,basesystem,bash,beecrypt,bzip2-libs,chkconfig,coreutils,cracklib,cracklib-dicts,db4,device-mapper,e2fsprogs,elfutils-libelf,ethtool,expat,filesystem,findutils,gawk,gdbm,glib2,glibc,glibc-common,grep,info,initscripts,iproute,iputils,krb5-libs,libacl,libattr,libcap,libgcc,libidn,libselinux,libsepol,libstdc++,libtermcap,libxml2,libxml2-python,mingetty,mktemp,module-init-tools,ncurses,neon,net-tools,openssl,pam,pcre,popt,procps,psmisc,python,python-elementtree,python-sqlite,python-urlgrabber,readline,rpm,rpm-libs,rpm-python,sed,setup,shadow-utils,sqlite,sysklogd,termcap,tzdata,udev,util-linux,yum,zlib
    1313
    14 # Where to store packages downloaded temporarily by rpmbootstrap
    15 mkbmcachedir default = /var/cache/rpmbootstrap
     14# Commands needed on the underlying system
     15mkbmcmd pbmkbm = #tar,chmod,ls
     16mkbmcmdopt pbmkbm = #,cfghtml,wget,sudo,mv,gzip,rm,chroot,schroot,cp,chown,mkdir,cat,bash,
     17#
    1618
    17 # Commands needed on the underlying system
    18 mkbmcmd pb = tar,chmod,ls
    19 mkbmcmdopt pb = rpmbuild,dpkg-buildpackage,rpm,dpkg,wget,sudo,apt-get,mv,gzip,ebuild,makepkg,pkgmk,pkgtrans,rm,rpmlint,lintian,chroot,schroot,cp,chown,debsign,qemu-img,qemu,kvm,rpmbootstrap,rinse,mock,debootstrap,mkdir,cat,ssh,scp,yum,bash,make,vi,ssh-keygen,svn,hg,cvs,git,svk,svn2cl,cvs2cl,urpmi
    20 mkbmcmd rpmbootstrap = rpm,rpm2cpio,wget
    21 #mkbmcmdopt rpmbootstrap =
    22 #
     19# Directories to create on the target media
     20mkbmtargetdir pbmkbm = /bin,/usr/bin,/tmp
     21# Files to embed on the target media
     22mkbmtargetfiles pbmkbm =
     23
     24# Where are the ISO bootloader for this OS
     25mkbmisobl linux = /usr/lib/syslinux/isolinux.bin,/usr/lib64/syslinux/isolinux.bin
     26mkbmkbd mageia = /usr/lib/kbd
    2327
    2428# How do you want to install content in your VE (pkg or file)
  • devel/rpmbootstrap/bin/rpmbootstrap

    r1326 r1402  
    257257# Get the package list to download, store them in a cache directory
    258258#
    259 my ($rbscachedir) = pb_conf_get_if("rbscachedir");
     259my ($rbscachedir) = pb_conf_get_if("cachedir");
    260260my ($pkgs,$mirror) = pb_distro_get_param($pbos,pb_conf_get("rbsmindep","rbsmirrorsrv"));
    261261
    262262my $cachedir = "/var/cache/rpmbootstrap";
    263263$cachedir = $rbscachedir->{'default'} if (defined $rbscachedir->{'default'});
     264$cachedir = $rbscachedir->{$appname} if (defined $rbscachedir->{$appname});
    264265
    265266# Point to the right subdir and create it if needed
Note: See TracChangeset for help on using the changeset viewer.