solpkg 2.1 KB

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