-
Notifications
You must be signed in to change notification settings - Fork 0
/
myinstall.SH
87 lines (82 loc) · 1.67 KB
/
myinstall.SH
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
case $CONFIG in
'') . ./config.sh ;;
esac
echo "Extracting myinstall (with variable substitutions)"
$spitshell >myinstall <<!GROK!THIS!
$startsh
# myinstall.SH
#
# This software is copyrighted as detailed in the LICENSE file.
#
export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
objdir=`pwd`
!GROK!THIS!
$cat >>myinstall <<'!NO!SUBS!'
case "$1" in
-*) args=$1
shift
case "$args" in
*f*) tofile=$1 ; shift ;;
esac
esac
case "$#" in
0|1) echo "Usage: myinstall [-opts] dir file [file...]"
exit 1
esac
dir=$1
shift
for file in $* ; do
case "$args" in
*f*) ;;
*) tofile=`echo $file | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
esac
if test -f $dir/$tofile ; then
case "$args" in
*d*)
if cmp -s $file $dir/$tofile ; then
continue
fi
;;
esac
case "$args" in
*o*) rm -f $dir/$tofile.old
mv $dir/$tofile $dir/$tofile.old;;
*n*) cat <<EOM
** You should diff $tofile & $tofile.new in $dir **
EOM
tofile="$tofile.new";;
esac
elif test -d $dir/$tofile ; then
case "$args" in
*o*) rm -rf $dir/$tofile.old
mv $dir/$tofile $dir/$tofile.old;;
esac
fi
case "$args" in
*R*)
fromname=`basename $file`
fromdir=`expr $file : '\(.*\)/[^/]*'`
if test "X$fromname" = X -o "X$fromdir" = X; then
exit 1
fi
cd $dir
(cd $fromdir ; tar cf - $fromname) | tar xpf -
cd $objdir
;;
*)
cp $file $dir/$tofile
;;
esac
case "$args" in
*s*) strip $dir/$tofile
esac
case "$args" in
*x*) chmod +x $dir/$tofile
esac
case "$args" in
*r*) chmod +r $dir/$tofile
esac
done
!NO!SUBS!
$eunicefix myinstall
chmod 755 myinstall