/usr/bin/make_filelists is in sloccount 2.26-5.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | #!/bin/sh
# On the command line, list the source code directories, e.g.:
# /usr/src/redhat/BUILD/*
# This command creates a set of directories paralleling the source code
# directories, with a file named "filelist" listing all the files.
# This script goes through some trouble to turn all relative references
# into absolute pathnames, to make sure that the intended files
# are always referenced. Conceivably the current directory isn't the
# data directory and the parameters given use relative addressing,
# and we need to fix all that here.
# This is part of SLOCCount, a toolsuite that counts
# source lines of code (SLOC).
# Copyright (C) 2001-2004 David A. Wheeler.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# To contact David A. Wheeler, see his website at:
# http://www.dwheeler.com.
#
#
if [ "$#" -eq 0 ]
then
echo "Error: You must provide a list of directories."
exit 1
fi
follow=""
skip=""
prefix=""
startingdir=`pwd`
datadir=`pwd`
while [ "$#" -gt 0 ]
do
case "$1"
in
--follow) follow="-follow"
shift;;
--datadir) shift
if [ ! -d "$1" ]
then
echo "Error: $1 is not a directory"
exit 1
fi
cd "$1"
datadir=`pwd`
cd "$startingdir"
shift;;
--skip) shift
skip="$1"
shift;;
--prefix) shift
prefix="$1"
shift;;
--) shift; break;;
--*) echo "Error: unrecognized option $1"
exit 1
shift ;;
*) break;;
esac
done
# Non-directories will be placed into the "top_dir" data directory:
toplevel_name="${prefix}top_dir"
for possible_dir
do
# Reset to starting directory each time, so that relative directory
# requests will be processed correctly.
cd "$startingdir"
# Translate "." into the name of current directory.
# We have to handle "." and ".." specially, because we can't place
# files with these names into the data directory.
if [ "$possible_dir" = "." ]
then
possible_dir=`pwd`
fi
if [ "$possible_dir" = ".." ]
then
cd ..
possible_dir=`pwd`
# Reset current directory.
cd "$startingdir"
fi
base=`basename "$possible_dir"`
if [ "$base" = "$skip" ]
then
continue
fi
if [ -d "$possible_dir" ]
then
# Set "dir" to real name (if possible_dir is a symlink to another
# directory, then "dir" and "possible_dir" may have very different values)
# depending on how "cd" is implemented on your shell.
cd "$possible_dir"
dir=`pwd`
# The child directory's name is derived from possible_dir, not dir --
# that way, directories we create will have names based on the supplied
# name (potentially a link), not the linked-to directory's name.
# Thus, symlinks can be used to disambiguate names where necessary.
childname="${prefix}${base}"
cd "$datadir"
if [ -d "$childname" ]
then
echo "WARNING! Directory $childname pre-existed when adding $possible_dir"
else
mkdir "$childname"
fi
echo "Creating filelist for $childname"
find "$dir" $follow -type f -print > "${childname}/filelist"
# If it exists, copy the PROGRAM_LICENSE.
if [ -s "${dir}/PROGRAM_LICENSE" ]
then
cp "${dir}/PROGRAM_LICENSE" "${childname}/PROGRAM_LICENSE"
fi
# If it exists, copy the ORIGINAL_SPEC_FILE
if [ -s "${dir}/ORIGINAL_SPEC_FILE" ]
then
cp "${dir}/ORIGINAL_SPEC_FILE" "${childname}/ORIGINAL_SPEC_FILE"
fi
# Do some error-checking.
if [ ! -s "${childname}/filelist" ]
then
# This is inefficient, but it doesn't matter - it's only used
# when we have an empty filelist (which is often an error condition)
saw_a_file=n
for x in ls "$dir"
do
saw_a_file=y
break
done
case $saw_a_file
in
n)
echo "Warning: directory ${childname} got no files."
echo "You may need to use the --follow option.";;
esac
fi
elif [ -f "$possible_dir" ]
then
# We have a non-directory (regular file, symlink to a file, etc.).
# We'll just add an absolute path to it into the toplevel_name directory.
# First, convert possible_dir into an absolute pathname if necessary:
pathname="$possible_dir"
case "$pathname"
in
/*) ;; # Already absolute pathname - do nothing.
*) pathname="${startingdir}/${possible_dir}" ;;
esac
# Add it to the toplevel_name directory (creating the directory if needed)
cd "$datadir"
if [ ! -d "$toplevel_name" ]
then
echo "Have a non-directory at the top, so creating directory $toplevel_name"
mkdir "$toplevel_name"
fi
echo "Adding $pathname to $toplevel_name"
echo "$pathname" >> "${toplevel_name}/filelist"
else
echo "WARNING!!! Not a file nor a directory (so ignored): $possible_dir"
fi
done
exit 0
|