4
0

solpkg 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 =~ "pst3") {
  33. # Needs to be installed SUID root
  34. ($dir, $none, $file, $mode, $user, $group) = split / /,$thisline;
  35. print PROTO "$dir $none $file 4755 root bin\n";
  36. } elsif ($thisline =~ "^[fd] ") {
  37. # Change the ownership of files and directories
  38. ($dir, $none, $file, $mode, $user, $group) = split / /,$thisline;
  39. print PROTO "$dir $none $file $mode $user bin\n";
  40. } else {
  41. # Symlinks and other stuff should be printed also
  42. print PROTO "$thisline\n";
  43. }
  44. }
  45. close PROTO;
  46. close PREPROTO;
  47. # Now we can start building the package
  48. $os = `uname -r`;
  49. $os =~ '\.';
  50. $os = "sol$'";
  51. chomp $os;
  52. open (PKGINFO,"<$pkginfo") ||
  53. die "Unable to read package information ($!)\n";
  54. while (<PKGINFO>) {
  55. # Read in the package information
  56. chomp;
  57. $thisline = $_;
  58. ($var,$value) = split /=/,$thisline;
  59. if ("$var" eq "NAME"
  60. or "$var" eq "PKG"
  61. or "$var" eq "VERSION"
  62. or "$var" eq "ARCH") {
  63. $tmp = lc($var);
  64. $value =~ s/\"//g;
  65. if ("$tmp" eq "version"
  66. and $value =~ ",REV") {
  67. ($value,$var) = split /\,/,$value;
  68. $$tmp = $value;
  69. } else {
  70. $$tmp = $value;
  71. }
  72. }
  73. }
  74. close PKGINFO;
  75. $packagename = "$name-$version-$os-$arch-local";
  76. print "Building package\n";
  77. system ("$pkgmk -o -r `pwd` -d $pkgdevice");
  78. system ("(cd $pkgdevice && $pkgtrans -s `pwd` ../$packagename $pkg)");
  79. print "Done. ($packagename)\n";