-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathruby-update
More file actions
executable file
·65 lines (60 loc) · 1.33 KB
/
Copy pathruby-update
File metadata and controls
executable file
·65 lines (60 loc) · 1.33 KB
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
#!/bin/bash
usage() {
echo "usage: $0 ruby-to-install [dest-dir(/opt/local)]" 1>&2
exit 1
}
install=true
dryrun=
unset src
until [ $# = 0 ]; do
case "$1" in
-u)
install=
;;
-n)
dryrun=-n
;;
-*)
echo "$0: unknown option $1" 1>&2
exit 1
;;
*)
if [ ! ${src+set} ]; then
src="$1"
elif [ !${dest+set} ]; then
dest="$1"
else
usage
fi
;;
esac
shift
done
: ${dest=/opt/local}
if [ "$install" -a ! -f "$src/.installed.list" ]; then
echo "$0: $src/.installed.list not found" 1>&2
exit 1
fi
if [ -f "$dest/bin/ruby" -a -e "$dest/bin/ruby" ]; then
archdir="$($dest/bin/ruby --disable=gems -rrbconfig -e 'puts RbConfig::CONFIG["rubyarchdir"]')"
list="$archdir/.installed.list"
if [ ! ${dryrun:+set} ]; then
tmp=$(mktemp)
trap 'rm -f "$tmp"' 0 2
mv "$list" "$tmp" || exit $?
list="$tmp"
fi
$dest/bin/ruby --disable=gems ${0%/*}/rbuninstall.rb $dryrun --destdir="$dest" "$list"
if [ ! ${dryrun:+set} ]; then
rm -f "$tmp"
fi
trap - 0 2
fi
if [ ${dryrun:+set} ]; then
echo "Installing $src to $dest"
elif [ $install ]; then
cp -a --no-preserve=ownership "$src"/* "$dest" &&
archdir="$($dest/bin/ruby --disable=gems -rrbconfig -e 'puts RbConfig::CONFIG["rubyarchdir"]')" &&
cp "$src/.installed.list" "$archdir/"
exit $?
fi