solpkg 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/usr/bin/perl
  2. $pkgdevice = $ARGV[0] || die "Unable to determine device ($!)\n";
  3. $find = "/usr/bin/find";
  4. $pkgproto = "/usr/bin/pkgproto";
  5. $pkgmk = "/usr/bin/pkgmk";
  6. $pkgtrans = "/usr/bin/pkgtrans";
  7. $prototype = "prototype";
  8. $pkginfo = "pkginfo";
  9. # Sanity check
  10. $pwd = `pwd`;
  11. if ($pwd =~ '\/usr\/local') {
  12. $pwd = $`;
  13. }
  14. die "Wrong location, please cd to <PKGBASE>/usr/local/ and run again.\n"
  15. if ($pwd eq "");
  16. open (PREPROTO,"$find . -print |$pkgproto |") ||
  17. die "Unable to read prototype information ($!)\n";
  18. open (PROTO,">$prototype") ||
  19. die "Unable to write file prototype ($!)\n";
  20. print PROTO "i pkginfo=./$pkginfo\n";
  21. while (<PREPROTO>) {
  22. # Read in the prototype information
  23. chomp;
  24. $thisline = $_;
  25. if ($thisline =~ " prototype "
  26. or $thisline =~ " pkginfo ") {
  27. # Don't do anything as they aren't important
  28. } elsif ($thisline =~ "^[fd] ") {
  29. # Change the ownership of files and directories
  30. ($dir, $none, $file, $mode, $user, $group) = split / /,$thisline;
  31. print PROTO "$dir $none $file $mode bin bin\n";
  32. } else {
  33. # Symlinks and other stuff should be printed also
  34. print PROTO "$thisline\n";
  35. }
  36. }
  37. close PROTO;
  38. close PREPROTO;
  39. # Now we can start building the package
  40. $os = `uname -r`;
  41. $os =~ '\.';
  42. $os = "sol$'";
  43. chomp $os;
  44. open (PKGINFO,"<$pkginfo") ||
  45. die "Unable to read package information ($!)\n";
  46. while (<PKGINFO>) {
  47. # Read in the package information
  48. chomp;
  49. $thisline = $_;
  50. ($var,$value) = split /=/,$thisline;
  51. if ("$var" eq "NAME"
  52. or "$var" eq "VERSION"
  53. or "$var" eq "ARCH") {
  54. $tmp = lc($var);
  55. $value =~ s/\"//g;
  56. if ("$tmp" eq "version"
  57. and $value =~ ",REV") {
  58. ($value,$var) = split /\,/,$value;
  59. $$tmp = $value;
  60. } else {
  61. $$tmp = $value;
  62. }
  63. }
  64. }
  65. close PKGINFO;
  66. $packagename = "$name-$version-$os-$arch-local";
  67. print "Building package\n";
  68. system ("$pkgmk -o -r `pwd` -d $pkgdevice");
  69. system ("(cd $pkgdevice && $pkgtrans -s `pwd` ../$packagename)");
  70. print "Done. ($packagename)\n";