-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmkuls
executable file
·51 lines (45 loc) · 895 Bytes
/
mkuls
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
#!/bin/sh
readonly DIR="uls"
readonly GROUPING="10000"
if [ $# -lt 2 -o $# -gt 3 ]
then
echo "USAGE: $0 <file> <numcopies> [subdir]"
exit 1
fi
file="$1"
numcopies="$2"
shift 2
dir="$DIR"
if [ $# -ne 0 ]
then
dir="$1"
shift
fi
if [ -e "$dir" ]
then
echo "OOPS: Directory '$dir' already exists!" >&2
exit 2
elif ! make "$file"
then
echo "OOPS: Failed to build recipe '$file'!" >&2
exit 3
fi
strip -g "$file"
suffix="`printf %s "$file" | sed -n 's/.*\(\..\+\)/\1/p'`"
libs="`ldd "$file" | sed -n "s:.*$PWD/./\([^ ]\+\).*:../../\1:p"`"
mkdir "$dir"
last="$((GROUPING - 1))"
for subdir in `seq 0 $((numcopies / GROUPING)) | sed '$i\last'`
do
if [ "$subdir" = "last" ]
then
last="$((numcopies % GROUPING - 1))"
continue
fi
mkdir "$dir/$subdir"
for nondir in `seq 0 "$last"`
do
cp "$file" "$dir/$subdir/$nondir$suffix"
done
[ -n "$libs" ] && ln -s $libs "$dir/$subdir"
done