-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAttachProgram
executable file
·87 lines (70 loc) · 2.79 KB
/
AttachProgram
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
#!/bin/bash
source ScriptFunctions
Import File
Import GoboLinux
Import Log
Import OptionParser
Import Versions
### Options ###################################################################
scriptDescription="Create a link in ${goboPrograms} to \$goboInstall or <src_tree>."
scriptCredits="Copyright (C) 2004 Carlo Calica. Released under the GNU GPL."
helpOnNoArguments=yes
scriptUsage="<program> [<version>] [<src_tree>]"
scriptExample="GCC 2.95.3 /Network/Programs"
scriptNotes="This script creates a program entry in ${goboPrograms} with a version "\
"symlink to <src_tree> directory. After it is tied into ${goboPrograms}, "\
"SymlinkProgram is executed. "\
"If <destdir> is omitted the env var goboInstall is used."
Add_Option_Boolean "b" "batch" "Batch mode."
Add_Option_Boolean "f" "force" "Force, reattach even if installed."
Add_Option_Boolean "r" "rootfs" "Move to RootFS."
Add_Option_Boolean "D" "no-dependencies" "Do not try to fullfit dependencies."
Parse_Options "$@"
### Operation #################################################################
Is_Writable "${goboPrograms}" || Die "Needs write access to ${goboPrograms}"
if Is_Directory "$(Arg 3)"
then
goboInstall="$(Arg 3)"
elif Is_Directory "$(Arg 2)"
then
goboInstall="$(Arg 2)"
no_version="true"
fi
export goboInstall=`readlink -f $goboInstall`
if [ "$goboPrograms" = "$goboInstall" ]
then
Die "Please specify a directory as an argument or goboInstall env variable."
fi
programname=`(export goboPrograms=$goboInstall; GuessProgramCase $(Arg 1) $(Arg 2))`
if [ "$no_version" != "true" ] && [ "$(Arg 2)" ]
then
if Is_Directory "${goboInstall}/${programname}/$(Arg 2)"
then
versionnumber="$(Arg 2)"
fi
else
versionnumber=$(GuessLatest $(All_Versions ${goboInstall}/${programname}))
fi
prefix="${goboInstall}/$programname/$versionnumber"
Is_Directory "$prefix" || Die "$programname version $versionnumber was not found."
error_msg="$programname $versionnumber already attached."
if Boolean "force"
then
Boolean "batch" && error_msg=""
Is_Directory "${goboPrograms}/$programname/$versionnumber" && Pass_Away $error_msg
fi
Log_Normal "Attaching ${programname}, version ${versionnumber} from ${goboInstall}."
#What to do.....
# This is a little more complex than a simple mv. Not sure if it needs to be
# but as it will normally be across filesystems it isn't that inefficient.
Make_Directory "${goboPrograms}/$programname"
ln -nsf "${goboInstall}/$programname/$versionnumber" "${goboPrograms}/$programname/$versionnumber"
[ "$?" = "0" ] || Log_Error "Can´t create symlink"
symopts=""
Boolean "rootfs" && symopts="--rootfs"
SymlinkProgram $symopts "$programname" "$versionnumber"
if ! Boolean "no-dependencies"
then
Log_Normal "Checking Dependencies..."
CheckDependencies --mode=missing "$programname" "$versionnumber"
fi