1#!/bin/sh
2
3# unpacker -- unpacks RPMs into the BUILD directory.
4# This is part of SLOCCount, a toolsuite that counts
5# source lines of code (SLOC).
6# Copyright (C) 2001-2004 David A. Wheeler.
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21#
22# To contact David A. Wheeler, see his website at:
23#  http://www.dwheeler.com.
24#
25#
26
27SPECS=/usr/src/redhat/SPECS
28BUILD=/usr/src/redhat/BUILD
29
30BUILD_LIST=/root/build_list
31OLD_BUILD_LIST=${BUILD_LIST}.old
32
33echo "lost+found" > $OLD_BUILD_LIST
34
35cd $SPECS
36for specfile in *.spec
37do
38 cd $SPECS
39 # The "yes" is to give "yes" to "do you want to run this patch" requests -
40 # in particular this is needed to unpack samba.2.0.7 in Red Hat 7.1.
41 if yes | rpm -bp $specfile
42 then
43  # Things were fine, do nothing.
44  echo "UNPACKER: Successfully performed rpm -bp $specfile"
45 else
46  echo "UNPACKER WARNING - ERROR in rpm -bp $specfile"
47 fi
48
49 # Find the new BUILD entries, and create cross-references to the old.
50 cd $BUILD
51 ls | sort > $BUILD_LIST
52 CHANGES=`comm -13 $OLD_BUILD_LIST $BUILD_LIST`
53 anychange="0"
54 for newbuild in $CHANGES
55 do
56  anychange=1
57  echo $specfile > ${newbuild}/ORIGINAL_SPEC_FILE
58  echo "UNPACKER: added build $newbuild from $specfile"
59  extract_license "$newbuild" "${SPECS}/$specfile" > ${newbuild}/PROGRAM_LICENSE
60  # For disk space, erase all HTML files.
61  # If disk space is available, REMOVE THIS LINE:
62  # find "$newbuild" -type f -name "*.html" -exec rm {} \;
63 done
64 if [ $anychange == 0 ]
65 then
66  echo "UNPACKER: did not add a build directory for spec file $specfile"
67 fi
68 mv $BUILD_LIST $OLD_BUILD_LIST
69
70done
71
72