diff options
Diffstat (limited to 'skripti/java_package_manager.sh')
-rwxr-xr-x | skripti/java_package_manager.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/skripti/java_package_manager.sh b/skripti/java_package_manager.sh new file mode 100755 index 0000000..b445abb --- /dev/null +++ b/skripti/java_package_manager.sh @@ -0,0 +1,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 |