Changeset 2659 for devel


Ignore:
Timestamp:
Jun 23, 2010, 4:26:59 PM (9 years ago)
Author:
bruno
Message:

r3911@wsip-70-165-196-181: bruno | 2010-06-22 03:34:20 +0200

  • First packaged version of a mrmin version begining to work (but doing nothing interesting yet ;-)
Location:
devel
Files:
1 added
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • devel/mr/Makefile.PL

    r2650 r2659  
    99    VERSION   => 'PBVER',
    1010    INST_SCRIPT  => 'blib/bin',
    11     INSTALLDIRS  => 'perl',
     11    INSTALLDIRS  => 'vendor',
    1212    PREREQ_PM   => {
    1313            #HTTP::Headers                  => 1.59,
     
    6161            $target = "/usr/local";
    6262            if (not defined $confdir) {
    63                 $confdir = "/usr/local/etc";
     63                $confdir = "$target/etc";
     64            }
     65            if (not defined $cachedir) {
     66                $cachedir = "$target/var/cache";
    6467            }
    6568        } else {
    66             $sharedir = $sharedir || "$target/share";
    67             $mandir = $mandir || "$sharedir/man";
    6869            $cachedir = $cachedir || "$target/var/cache";
    6970            if (not defined $confdir) {
    7071                die "CONFDIR should be defined if PREFIX is defined";
    7172            }
     73            if (not defined $cachedir) {
     74                die "CACHEDIR should be defined if PREFIX is defined";
     75            }
    7276        }
     77        $sharedir = $sharedir || "$target/share";
     78        $mandir = $mandir || "$sharedir/man";
    7379
    7480        my $conff = "etc/PBPROJ.conf";
     
    8389mr_install_dir default = $target
    8490#
    85 #
    8691# conf dir
    8792#
     
    95100#
    96101mr_share_dir default = $sharedir/PBPROJ
     102#
     103# version
     104#
     105mr_version default = PBVER-rPBREV
    97106EOF
    98107        close(CONF);
     
    102111
    103112        $text .= "install ::\n";
    104         $text .= "\t".'@echo PBPKG PBVER-PBREV will be installed under $(DESTDIR)'."\n";
     113        $text .= "\t".'@echo PBPKG PBVER-rPBREV will be installed under $(DESTDIR)'."\n";
    105114        $text .= "\t".'install -m 755 -d $(DESTDIR)'."$confdir/PBPROJ".' $(DESTDIR)'."$cachedir/PBPROJ".' $(DESTDIR)'."$sharedir/PBPROJ\n";
    106115        $text .= "\t".'cp etc/PBPROJ.conf $(DESTDIR)'."$confdir/PBPROJ/PBPROJ.conf.dist ; install -m 755 -d ".' $(DESTDIR)'."$mandir/man5 ; pod2man etc/PBPROJ.conf > ".'$(DESTDIR)'."$mandir/man5/PBPROJ.conf.5\n";
    107116        $text .= "\t".'md5sum $(DESTDIR)'."$confdir/PBPROJ/PBPROJ.conf.dist > ".'$(DESTDIR)'."$confdir/PBPROJ/PBPROJ.conf.dist.md5\n";
    108         $text .= "\t".'cp lib/MondoRescue/DynConf.pm $(DESTDIR)/$(INST_LIBDIR)/'."\n";
    109         $text .= "\t".'md5sum $(DESTDIR)'."$confdir/PBPROJ/PBPROJ.conf.dist > ".'$(DESTDIR)'."$confdir/PBPROJ/PBPROJ.conf.dist.md5\n";
    110         #$text .= "\t".'if [ -f etc/PBKG.conf ]; then cp etc/PBPKG.conf $(DESTDIR)'."$confdir/PBPROJ/PBKG.conf.dist ; install -m 755 -d ".' $(DESTDIR)'."$mandir/man5 ; pod2man etc/PBPKG.conf > ".'$(DESTDIR)'."$mandir/man5/PBPKG.conf.5 ; fi\n";
    111         #$text .= "\t".'md5sum $(DESTDIR)'."$confdir/PBPROJ/PBPKG.conf.dist > ".'$(DESTDIR)'."$confdir/PBPROJ/PBPKG.conf.dist.md5\n";
     117        $text .= "\t".'cp lib/MondoRescue/DynConf.pm $(DESTDIR)/$(VENDORLIBEXP)/MondoRescue/'."\n";
    112118
    113119        # Now generate a perl module used by every other one in the project
     
    152158
    153159This function returns all the installation PATH info needed by the project
    154 It takes no parameter and returns 3 values
     160It takes no parameter and returns 2 values
    155161First value is the conf dir
    156162Second value is the project name
     
    159165
    160166sub mr_dynconf_init {
    161     return($confdir,PBPROJ);
     167    return("$confdir/PBPROJ","PBPROJ");
    162168}
    1631691;
  • devel/mr/etc/mondorescue.conf

    r2650 r2659  
    2020mr_fstab default = /etc/fstab
    2121
     22#
     23# Interface to burner
     24#
     25mr_burn_cmd default = /usr/bin/wodim
     26#mr_burn_cmd default = /usr/bin/cdrecord
     27
     28mr_burn_opt default = -v
    2229#
    2330# LVM commands and conf files
  • devel/mr/lib/MondoRescue/Base.pm

    r2650 r2659  
    2525use Exporter;
    2626
     27# Global hash for configuration params of mr
     28my %mr;
     29our $mr = \%mr;
     30
    2731# Export, by default, all the functions into the namespace of
    2832# any code which uses this module.
    2933
    3034our @ISA = qw(Exporter);
    31 our @EXPORT = qw(mr_init mr_exit);
     35our @EXPORT = qw(mr_init mr_exit mr_conf_get $mr);
    3236
    3337=pod
     
    7175#
    7276# Conf files Management
    73 # the $MRMINI_CONF/mondorescue.conf.dist is delivered as part of the project and
     77# the $etcdir/mondorescue.conf.dist is delivered as part of the project and
    7478# its checksum is verified as we need good default values that we can trust
    7579#
     
    106110exit($code);
    107111}
     112
     113=item B<mr_conf_get>
     114
     115This function get parameters in configuration files and returns from the least significant level (default) to the emost significant level (application name), passing by the project name.
     116It takes a list of parameters to find and returns the values corresponding
     117
     118=cut
     119
     120
     121sub mr_conf_get {
     122    my @params = @_;
     123    my @ptr = ();
     124    my $ptr;
     125   
     126    pb_log(2,"Entering mr_conf_get\n");
     127    my @args1 = pb_conf_get_if(@params);
     128    my $proj = $ENV{'PBPROJ'};
     129    $ENV{'PBPROJ'} = $ENV{'PBPKG'};
     130    my @args2 = pb_conf_get_if(@params);
     131    foreach my $i (0..$#args1) {
     132        $ptr = undef;
     133        # Process from least important to more important
     134        $ptr = $args1[$i]->{'default'};
     135        $ptr[$i] = $ptr if (defined $ptr);
     136        $ptr = $args1[$i]->{$ENV{'PBPROJ'}};
     137        $ptr[$i] = $ptr if (defined $ptr);
     138        $ptr = $args2[$i]->{$ENV{'PBPKG'}};
     139        $ptr[$i] = $ptr if (defined $ptr);
     140        $ptr[$i] = "Undefined" if (not defined $ptr[$i]);
     141        pb_log(2,"Found parameter $params[$i] with value $ptr[$i]\n");
     142    }
     143    $ENV{'PBPROJ'} = $proj;
     144    return(@ptr);
     145}
  • devel/mrmini/Makefile.PL

    r2648 r2659  
    99    VERSION      => 'PBVER',
    1010    INST_SCRIPT  => 'blib/sbin',
    11     INSTALLDIRS  => 'perl',
     11    INSTALLDIRS  => 'vendor',
    1212    PREREQ_PM    => {
    1313            #HTTP::Headers                    => 1.59,
     
    2121            'sbin/mrprepare-lvm' => '$(INST_MAN1DIR)/mrprepare-lvm.$(MAN1EXT)',
    2222                    },
    23     #MAN3PODS      => {
    24             #'lib/MondoRescue/Mini/LVM.pm' => '$(INST_MAN3DIR)/MondoRescue::Mini::LVM.$(MAN3EXT)',
    25             #},
     23    MAN3PODS      => { 
     24            'lib/MondoRescue/Mini/Base.pm' => '$(INST_MAN3DIR)/MondoRescue::Mini::Base.$(MAN3EXT)',
     25            },
    2626);
     27
     28
     29package MY;
     30
     31sub postamble {
     32
     33    use MondoRescue::DynConf;
     34
     35    my ($confdir,$proj) = mr_dynconf_init();
     36
     37    my $text .= "install ::\n";
     38    $text .= "\t".'@echo PBPKG PBVER-rPBREV will be installed under $(DESTDIR)'."\n";
     39    $text .= "\tinstall -m 755 -d ".' $(DESTDIR)/$(INSTALLMAN1DIR)/../man5 $(DESTDIR)'."/$confdir/".'; cp etc/PBPKG.conf $(DESTDIR)'."/$confdir/PBPKG.conf.dist ; pod2man etc/PBPKG.conf > ".'$(DESTDIR)/$(INSTALLMAN1DIR)/../man5/PBPKG.conf.5'."\n";
     40    $text .= "\t".'md5sum $(DESTDIR)'."$confdir/PBPKG.conf.dist > ".'$(DESTDIR)'."$confdir/PBPKG.conf.dist.md5\n";
     41    return($text);
     42}
  • devel/mrmini/etc/mrmini.conf

    r2650 r2659  
    8888#
    8989mr_force_mods mrmini =
    90 mr deny_mods mrmini =
    91 
    92 #
    93 # Location of the fstab file
    94 #
    95 mr_fstab default = /etc/fstab
     90mr_deny_mods mrmini =
    9691
    9792#
     
    9994#
    10095mr_log_file mrmini = /var/log/mrmini.log
    101 mr_log_file mondoarchive = /var/log/mondoarchive.log
    102 mr_log_file mondorestore = /var/log/mondorestore.log
    10396
    10497#
  • devel/mrmini/sbin/mrmini

    r2650 r2659  
    2727use MondoRescue::LVM;
    2828use MondoRescue::Base;
    29 
    30 # Global variables
    31 my %opts;                   # CLI Options
    32 my @date = pb_get_date();
    33 my $mr_date = strftime("%Y-%m-%d %H:%M:%S", @date);
     29use MondoRescue::DynConf;
     30use MondoRescue::Mini::Base;
    3431
    3532=pod
     
    105102
    106103=cut
     104
     105# Global variables
     106my %opts;                   # CLI Options
     107
    107108GetOptions(
    108109        "verbose|v+" => \$opts{'v'},
     
    154155=cut
    155156
     157
     158
    156159# ---------------------------------------------------------------------------
    157160
    158161# Initialize the syntax string
    159162
    160 pb_syntax_init("mrmini Version PBVER-rPBREV\n");
     163#
     164# Global variables
     165#
     166my $proj;
     167($mr->{'confdir'},$proj) = mr_dynconf_init();
     168my @date = pb_get_date();
     169$mr->{'start_date'} = strftime("%Y-%m-%d %H:%M:%S", @date);
     170
     171$ENV{'PBPROJ'} = $proj;
     172$ENV{'PBPKG'} = "mrmini";
     173
     174# Adds conf files in order
     175pb_conf_add("$mr->{'confdir'}/mondorescue.conf.dist","$mr->{'confdir'}/mondorescue.conf");
     176($mr->{'install_dir'},$mr->{'version'}) =  mr_conf_get("mr_install_dir","mr_version");
     177
     178pb_syntax_init("$ENV{'PBPKG'} Version $mr->{'version'}\n");
    161179pb_display_init("text","");
    162180
     
    190208    $iso = $opts{'i'};
    191209}
    192 
    193 #
    194 # Global variables
    195 #
    196 my ($MRMINI_PREFIX,$MRMINI_CONF,$MRMINI_LIB) = mr_setup_var();
    197 my $MRMINI_VERSION = "PBVER-rPBREV";
    198 my $MRMINI_SBIN = "$MRMINI_PREFIX/sbin";
    199 my $MRMINI_FDISK = "$MRMINI_SBIN/parted2fdik";
    200 my $MRMINI_DEPLIST = "$MRMINI_CONF/deplist.d";
    201 # Better ?
    202 my $ARCH = `uname -m`;
    203 chop($ARCH);
     210my $logfile = undef;
     211if (defined $opts{'l'}) {
     212    $logfile = $opts{'l'};
     213}
    204214
    205215#
     
    207217#
    208218pb_temp_init();
    209 
    210 # Adds conf files in order
    211 pb_conf_add("$ENV{'HOME'}/.mondorescuerc","$MRMINI_CONF/mondorescue.conf");
    212 
    213 #
    214 # Configuration parameters
    215 #
    216 $ENV{'PBPROJ'} = "mrmini";
    217 my ($mr_boot_size,$mr_boot_cd,$mr_boot_usb,$mr_boot_tape,$mr_kernel,$mr_fstab) =  pb_conf_get("mr_boot_size","mr_boot_cd","mr_boot_usb","mr_boot_tape","mr_kernel","mr_fstab");
    218 my ($mr_tape_mods,$mr_scsi_mods,$mr_ide_mods,$mr_pcmcia_mods,$mr_usb_mods,$mr_net_mods,$mr_cdrom_mods,$mr_deny_mods,$mr_force_mods) =  pb_conf_get("mr_tape_mods","mr_scsi_mods","mr_ide_mods","mr_pcmcia_mods","mr_usb_mods","mr_net_mods","mr_cdrom_mods","mr_extra_mods","mr_deny_mods","mr_force_mods");
    219 my ($mr_logfile,$mr_cache_dir,$mr_boot_msg,$mr_burn_cmd,$mr_burn_opt) = pb_conf_get("mr_logfile","mr_cache_dir","mr_boot_msg","mr_burn_cmd","mr_burn_opt");
    220 
    221 #
    222 # Manage log file
    223 #
    224 my $logfile = $mr_logfile->{$ENV{'PBPROJ'}};
    225 
    226 if (defined $opts{'l'}) {
    227     $logfile = $opts{'l'};
    228 }
    229 open(pbLOG,"> $logfile") || die "Unable to log to $logfile: $!";
    230 $pbLOG = \*pbLOG;
    231 $pbdebug = 0  if ($pbdebug == -1);
    232 pb_log_init($pbdebug, $pbLOG);
    233 
    234 pb_log(0,"mrmini start date: $mr_date");
    235 pb_log(0,"-------------------------------------");
    236 pb_log(0,"mrmini v$MRMINI_VERSION");
    237 pb_log(0,"$ARCH architecture detected");
    238 pb_log(0,"mrmini called with the following arguments: ".join(" ",@ARGV));
    239 pb_log(0,"-------------------------------------");
    240 pb_log(0,"MONDO_CACHE: $ENV{'MONDO_CACHE'}") if (defined $ENV{'MONDO_CACHE'});
    241 pb_log(0,"MRMINI_LIB: $MRMINI_LIB");
    242 pb_log(0,"MRMINI_CONF: $MRMINI_CONF");
    243 pb_log(0,"MRMINI_SBIN: $MRMINI_SBIN");
    244 if (-r "$ENV{'HOME'}/.mondorescuerc") {
    245     pb_log(0,"-------------------------------------");
    246     pb_log(0,"Conf file $ENV{'HOME'}/.mondorescuerc");
    247     pb_display_file("$ENV{'HOME'}/.mondorescuerc");
    248 }
    249 if (-r "$MRMINI_CONF/mondorescue.conf") {
    250     pb_log(0,"-------------------------------------");
    251     pb_log(0,"Conf file $MRMINI_CONF/mondorescue.conf");
    252     pb_display_file("$MRMINI_CONF/mondorescue.conf");
    253 }
    254 pb_log(0,"-------------------------------------");
    255 
    256 #
    257 # Prepare cache dir
    258 #
    259 pb_rm_rf("$mr_cache_dir/*");
    260 pb_mkdir_p($mr_cache_dir);
    261 
    262 #
    263 # LVM setup
    264 #
    265 my ($lvmver,$lvmcmd) = mr_lvm_check();
    266 
    267 pb_log(0,"LVM $lvmver command set to $lvmcmd");
    268 pb_log(0,"-------------------------------------");
     219mr_mini_main($logfile);
    269220mr_exit(0);
Note: See TracChangeset for help on using the changeset viewer.