unixstrip.pl 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #
  2. # BEGIN COPYRIGHT BLOCK
  3. # This Program is free software; you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation; version 2 of the License.
  6. #
  7. # This Program is distributed in the hope that it will be useful, but WITHOUT
  8. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  10. #
  11. # You should have received a copy of the GNU General Public License along with
  12. # this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  13. # Place, Suite 330, Boston, MA 02111-1307 USA.
  14. #
  15. # In addition, as a special exception, Red Hat, Inc. gives You the additional
  16. # right to link the code of this Program with code not covered under the GNU
  17. # General Public License ("Non-GPL Code") and to distribute linked combinations
  18. # including the two, subject to the limitations in this paragraph. Non-GPL Code
  19. # permitted under this exception must only link to the code of this Program
  20. # through those well defined interfaces identified in the file named EXCEPTION
  21. # found in the source code files (the "Approved Interfaces"). The files of
  22. # Non-GPL Code may instantiate templates or use macros or inline functions from
  23. # the Approved Interfaces without causing the resulting work to be covered by
  24. # the GNU General Public License. Only Red Hat, Inc. may make changes or
  25. # additions to the list of Approved Interfaces. You must obey the GNU General
  26. # Public License in all respects for all of the Program code and other code used
  27. # in conjunction with the Program except the Non-GPL Code covered by this
  28. # exception. If you modify this file, you may extend this exception to your
  29. # version of the file, but you are not obligated to do so. If you do not wish to
  30. # provide this exception without modification, you must delete this exception
  31. # statement from your version and license this file solely under the GPL without
  32. # exception.
  33. #
  34. #
  35. # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  36. # Copyright (C) 2005 Red Hat, Inc.
  37. # All rights reserved.
  38. # END COPYRIGHT BLOCK
  39. #
  40. use File::Find;
  41. #
  42. # usage: unixstrip.pl [ directory ... ] [ shlibsign ]
  43. #
  44. # if no arguments are passed, strip files under the current directory.
  45. #
  46. # if 1 argument is passed, strip files under the given directory.
  47. #
  48. # if 2 or more arguments are passed,
  49. # the last argument is considered the path to nss utility shlibsign (NSS3.9~),
  50. # the preceding args are directories, under which files are to be stripped.
  51. # And nss libraries libsoftokn3, libfreebl_pure32_3, libfreebl_hybrid_3
  52. # are to be checksum'ed with shlibsign.
  53. my $SHLIBSIGN = "";
  54. if (@ARGV > 1) {
  55. $SHLIBSIGN = $ARGV[$#ARGV];
  56. print STDERR "set $SHLIBSIGN \n";
  57. for (my $i = 0; $i < $#ARGV; $i++)
  58. {
  59. print STDERR "args[$i]: $ARGV[$i]\n";
  60. find(\&find_cb, $ARGV[$i]);
  61. }
  62. } elsif (@ARGV == 1) {
  63. find(\&find_cb, @ARGV);
  64. } else {
  65. find(\&find_cb, '.');
  66. }
  67. sub find_cb {
  68. return if (! -f $_); # only look at plain files
  69. return if (! -B $_); # skip text files
  70. return if (/\.jpg$/); # skip jpg files
  71. return if (/\.gif$/); # skip gif files
  72. return if (/\.jar$/); # skip jar files
  73. return if (/\.zip$/); # skip zip files
  74. return if (/\.gz$/); # skip gzip files
  75. return if (/\.chk$/); # skip chk files
  76. print STDERR "about to strip $_ .\n";
  77. system("strip $_");
  78. print STDERR "strip $_ done.\n";
  79. if ($SHLIBSIGN ne "" && /libsoftokn3|libfreebl_pure32_3|libfreebl_hybrid_3/)
  80. {
  81. print STDERR "$SHLIBSIGN $_\n";
  82. system("$SHLIBSIGN -v -i $_");
  83. }
  84. }
  85. exit 0;