home *** CD-ROM | disk | FTP | other *** search
/ Caldera Network Desktop 1.0 / caldera-network-desktop-1.0.bin / images / ramdisk2-beta.img / usr / bin / rpm < prev   
Text File  |  1995-10-24  |  6KB  |  194 lines

  1. #!/usr/bin/perl
  2.  
  3. # RPM Package Management System
  4. # Copyright (C) 1995 Red Hat, Inc
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. # rpm - we can rebuild it
  19. #       we have the technology
  20. #       better, stronger, faster
  21.  
  22. # Copyright (C) 1995 - Red Hat Software
  23.  
  24. unshift(@INC, "/usr/lib/rhs/rpm");
  25.  
  26. require "rpmgetopts.pl";
  27. require "message.pl";
  28. require "misc.pl";
  29. require "opts.pl";
  30.  
  31. $DO_PREP       = 1;
  32. $DO_BUILD      = 2;
  33. $DO_INSTALL    = 4;
  34. $DO_SOURCE     = 8;
  35. $DO_BINARY     = 16;
  36. $DO_TEST       = 32;
  37. $DO_LIST_CHECK = 64;
  38. $DO_CLEAN      = 128;
  39.  
  40. $ENV{'PATH'} = $rpm{'PATH'};
  41. $ENV{'PWD'} = `pwd`;
  42. chop $ENV{'PWD'};
  43.  
  44. sub sigint_handler {
  45.     &error("SIGINT received - aborted");
  46. }
  47. $SIG{"INT"} = 'sigint_handler';
  48.  
  49. &setmessagelevel(1);
  50. @args = ();
  51. $mode = 0;
  52.  
  53. $rpm{"options"} = join(' ', @ARGV);
  54. @rest = &rpm_getopts("ab:cdfhiUlpqsSuyVwFPv", @ARGV);
  55.  
  56. $bigmode = "none";
  57. $lopt_y && ($bigmode = "verify");
  58. $lopt_V && ($bigmode = "verify");
  59. $lopt_q && ($bigmode = "query");
  60. $lopt_U && ($bigmode = "install") && ($rpm{"upgrade"} = 1);
  61. $lopt_i && ($bigmode ne "query") && ($bigmode = "install");
  62. $lopt_i && ($bigmode eq "query") && ($querymode{"info"} = 1);
  63. $lopt_u && ($bigmode = "uninstall");
  64. $lopt_a && ($querywhat = "all");
  65. $lopt_f && ($querywhat = "whence");
  66. $lopt_F && ($querywhat = "Whence");
  67. $lopt_p && ($querywhat = "package");
  68. $lopt_P && ($querywhat = "Package");
  69. $lopt_c && ($rpm{"clean"} = 1, $querymode{"list"} = 1, $querymode{config} = 1);
  70. $lopt_l && ($querymode{"list"} = 1);
  71. $lopt_S && ($rpm{'search'} = 1);
  72. $lopt_w && ($bigmode = "install") && ($rpm{'where'} = 1);
  73. $lopt_d && ($querymode{"list"} = 1, $querymode{"doc"} = 1);
  74. $lopt_s && ($querymode{"state"} = 1, $querymode{"list"} = 1);
  75. $lopt_h && ($rpm{"marker"} = "hash");
  76.  
  77. if ($lopt_v == 1) {
  78.     &setmessageverbose();
  79. } elsif ($lopt_v >= 2) {
  80.     &setmessagedebug();
  81. }
  82.  
  83. # Now we can process the long arguments
  84. foreach $_ (@rest) {
  85.     ($rpm{"root"} == 1) && ($rpm{"root"} = $_, $rpm{"rootspec"} = $_, next);
  86.     ($rpm{"timecheck"} == -1) && ($rpm{"timecheck"} = $_, next);
  87.     /^--upgrade$/ && ($bigmode = "install") && ($rpm{"upgrade"} = 1, next);
  88.     /^--where$/ && ($bigmode = "install") && ($rpm{"where"} = 1, next);
  89.     /^--rebuild$/ && ($bigmode = "build") && ($rpm{"rebuild"} = 1, next);
  90.     /^--root$/ && ($rpm{"root"} = 1, next);
  91.     /^--short-circuit$/ && ($rpm{"short_circuit"} = 1, next);
  92.     /^--clean$/ && ($rpm{"clean"} = 1, next);
  93.     /^--time-check$/ && ($rpm{"timecheck"} = -1, next);
  94.     /^--test$/ && ($rpm{"test"} = 1, $rpm{"keeptemps"} = 1, next);
  95.     /^--quiet$/ && (&setmessagequiet(), next);
  96.     /^--percent$/ && ($rpm{"marker"} = "percent", next);
  97.     /^--hash$/ && ($rpm{"marker"} = "hash", next);
  98.     /^--force$/ && ($rpm{"force"} = 1, next);
  99.     /^--query$/ && ($bigmode = "query", next);
  100.     /^--verify$/ && ($bigmode = "verify", next);
  101.     /^--keep-temp/ && ($rpm{"keeptemps"} = 1, next);
  102.     /^--verbose$/ && (&setmessageverbose(), next);
  103.     /^--install$/ && ($bigmode ne "query") && ($bigmode = "install") && next;
  104.     /^--uninstall$/ && ($bigmode = "uninstall") && next;
  105.     /^--search$/ && ($rpm{'search'} = 1, next);
  106.     /^--debug$/ && (&setmessagedebug(), next);
  107.     /^--version$/ && ($bigmode = "version", next);
  108.     /^--help$/ && ($bigmode = "help", next);
  109.     /^-/ && (&error("Unrecognized option: $_"));
  110.     push(@args, $_);
  111. }
  112. ($rpm{"root"} == 1) && &error("--root requires argument");
  113.  
  114. if ($rpm{"rebuild"}) {
  115.     require "install.pl";
  116.     $mode = $DO_PREP | $DO_BUILD | $DO_INSTALL | $DO_BINARY | $DO_CLEAN;
  117.     $rpm{"clean"} = 1;
  118.     if ($rpm{"messagelevel"} == 1) {
  119.     # verbose by default
  120.     &setmessageverbose();
  121.     }
  122. }
  123.  
  124. if ($lopt_b) {
  125.     if ($rpm{"messagelevel"} == 1) {
  126.     # verbose by default
  127.     &setmessageverbose();
  128.     }
  129.     $_ = $lopt_b;
  130.     $bigmode = "build";
  131.     /^p$/ && ($mode = $DO_PREP);
  132.     /^l$/ && ($mode = $DO_LIST_CHECK);
  133.     /^b$/ && ($mode = $DO_PREP | $DO_BUILD | $DO_INSTALL | $DO_BINARY | $DO_CLEAN);
  134.     /^a$/ && ($mode = $DO_PREP | $DO_BUILD | $DO_INSTALL | $DO_BINARY | $DO_SOURCE | $DO_CLEAN);
  135.     if ($rpm{"short_circuit"}) {
  136.     /^c$/ && ($mode = $DO_BUILD);
  137.     /^i$/ && ($mode = $DO_INSTALL);
  138.     } else {
  139.     /^c$/ && ($mode = $DO_PREP | $DO_BUILD);
  140.     /^i$/ && ($mode = $DO_PREP | $DO_BUILD | $DO_INSTALL);
  141.     }
  142. }
  143.  
  144. ## All options are processed!
  145.  
  146. if ($bigmode ne "build") {
  147.     $rpm{"require_vendor"} = 0;
  148.     $rpm{"require_distribution"} = 0;
  149.     $rpm{"require_group"} = 0;
  150.     $rpm{"require_icon"} = 0;
  151. }
  152.  
  153. if ($bigmode eq "build") {
  154.     $h = `hostname`;
  155.     if ($h =~ /redhat\.com/) {
  156.     if (! ($rpm{"require_vendor"} &&
  157.            $rpm{"require_distribution"} &&
  158.            $rpm{"require_group"})) {
  159.         error("Bad /etc/rpmrc for redhat.com");
  160.     }
  161.     }
  162.     require "build.pl";
  163.     &do_build($mode, *args);
  164. } elsif ($bigmode eq "uninstall") {
  165.     require "uninstall.pl";
  166.     &uninstallpackages($rpm{"force"}, $rpm{"test"}, $rpm{"nosub"}, @args);
  167. } elsif ($bigmode eq "verify") {
  168.     require "verify.pl";
  169.     &doverify($querywhat, @args);
  170. } elsif ($bigmode eq "install") {
  171.     require "install.pl";
  172.     &installpackages($rpm{"force"}, $rpm{"test"}, $rpm{"marker"}, 
  173.             $rpm{"upgrade"}, @args);
  174. } elsif ($bigmode eq "query") {
  175.     require "query.pl";
  176.     &doquery($querywhat, *querymode, @args);
  177. } elsif ($bigmode eq "version") {
  178.     print "rpm version $rpm{'version'}\n";
  179. } else {
  180.     require "help.pl";
  181.     if ($bigmode eq "help") {
  182.     &help();
  183.     } else {
  184.     &usage();
  185.     }
  186. }
  187.  
  188. if (! $rpm{"keeptemps"}) {
  189.     &remove_temps;
  190. }
  191. exit (0);
  192.