Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
3.5 KiB

  1. #!/usr/local/bin/perl -w
  2. use strict;
  3. use IO::File;
  4. use ExtUtils::Packlist;
  5. use ExtUtils::Installed;
  6. use vars qw($Inst @Modules);
  7. ################################################################################
  8. sub do_module($)
  9. {
  10. my ($module) = @_;
  11. my $help = <<EOF;
  12. Available commands are:
  13. f [all|prog|doc] - List installed files of a given type
  14. d [all|prog|doc] - List the directories used by a module
  15. v - Validate the .packlist - check for missing files
  16. t <tarfile> - Create a tar archive of the module
  17. q - Quit the module
  18. EOF
  19. print($help);
  20. while (1)
  21. {
  22. print("$module cmd? ");
  23. my $reply = <STDIN>; chomp($reply);
  24. CASE:
  25. {
  26. $reply =~ /^f\s*/ and do
  27. {
  28. my $class = (split(' ', $reply))[1];
  29. $class = 'all' if (! $class);
  30. my @files;
  31. if (eval { @files = $Inst->files($module, $class); })
  32. {
  33. print("$class files in $module are:\n ",
  34. join("\n ", @files), "\n");
  35. last CASE;
  36. }
  37. else
  38. { print($@); }
  39. };
  40. $reply =~ /^d\s*/ and do
  41. {
  42. my $class = (split(' ', $reply))[1];
  43. $class = 'all' if (! $class);
  44. my @dirs;
  45. if (eval { @dirs = $Inst->directories($module, $class); })
  46. {
  47. print("$class directories in $module are:\n ",
  48. join("\n ", @dirs), "\n");
  49. last CASE;
  50. }
  51. else
  52. { print($@); }
  53. };
  54. $reply =~ /^t\s*/ and do
  55. {
  56. my $file = (split(' ', $reply))[1];
  57. my $tmp = "/tmp/inst.$$";
  58. if (my $fh = IO::File->new($tmp, "w"))
  59. {
  60. $fh->print(join("\n", $Inst->files($module)));
  61. $fh->close();
  62. system("tar cvf $file -I $tmp");
  63. unlink($tmp);
  64. last CASE;
  65. }
  66. else { print("Can't open $file: $!\n"); }
  67. last CASE;
  68. };
  69. $reply eq 'v' and do
  70. {
  71. if (my @missing = $Inst->validate($module))
  72. {
  73. print("Files missing from $module are:\n ",
  74. join("\n ", @missing), "\n");
  75. }
  76. else
  77. {
  78. print("$module has no missing files\n");
  79. }
  80. last CASE;
  81. };
  82. $reply eq 'q' and do
  83. {
  84. return;
  85. };
  86. # Default
  87. print($help);
  88. }
  89. }
  90. }
  91. ################################################################################
  92. sub toplevel()
  93. {
  94. my $help = <<EOF;
  95. Available commands are:
  96. l - List all installed modules
  97. m <module> - Select a module
  98. q - Quit the program
  99. EOF
  100. print($help);
  101. while (1)
  102. {
  103. print("cmd? ");
  104. my $reply = <STDIN>; chomp($reply);
  105. CASE:
  106. {
  107. $reply eq 'l' and do
  108. {
  109. print("Installed modules are:\n ", join("\n ", @Modules), "\n");
  110. last CASE;
  111. };
  112. $reply =~ /^m\s+/ and do
  113. {
  114. do_module((split(' ', $reply))[1]);
  115. last CASE;
  116. };
  117. $reply eq 'q' and do
  118. {
  119. exit(0);
  120. };
  121. # Default
  122. print($help);
  123. }
  124. }
  125. }
  126. ################################################################################
  127. $Inst = ExtUtils::Installed->new();
  128. @Modules = $Inst->modules();
  129. toplevel();
  130. ################################################################################