[16] | 1 | #!/usr/bin/perl -w |
---|
| 2 | # IBM_PROLOG_BEGIN_TAG |
---|
| 3 | # This is an automatically generated prolog. |
---|
| 4 | # |
---|
| 5 | # |
---|
| 6 | # |
---|
| 7 | # Licensed Materials - Property of IBM |
---|
| 8 | # |
---|
| 9 | # (C) COPYRIGHT International Business Machines Corp. 2005,2006 |
---|
| 10 | # All Rights Reserved |
---|
| 11 | # |
---|
| 12 | # US Government Users Restricted Rights - Use, duplication or |
---|
| 13 | # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. |
---|
| 14 | # |
---|
| 15 | # IBM_PROLOG_END_TAG |
---|
| 16 | #------------------------------------------------------------------------------- |
---|
| 17 | # Items that may be overridden: |
---|
| 18 | # - GPFS source location -- Does not require any knowledge of the system |
---|
| 19 | # configurable parameters. |
---|
| 20 | # - OS Kernel headers -- Does not necessarily preclude the automatically |
---|
| 21 | # determined system configuration (but the implications of specifying them |
---|
| 22 | # indicates a mismatch with automatically determinable items). |
---|
| 23 | #------------------------------------------------------------------------------- |
---|
| 24 | |
---|
| 25 | #------------------------------------------------------------------------------- |
---|
| 26 | # function: usage |
---|
| 27 | # |
---|
| 28 | # This function displays the usage for the auto-configuration program. |
---|
| 29 | #------------------------------------------------------------------------------- |
---|
| 30 | sub usage() |
---|
| 31 | { |
---|
| 32 | # Obtain invoked program name |
---|
| 33 | $program = `basename $0`; |
---|
| 34 | chomp($program); |
---|
| 35 | |
---|
| 36 | # Display full syntax description |
---|
| 37 | print "\nUsage: ${program} [--help] [sharkcloneroot=<dir>]\n"; |
---|
| 38 | print "\nOptions:\n"; |
---|
| 39 | print "\n --help"; |
---|
| 40 | print "\n Display ${program} help and exit.\n"; |
---|
| 41 | print "\n sharkcloneroot=<dir>"; |
---|
| 42 | print "\n Specify the location of the source tree to configure."; |
---|
| 43 | print "\n If not specified, check the SHARKCLONEROOT environment"; |
---|
| 44 | print "\n variable. If neither is specifiec, default to the GPL"; |
---|
| 45 | print "\n source directory /usr/lpp/mmfs/src.\n"; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | #------------------------------------------------------------------------------- |
---|
| 49 | # function: get_OS |
---|
| 50 | # |
---|
| 51 | # This function determines the target Operating System. |
---|
| 52 | #------------------------------------------------------------------------------- |
---|
| 53 | sub get_OS() |
---|
| 54 | { |
---|
| 55 | local ($os); |
---|
| 56 | local ($gpfs_os); |
---|
| 57 | |
---|
| 58 | $os = `uname`; |
---|
| 59 | if ($os =~ "AIX") |
---|
| 60 | { |
---|
| 61 | $gpfs_os = "GPFS_AIX"; |
---|
| 62 | } |
---|
| 63 | elsif ($os =~ "Linux") |
---|
| 64 | { |
---|
| 65 | $gpfs_os = "GPFS_LINUX"; |
---|
| 66 | } |
---|
| 67 | else |
---|
| 68 | { |
---|
| 69 | $gpfs_os = "UNSUPPORTED"; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | return($gpfs_os); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | #------------------------------------------------------------------------------- |
---|
| 76 | # function: get_Architecture |
---|
| 77 | # |
---|
| 78 | # This function determines the target hardware architecture. |
---|
| 79 | #------------------------------------------------------------------------------- |
---|
| 80 | sub get_Architecture() |
---|
| 81 | { |
---|
| 82 | local ($arch); |
---|
| 83 | local ($gpfs_arch); |
---|
| 84 | |
---|
| 85 | $arch = `uname -m`; |
---|
| 86 | if ($arch =~ /^ia64$/) |
---|
| 87 | { |
---|
| 88 | $gpfs_arch = "GPFS_ARCH_IA64"; |
---|
| 89 | } |
---|
| 90 | elsif ($arch =~ /^i\d86$/) |
---|
| 91 | { |
---|
| 92 | $gpfs_arch = "GPFS_ARCH_I386"; |
---|
| 93 | } |
---|
| 94 | elsif ($arch =~ /^ppc$/) |
---|
| 95 | { |
---|
| 96 | $gpfs_arch = "GPFS_ARCH_POWER"; |
---|
| 97 | } |
---|
| 98 | elsif ($arch =~ /^ppc64$/) |
---|
| 99 | { |
---|
| 100 | $gpfs_arch = "GPFS_ARCH_PPC64"; |
---|
| 101 | } |
---|
| 102 | elsif ($arch =~ /^x86_64$/) |
---|
| 103 | { |
---|
| 104 | $gpfs_arch = "GPFS_ARCH_X86_64"; |
---|
| 105 | } |
---|
| 106 | else |
---|
| 107 | { |
---|
| 108 | $gpfs_arch = "UNSUPPORTED"; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | return($gpfs_arch); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | #------------------------------------------------------------------------------- |
---|
| 115 | # function: get_DistValues |
---|
| 116 | # |
---|
| 117 | # This function determines the target Linux distribution values. |
---|
| 118 | #------------------------------------------------------------------------------- |
---|
| 119 | sub get_DistValues() |
---|
| 120 | { |
---|
| 121 | local ($redhat_release, $suse_release); |
---|
| 122 | local ($dist, $dist_level, $kernel_string); |
---|
| 123 | local($version, $release, $modification, $fix); |
---|
| 124 | local($modification_actual, $fix_actual); |
---|
| 125 | |
---|
| 126 | local($kernel, $kernel_actual); |
---|
| 127 | |
---|
| 128 | $suse_release = "/etc/SuSE-release"; |
---|
| 129 | $redhat_release = "/etc/redhat-release"; |
---|
| 130 | |
---|
| 131 | # Obtain the running kernel version string |
---|
| 132 | $kernel_string = `uname -r`; |
---|
| 133 | chomp($kernel_string); |
---|
| 134 | if ($kernel_string =~ /([2])\.([46]).(\d+)(.*)$/) |
---|
| 135 | { |
---|
| 136 | # Obtain the version, release, modification and fix level. Also obtain |
---|
| 137 | # the "actual" modification and fix values (full, unmodified numeric only |
---|
| 138 | # values) required for SLES 9 kernel headers. |
---|
| 139 | $version = $1; |
---|
| 140 | $release = $2; |
---|
| 141 | $modification_actual = $modification = $3; |
---|
| 142 | $fix = $4; |
---|
| 143 | |
---|
| 144 | if ($modification > 99) |
---|
| 145 | { |
---|
| 146 | # Reduce modification to two digits to fit format string. |
---|
| 147 | $modification = 99; |
---|
| 148 | } |
---|
| 149 | if ($fix =~ /^.(\d+)([.-])(\d+)([.-])(\d+)/) |
---|
| 150 | { |
---|
| 151 | # Fix level utilizes a multi-numeric format "." or "-" separated. |
---|
| 152 | $fix = $1; |
---|
| 153 | $fix_actual = $1 . $2 . $3 . $4 . $5; |
---|
| 154 | } |
---|
| 155 | elsif ($fix =~ /^([.-])(\d+)([.-])(\d+)/) |
---|
| 156 | { |
---|
| 157 | # Fix level utilizes a multi-numeric format "." or "-" separated. |
---|
| 158 | $fix = $2; |
---|
| 159 | $fix_actual = $1 . $2 . $3 . $4; |
---|
| 160 | } |
---|
| 161 | elsif ($fix =~ /^-(\d+)/) |
---|
| 162 | { |
---|
| 163 | # Fix level utilizes a single-numeric format. |
---|
| 164 | $fix_actual = $fix = $1; |
---|
| 165 | } |
---|
| 166 | else |
---|
| 167 | { |
---|
| 168 | # No fix level in format; assign one to fit format string. |
---|
| 169 | $fix = "00"; |
---|
| 170 | } |
---|
| 171 | if ($fix > 99) |
---|
| 172 | { |
---|
| 173 | # Reduce fix to two digits to fit format string. |
---|
| 174 | $fix = 99; |
---|
| 175 | } |
---|
| 176 | $kernel = sprintf("%01d%02d%02d%02d", $version, $release, $modification, |
---|
| 177 | $fix); |
---|
| 178 | $kernel_actual = sprintf("%d.%d.%d-%s", $version, $release, |
---|
| 179 | $modification_actual, $fix_actual); |
---|
| 180 | } |
---|
| 181 | else |
---|
| 182 | { |
---|
| 183 | die("Cannot parse kernel version $kernel_string\n"); |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | # DES: Fix this...if we do NOT do alternate configurations |
---|
| 187 | # If the requested build is for the local machine, then we can determine the |
---|
| 188 | # following information from local files. Otherwise, the user will have to |
---|
| 189 | # provide that information. |
---|
| 190 | if (-f $suse_release) |
---|
| 191 | { |
---|
| 192 | # SuSE Release |
---|
| 193 | $dist = "SUSE_LINUX"; |
---|
| 194 | $dist_level = "80"; |
---|
| 195 | open(RELFILE, $suse_release) || die "Cannot open $suse_release"; |
---|
| 196 | LINE: while ($line = <RELFILE>) |
---|
| 197 | { |
---|
| 198 | if ($line =~ /VERSION = (\d+)/ ) |
---|
| 199 | { |
---|
| 200 | $dist_version = $1; |
---|
| 201 | } |
---|
| 202 | } |
---|
| 203 | close(RELFILE); |
---|
| 204 | |
---|
| 205 | # Determine the kernel headers directory |
---|
| 206 | $lib_mod_bld_dir = "/lib/modules/$kernel_string/build/include"; |
---|
| 207 | $lib_mod_src_dir = "/lib/modules/$kernel_string/source/include"; |
---|
| 208 | $usr_src_dir = "/usr/src/linux-$kernel_actual/include"; |
---|
| 209 | if ($dist_version eq "8" && (-f "$lib_mod_bld_dir/linux/version.h")) |
---|
| 210 | { |
---|
| 211 | $kernel_hdr_dir = $lib_mod_bld_dir; |
---|
| 212 | # Build directory not required for the 2.4 kernel |
---|
| 213 | $kernel_bld_dir = ""; |
---|
| 214 | } |
---|
| 215 | elsif ($dist_version eq "9" && (-f "$lib_mod_src_dir/linux/version.h")) |
---|
| 216 | { |
---|
| 217 | $kernel_hdr_dir = $lib_mod_src_dir; |
---|
| 218 | # Build directory for the linux 2.6 kernel |
---|
| 219 | $kernel_bld_dir = "/lib/modules/$kernel_string/build"; |
---|
| 220 | } |
---|
| 221 | elsif ($dist_version eq "9" && (-f "$usr_src_dir/linux/version.h")) |
---|
| 222 | { |
---|
| 223 | $kernel_hdr_dir = $usr_src_dir; |
---|
| 224 | # cannot guess the value in this case - let the user specify this |
---|
| 225 | $kernel_bld_dir = ""; |
---|
| 226 | } |
---|
| 227 | elsif ($dist_version eq "10" && (-f "$lib_mod_src_dir/linux/version.h")) |
---|
| 228 | { |
---|
| 229 | $kernel_hdr_dir = $lib_mod_src_dir; |
---|
| 230 | # cannot guess the value in this case - let the user specify this |
---|
| 231 | $kernel_bld_dir = "/lib/modules/$kernel_string/build"; |
---|
| 232 | } |
---|
| 233 | elsif ($dist_version eq "10" && (-f "$usr_src_dir/linux/version.h")) |
---|
| 234 | { |
---|
| 235 | $kernel_hdr_dir = $usr_src_dir; |
---|
| 236 | # cannot guess the value in this case - let the user specify this |
---|
| 237 | $kernel_bld_dir = ""; |
---|
| 238 | } |
---|
| 239 | else |
---|
| 240 | { |
---|
| 241 | die ("Cannot find a valid kernel include dir\n"); |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | # ensure that the source directory has the right autoconf.h and version.h |
---|
| 245 | # copied to it. Due to some distro bugs this may not always be the case. |
---|
| 246 | if ($kernel_hdr_dir ne "" && $kernel_bld_dir ne "") |
---|
| 247 | { |
---|
| 248 | if (system("/usr/bin/diff -q $kernel_hdr_dir/linux/version.h $kernel_bld_dir/include/linux/version.h") != 0) |
---|
| 249 | { |
---|
| 250 | die("Kernel source tree does not have the correct version.h file.\n", |
---|
| 251 | "See /usr/lpp/mmfs/src/README for further information\n"); |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | if (system("/usr/bin/diff -q $kernel_hdr_dir/linux/autoconf.h $kernel_bld_dir/include/linux/autoconf.h") != 0) |
---|
| 255 | { |
---|
| 256 | die("Kernel source tree does not have the correct autoconf.h file.\n", |
---|
| 257 | "See /usr/lpp/mmfs/src/README for further information\n"); |
---|
| 258 | } |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | } |
---|
| 262 | elsif (-f $redhat_release) |
---|
| 263 | { |
---|
| 264 | # RedHat Release |
---|
| 265 | open(RELFILE, $redhat_release) || die "Cannot open $redhat_release"; |
---|
| 266 | LINE: while ($line = <RELFILE>) |
---|
| 267 | { |
---|
| 268 | if ($line =~ /Red Hat Linux release (\S+)/ ) |
---|
| 269 | { |
---|
| 270 | $dist = "REDHAT_LINUX"; |
---|
| 271 | $dist_level = $1 eq "9" ? "90" : "80"; |
---|
| 272 | } |
---|
| 273 | elsif ($line =~ /Red Hat Enterprise Linux/ ) |
---|
| 274 | { |
---|
| 275 | $dist = "REDHAT_AS_LINUX"; |
---|
| 276 | $dist_level = "80"; |
---|
| 277 | } |
---|
| 278 | } |
---|
| 279 | close(RELFILE); |
---|
| 280 | |
---|
| 281 | # Determine the kernel headers directory |
---|
| 282 | $lib_mod_dir = "/lib/modules/$kernel_string/build/include"; |
---|
| 283 | $usr_src_dir = "/usr/src/linux-$kernel_string/include"; |
---|
| 284 | if (-f "$lib_mod_dir/linux/version.h") |
---|
| 285 | { |
---|
| 286 | $kernel_hdr_dir = $lib_mod_dir; |
---|
| 287 | $kernel_bld_dir = "/lib/modules/$kernel_string/build"; |
---|
| 288 | } |
---|
| 289 | elsif (-f "$usr_src_dir/linux/version.h") |
---|
| 290 | { |
---|
| 291 | $kernel_hdr_dir = $usr_src_dir; |
---|
| 292 | $kernel_bld_dir = "/usr/src/linux-$kernel_string"; |
---|
| 293 | } |
---|
| 294 | else |
---|
| 295 | { |
---|
| 296 | die ("Cannot find a valid kernel include dir\n"); |
---|
| 297 | } |
---|
| 298 | } |
---|
| 299 | else |
---|
| 300 | { |
---|
| 301 | $dist = "UNSUPPORTED"; |
---|
| 302 | $dist_level = "UNSUPPORTED"; |
---|
| 303 | $kernel = "UNSUPPORTED"; |
---|
| 304 | $kernel_hdr_dir = "UNSUPPORTED"; |
---|
| 305 | $kernel_bld_dir = "UNSUPPORTED"; |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | return($dist, $dist_level, $kernel, $kernel_hdr_dir, $kernel_bld_dir); |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | #------------------------------------------------------------------------------- |
---|
| 312 | # function: write_config |
---|
| 313 | # |
---|
| 314 | # This function writes the build configuration file, combining the template and |
---|
| 315 | # the supplied configuration values. |
---|
| 316 | #------------------------------------------------------------------------------- |
---|
| 317 | sub write_config() |
---|
| 318 | { |
---|
| 319 | local ($os, $architecture, $dist, $dist_level, $kernel); |
---|
| 320 | local ($kernel_hdr_dir, $template_dir); |
---|
| 321 | |
---|
| 322 | $os = shift; |
---|
| 323 | $architecture = shift; |
---|
| 324 | $dist = shift; |
---|
| 325 | $dist_level = shift; |
---|
| 326 | $kernel = shift; |
---|
| 327 | $kernel_hdr_dir = shift; |
---|
| 328 | $kernel_bld_dir = shift; |
---|
| 329 | $template_dir = shift; |
---|
| 330 | |
---|
| 331 | # Open the template and build configuration files |
---|
| 332 | open(TEMPLATE, "$template_dir/site.mcr.proto") || |
---|
| 333 | die "Unable to open template file $template_dir/site.mcr.proto\n"; |
---|
| 334 | open(CONFIG, ">$template_dir/site.mcr") || |
---|
| 335 | die "Unable to open configuration file $template_dir/site.mcr\n"; |
---|
| 336 | |
---|
| 337 | #----------------------------- |
---|
| 338 | # Generate configuration file |
---|
| 339 | #----------------------------- |
---|
| 340 | foreach $line (<TEMPLATE>) |
---|
| 341 | { |
---|
| 342 | # Substitute variable fields in configuration file |
---|
| 343 | if ($line =~ m/^#define GPFS_LINUX$/) |
---|
| 344 | { |
---|
| 345 | $line =~ s/GPFS_LINUX$/$os/; |
---|
| 346 | } |
---|
| 347 | elsif ($line =~ m/^#define GPFS_ARCH_I386$/) |
---|
| 348 | { |
---|
| 349 | $line =~ s/GPFS_ARCH_I386$/$architecture/; |
---|
| 350 | } |
---|
| 351 | elsif (($line =~ m/^LINUX_DISTRIBUTION = REDHAT_LINUX$/) && ($os eq "GPFS_LINUX")) |
---|
| 352 | { |
---|
| 353 | $line =~ s/REDHAT_LINUX$/$dist/; |
---|
| 354 | } |
---|
| 355 | elsif (($line =~ m/^#define LINUX_DISTRIBUTION_LEVEL 90$/) && ($os eq "GPFS_LINUX")) |
---|
| 356 | { |
---|
| 357 | $line =~ s/90$/$dist_level/; |
---|
| 358 | } |
---|
| 359 | elsif (($line =~ m/^#define LINUX_KERNEL_VERSION 2042028$/) && ($os eq "GPFS_LINUX")) |
---|
| 360 | { |
---|
| 361 | $line =~ s/2042028$/$kernel/; |
---|
| 362 | } |
---|
| 363 | elsif (($line =~ m/^KERNEL_HEADER_DIR = \/lib\/modules\/`uname -r`\/build\/include$/) && ($os eq "GPFS_LINUX")) |
---|
| 364 | { |
---|
| 365 | $line =~ s/\/lib\/modules\/`uname -r`\/build\/include$/$kernel_hdr_dir/; |
---|
| 366 | } |
---|
| 367 | elsif (($line =~ m/^KERNEL_BUILD_DIR = \/lib\/modules\/`uname -r`\/build$/) && ($os eq "GPFS_LINUX")) |
---|
| 368 | { |
---|
| 369 | $line =~ s/\/lib\/modules\/`uname -r`\/build$/$kernel_bld_dir/; |
---|
| 370 | } |
---|
| 371 | print CONFIG "$line"; |
---|
| 372 | } |
---|
| 373 | |
---|
| 374 | # Close the template and configuration files. |
---|
| 375 | close(TEMPLATE); |
---|
| 376 | close(CONFIG); |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | #------------------------------------------------------------------------------- |
---|
| 380 | # function: configure |
---|
| 381 | # |
---|
| 382 | # This function obtains the full set of build configuration values, generating |
---|
| 383 | # the configuration file from the template. |
---|
| 384 | #------------------------------------------------------------------------------- |
---|
| 385 | sub configure() |
---|
| 386 | { |
---|
| 387 | local ($architecture, $dist, $dist_level, $kernel, $kernel_hdr_dir, $os); |
---|
| 388 | local ($sharkcloneroot, $template_dir); |
---|
| 389 | |
---|
| 390 | # Obtain input parameters |
---|
| 391 | $sharkcloneroot = shift; |
---|
| 392 | |
---|
| 393 | #------------------------ |
---|
| 394 | # Verify source location |
---|
| 395 | #------------------------ |
---|
| 396 | if ($sharkcloneroot =~ m/^[^\/]/) |
---|
| 397 | { |
---|
| 398 | # Source path not fully qualified |
---|
| 399 | print STDERR "Source path not fully qualified: $sharkcloneroot\n"; |
---|
| 400 | return(-1); |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | #---------------------------------------------------------------- |
---|
| 404 | # Verify build type (GPL or development) from template location. |
---|
| 405 | #---------------------------------------------------------------- |
---|
| 406 | if (-e "$sharkcloneroot/config/site.mcr.proto") |
---|
| 407 | { |
---|
| 408 | $template_dir = "$sharkcloneroot/config"; |
---|
| 409 | } |
---|
| 410 | elsif (-e "$sharkcloneroot/shark-config/site.mcr.proto") |
---|
| 411 | { |
---|
| 412 | $template_dir = "$sharkcloneroot/shark-config"; |
---|
| 413 | } |
---|
| 414 | else |
---|
| 415 | { |
---|
| 416 | print STDERR "Missing or incomplete source at: $sharkcloneroot\n"; |
---|
| 417 | return(-1); |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | #------------------------- |
---|
| 421 | # Determine the target OS |
---|
| 422 | #------------------------- |
---|
| 423 | $os = get_OS(); |
---|
| 424 | if ($os eq "GPFS_LINUX") |
---|
| 425 | { |
---|
| 426 | #--------------------------------------- |
---|
| 427 | # Determine Linux specific settings |
---|
| 428 | #--------------------------------------- |
---|
| 429 | |
---|
| 430 | # Determine the Architecture |
---|
| 431 | $architecture = get_Architecture(); |
---|
| 432 | if ($architecture eq "UNSUPPORTED") |
---|
| 433 | { |
---|
| 434 | print STDERR "Unsupported Architecture: $architecture\n"; |
---|
| 435 | $rc = -1; |
---|
| 436 | return($rc); |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | # Determine the Distribution, Kernel, Kern Header Directory |
---|
| 440 | ($dist, $dist_level, $kernel, $kernel_hdr_dir, $kernel_bld_dir) = get_DistValues(); |
---|
| 441 | if ($dist eq "UNSUPPORTED") |
---|
| 442 | { |
---|
| 443 | print STDERR "Unsupported Distribution: $dist\n"; |
---|
| 444 | $rc = -1; |
---|
| 445 | return($rc); |
---|
| 446 | } |
---|
| 447 | if ($dist_level eq "UNSUPPORTED") |
---|
| 448 | { |
---|
| 449 | print STDERR "Unsupported Distribution Level: $dist_level\n"; |
---|
| 450 | $rc = -1; |
---|
| 451 | return($rc); |
---|
| 452 | } |
---|
| 453 | } |
---|
| 454 | elsif ($os eq "GPFS_AIX") |
---|
| 455 | { |
---|
| 456 | #--------------------------------- |
---|
| 457 | # Determine AIX specific settings |
---|
| 458 | # |
---|
| 459 | # NOTE: Only require architecture |
---|
| 460 | #--------------------------------- |
---|
| 461 | |
---|
| 462 | $architecture = "GPFS_ARCH_POWER"; |
---|
| 463 | } |
---|
| 464 | else |
---|
| 465 | { |
---|
| 466 | #------------------------------ |
---|
| 467 | # Unsupported Operating System |
---|
| 468 | #------------------------------ |
---|
| 469 | |
---|
| 470 | print STDERR "Unsupported Operating System: $os\n"; |
---|
| 471 | $rc = -1; |
---|
| 472 | exit($rc); |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | # If we have gotten to this point without an error occurrence, then process |
---|
| 476 | # the site.mcr.proto and write a site.mcr file for the source code build. |
---|
| 477 | if ($rc eq 0) |
---|
| 478 | { |
---|
| 479 | &write_config($os, $architecture, $dist, $dist_level, $kernel, |
---|
| 480 | $kernel_hdr_dir, $kernel_bld_dir, $template_dir); |
---|
| 481 | } |
---|
| 482 | |
---|
| 483 | return(0); |
---|
| 484 | } |
---|
| 485 | |
---|
| 486 | #------------------------------------------------------------------------------- |
---|
| 487 | # Main program |
---|
| 488 | #------------------------------------------------------------------------------- |
---|
| 489 | |
---|
| 490 | # Initialize utility variables |
---|
| 491 | $rc = 0; |
---|
| 492 | |
---|
| 493 | # Initialize core variables |
---|
| 494 | $sharkcloneroot = undef; |
---|
| 495 | |
---|
| 496 | # Process command-line arguments |
---|
| 497 | foreach $arg (sort @ARGV) |
---|
| 498 | { |
---|
| 499 | if ($arg =~ m/^-/) |
---|
| 500 | { |
---|
| 501 | # Option specified |
---|
| 502 | if ($arg eq "--help") |
---|
| 503 | { |
---|
| 504 | # Help requested ==> Display usage, exit success |
---|
| 505 | usage(); |
---|
| 506 | exit(0); |
---|
| 507 | } |
---|
| 508 | else |
---|
| 509 | { |
---|
| 510 | # Unknown option ==> Display usage, exit failure |
---|
| 511 | usage(); |
---|
| 512 | exit(1); |
---|
| 513 | } |
---|
| 514 | } |
---|
| 515 | else |
---|
| 516 | { |
---|
| 517 | # Attribute/value pair specified |
---|
| 518 | ($attr, $value) = split("=", $arg); |
---|
| 519 | if ($attr eq "sharkcloneroot") |
---|
| 520 | { |
---|
| 521 | # Source override specified |
---|
| 522 | if (!$sharkcloneroot) |
---|
| 523 | { |
---|
| 524 | $sharkcloneroot = $value; |
---|
| 525 | } |
---|
| 526 | else |
---|
| 527 | { |
---|
| 528 | ### prtMsg(36, "source"); |
---|
| 529 | usage(); |
---|
| 530 | exit(1); |
---|
| 531 | } |
---|
| 532 | } |
---|
| 533 | else |
---|
| 534 | { |
---|
| 535 | # Invalid override |
---|
| 536 | print STDERR "Invalid override: $attr\n"; |
---|
| 537 | usage(); |
---|
| 538 | exit(1); |
---|
| 539 | } |
---|
| 540 | } |
---|
| 541 | } |
---|
| 542 | |
---|
| 543 | #-------------------------------------- |
---|
| 544 | # Assign program defaults as necessary |
---|
| 545 | #-------------------------------------- |
---|
| 546 | |
---|
| 547 | # Define the source directory. The default value may be overridden with the |
---|
| 548 | # following priority utilized: |
---|
| 549 | # 1) sharkcloneroot attribute setting supplied via command line |
---|
| 550 | # 2) SHARKCLONEROOT environment variable |
---|
| 551 | # 3) /usr/lpp/mmfs/bin default |
---|
| 552 | if (!$sharkcloneroot) |
---|
| 553 | { |
---|
| 554 | # sharkcloneroot attribute unspecified |
---|
| 555 | if (defined $ENV{SHARKCLONEROOT}) |
---|
| 556 | { |
---|
| 557 | # SHARKCLONEROOT environment variable specified |
---|
| 558 | $sharkcloneroot = $ENV{SHARKCLONEROOT}; |
---|
| 559 | } |
---|
| 560 | else |
---|
| 561 | { |
---|
| 562 | # SHARKCLONEROOT environment variable unspecified |
---|
| 563 | $sharkcloneroot = "/usr/lpp/mmfs/src"; |
---|
| 564 | } |
---|
| 565 | } |
---|
| 566 | |
---|
| 567 | #---------------------------------------------------------- |
---|
| 568 | # Process the configuration; Return success/failure status |
---|
| 569 | #---------------------------------------------------------- |
---|
| 570 | $rc = &configure($sharkcloneroot); |
---|
| 571 | exit($rc); |
---|
| 572 | |
---|
| 573 | #------------------------------------------------------------------------------- |
---|