solpkg 2.0 KB

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