Changeset 1348 in ProjectBuilder for devel/pbmkbm
- Timestamp:
- Oct 26, 2011, 11:28:44 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pbmkbm/bin/pbmkbm
r1341 r1348 21 21 use ProjectBuilder::Conf; 22 22 use ProjectBuilder::Distribution; 23 use ProjectBuilder::VE; 23 24 24 25 # Global variables … … 50 51 Kernel, modules could come either from the local installed system 51 52 (typically for disaster recovery context) or from a kernel package of a 52 given configuration .53 given configuration or a referenced content. 53 54 Utilities could come from busybox, local utilities or set of packages. 54 55 The root filesystem is made with them. 55 56 The initrd/initramfs could be made internaly or by calling dracut. 56 T He boot config file is generated from analysis content or provided externally.57 The boot config file is generated from analysis content or provided externally. 57 58 58 59 =head1 SYNOPSIS 59 60 60 pbmkbm [-vhq][-t boot- media-type [-d device]][-m os-ver-arch]61 pbmkbm [-vhq][-t boot-type [-d device]][-b boot-method][-m os-ver-arch] 61 62 [-s script][-a pkg1[,pkg2,...]] [target-dir] 62 63 63 pbmkbm [--verbose][--help][--man][--quiet][--type boot-media-type [-device device]] 64 [--script script][--iso iso][--add pkg1,[pkg2,...]][target-dir] 64 pbmkbm [--verbose][--help][--man][--quiet][--type boot-type [--device device]] 65 [--machine os-ver-arch][--boot boot-method] 66 [--script script][--add pkg1,[pkg2,...]] [target-dir] 65 67 66 68 =head1 OPTIONS … … 84 86 Do not print any output. 85 87 88 =item B<-t|--type boot-type> 89 90 Type of the boot device to generate. A boot-type can be: 91 92 =over 4 93 94 =item B<iso> 95 96 Generate an ISO9660 image format (suitable to be burned later on or loopback mounted. Uses isolinux. 97 98 =item B<usb> 99 100 Generate a USB image format (typically a key of external hard drive). Uses syslinux. 101 102 =item B<pxe> 103 104 Generate a PXE environement (suitable to be integrated in a PXElinux configuration). Uses pxelinux. 105 106 =back 107 108 =item B<-d|--device device-file> 109 110 Name of the device or file on which you want to create the boot media. 111 112 =item B<-b|--boot boot-method> 113 114 This is the boot method to use to create the boot media. A boot-method can be: 115 116 =over 4 117 118 =item B<native> 119 120 Use the tools of the native distribution to create the boot media. No other dependency. 121 122 =item B<ve> 123 124 Use the project-builder.org virtual environment notion to create the boot media. No other dependency outside of the project. 125 126 =item B<busybox> 127 128 Use the busybox tool to create the boot media. Cf: L<http://www.busybox.net> 129 130 =item B<dracut> 131 132 Use the dracut tool to create the boot media. Cf: L<http://www.dracut.net> 133 134 =back 135 86 136 =item B<-s|--script script> 87 137 88 Name of the script you want to execute on the related VEs after the installation. 89 It is executed in host environment. 90 You can use the chroot command to execute actions in the VE. 138 Name of the script you want to execute on the related boot media at the end o the build. 91 139 92 140 =item B<-a|--add pkg1[,pkg2,...]> 93 141 94 Additional packages to add from the distribution you want to install on the related VE 95 at the end of the chroot build. 142 Additional packages to add from the distribution you want to install on the related boot media 143 at the end of the build. 144 145 =item B<-m|--machine os-ver-arch> 146 147 This is the target tuple operating system-version-architecture for which you want to create the boot media. 96 148 97 149 =back … … 99 151 =head1 ARGUMENTS 100 152 153 target-dir is the directory under which the boot media will be build. 154 101 155 =over 4 102 156 103 =item B<target-dir>104 105 This is the target directory under which the VE will be created.106 Created on the fly if needed.107 If none is given use the default directory hosting VE for project-builder.org108 (Cf: vepath parameter in $HOME/.pbrc)109 110 157 =back 111 158 112 159 =head1 EXAMPLE 113 160 114 To setup a USB boot media on the /dev/sdb device for a Fedora 12 distribution with an i386 architecture issue: 115 116 pbmkbm -t usb -d /dev/sdb -m fedora-12-i386 161 To setup a USB busybox based boot media on the /dev/sdb device for a Fedora 12 distribution with an i386 architecture issue: 162 163 pbmkbm -t usb -d /dev/sdb -m fedora-12-i386 -b busybox 164 165 To setup an ISO image under /tmp for a RHEL 6 x86_64 distribution issue using the native environment: 166 167 pbmkbm -t iso -d /tmp -m rhel-6-x86_64 -b ve 117 168 118 169 =head1 WEB SITES … … 153 204 154 205 GetOptions("help|?|h" => \$opts{'h'}, 155 "man |m" => \$opts{'man'},206 "man" => \$opts{'man'}, 156 207 "verbose|v+" => \$opts{'v'}, 157 208 "quiet|q" => \$opts{'q'}, … … 160 211 "machine|m=s" => \$opts{'m'}, 161 212 "add|a=s" => \$opts{'a'}, 213 "device|d=s" => \$opts{'d'}, 214 "type|t=s" => \$opts{'t'}, 215 "boot|b=s" => \$opts{'b'}, 162 216 "version|V=s" => \$opts{'V'}, 163 217 ) || pb_syntax(-1,0); … … 184 238 # Get VE name 185 239 $ENV{'PBV'} = $opts{'m'}; 186 die pb_syntax(-1,1) if (not defined $ENV{'PBV'});187 188 die "Needs to be run as root" if ($EFFECTIVE_USER_ID != 0);189 240 190 241 # 191 242 # Initialize distribution info from pb conf file 192 243 # 193 pb_log(0,"Starting VE build for $ENV{'PBV'}\n");194 244 my $pbos = pb_distro_get_context($ENV{'PBV'}); 245 pb_log(0,"Starting boot media build for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}\n"); 246 247 pb_env_init_pbrc(); # to get content of HOME/.pbrc 195 248 196 249 # … … 198 251 # Create if not existent and use default if none given 199 252 # 200 pb_env_init_pbrc(); # to get content of HOME/.pbrc 201 my $vepath = shift @ARGV; 253 my $targetdir = shift @ARGV; 202 254 203 255 # … … 207 259 pb_check_requirements($req,$opt,$appname); 208 260 209 if (not defined $vepath) { 210 my ($vestdpath) = pb_conf_get("vepath"); 211 $vepath = "$vestdpath->{'default'}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}" if (defined $vestdpath->{'default'}); 212 } 213 214 die pb_log(0,"No target-dir specified and no default vepath found in $ENV{'PBETC'}\n") if (not defined $vepath); 215 216 pb_mkdir_p($vepath) if (! -d $vepath); 217 218 # 261 # After that we will need root access 262 die "$appname needs to be run as root" if ($EFFECTIVE_USER_ID != 0); 263 264 # 265 # Where is our build target directory 266 # 267 268 if (not defined $targetdir) { 269 $targetdir = "/var/cache/pbmkbm"; 270 my ($vestdpath) = pb_conf_get("mkbmpath"); 271 $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); 275 276 # Point to the right subdir and create it if needed 277 pb_mkdir_p($targetdir) if (! -d $targetdir); 278 279 280 # Now the preparation is over, we need to do something useful :-) 281 # But it all depends on how we're asked to do it. 282 # 283 # First we need to copy into the target dir all the relevant content 284 pb_mkbm_create_content(); 285 286 # Then we need to package this content in the destination format 287 pb_mkbm_create_media(); 288 289 sub pb_mkbm_create_content { 290 291 pb_log(1,"Creating boot media content\n"); 292 if ($opts{'b'} eq "ve") { 293 # Use existing tools to create a good VE ! 294 pb_ve_launch($ENV{'PBV'}); 295 } elsif ($opts{'b'} eq "native") { 296 # Use native tools to create a good VE ! 297 } else { 298 die "Unknown method $opts{'b'} used to create the media content"; 299 } 300 } 301 302 sub pb_mkbm_create_media { 303 304 } 305 219 306 # Get the package list to download, store them in a cache directory 220 307 # 221 308 my ($mkbmcachedir) = pb_conf_get_if("mkbmcachedir"); 222 my ($pkgs,$mirror) = pb_distro_get_param($pbos,pb_conf_get("mkbmmindep","mkbmmirrorsrv")); 223 224 my $cachedir = "/var/cache/pbmkbm"; 225 $cachedir = $mkbmcachedir->{'default'} if (defined $mkbmcachedir->{'default'}); 226 227 # Point to the right subdir and create it if needed 228 $cachedir .= "/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 229 pb_mkdir_p($cachedir) if (! -d $cachedir); 309 my ($pkgs) = pb_distro_get_param($pbos,pb_conf_get("mkbmmindep")); 230 310 231 311 # 232 312 # /proc needed 233 313 # 234 pb_system("mount -o bind /proc $ vepath/proc","Mounting /proc");314 pb_system("mount -o bind /proc $targetdir/proc","Mounting /proc"); 235 315 236 316 # Installed additional packages we were asked to 237 317 if (defined $opts{'a'}) { 238 318 $opts{'a'} =~ s/,/ /g; 239 pb_system("chroot $ vepath/bin/bash -c \"$pbos->{'install'} $opts{'a'} \"","Adding packages to OS by running $pbos->{'install'} $opts{'a'}");319 pb_system("chroot $targetdir /bin/bash -c \"$pbos->{'install'} $opts{'a'} \"","Adding packages to OS by running $pbos->{'install'} $opts{'a'}"); 240 320 } 241 321 … … 244 324 # 245 325 pb_log(1,"Cleaning up\n"); 246 pb_system("umount $ vepath/proc","Unmounting /proc");326 pb_system("umount $targetdir/proc","Unmounting /proc"); 247 327 248 328 # Executes post-install step if asked for 249 329 if ($opts{'s'}) { 250 pb_system("$opts{'s'} $ vepath","Executing the post-install script: $opts{'s'} $vepath");251 } 330 pb_system("$opts{'s'} $targetdir","Executing the post-install script: $opts{'s'} $targetdir"); 331 }
Note:
See TracChangeset
for help on using the changeset viewer.