blob: b445abbeed8e0c2508b00c0b3be0fd052f45c7a8 (
plain) (
blame)
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
|
#!/bin/sh
set -xeuo pipefail
clean () {
sed -n '/^# java_package_manager.begin$/,/^# java_package_manager.end$/{/^# java_package_manager.begin$/!{/^# java_package_manager.end$/!p}}' .gitignore | while read l
do
rd=`rev <<<$l | cut -d/ -f2- | rev`
rm $l
[ `ls $rd | wc -l` -eq 0 ] && rmdir $rd
done
sed -i '/^# java_package_manager.begin$/,/^# java_package_manager.end$/d' .gitignore
}
case $1 in
i*|I*)
[ -f java_package_manager.txt ] || { echo no java_package_manager.txt, refusing to run; exit 2; }
if grep '^# java_package_manager.begin$' .gitignore > /dev/null
then
echo was already installed. cleaning before reinstalling.
clean
fi
echo '# java_package_manager.begin' >> .gitignore
c=0
grep -v '^#' java_package_manager.txt | while read l
do
c=$(($c+1))
[ $c -eq 1 ] && { d=$l; continue; }
find $l -type f | while read line
do
dst=`sed s,$l,$d, <<<$line`
dstd=`rev <<<$dst | cut -d/ -f2- | rev`
[ -d $dstd ] || mkdir -p $dstd
cp --no-clobber $line $dst
echo $dst >> .gitignore
done
done
echo '# java_package_manager.end' >> .gitignore
;;
c*|C*)
clean
;;
*)
echo wrong option
exit 1
;;
esac
|