forked from lunar-linux/lunar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsources.lunar
218 lines (180 loc) · 5.47 KB
/
sources.lunar
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#/bin/bash
############################################################
# #
# This code is written for Lunar Linux, see #
# http://lunar-linux.org #
# #
############################################################
# #
# $FUNCTIONS/sources #
# includes sources, md5_verify_source, verify_sources #
# verify_source #
# #
# 20020604 #
# #
############################################################
# #
# Copyrighted Kagan Kongar 2002 under GPLv2 #
# #
############################################################
verify_source() {
local VERIFIED SOURCE_FILE
debug_msg "verify_source ($@)"
VERIFIED="true"
for SOURCE_FILE in $@ ; do
if [ ! -f $SOURCE_CACHE/$1 ] ; then
message "${PROBLEM_COLOR}Missing ${FILE_COLOR}${1}${DEFAULT_COLOR}"
message "${PROBLEM_COLOR}Lunar Install aborting.${DEFAULT_COLOR}"
activity_log "lin" "$MODULE" "$VERSION" "failed" "because it was missing source: $1"
return 1
fi
done
}
# function : sources
# usage : sources <module_name>
# purpose : displays the sources needed for a given module
sources() {
(
debug_msg "sources ($@)"
MAX_SOURCES=${MAX_SOURCES:-100}
if ! run_details $1 ; then
return 1
fi
for (( CNT=1; CNT<=$MAX_SOURCES; CNT++ )) ; do
TEMP=SOURCE$((CNT))
TEMP=${TEMP/%SOURCE1/SOURCE}
eval SRC=\$${TEMP}
[ -z "$SRC" ] && break
echo $SRC
done
)
}
erase() {
debug_msg "erase ($@)"
if [ "$PARTIAL" == "off" ]; then
debug_msg "erase: deleting \"$1\""
rm -f $1
fi
}
unpack() {
local FILENAME
debug_msg "unpack ($@)"
FILENAME=$SOURCE_CACHE/$1
verbose_msg "Unpacking \"$FILENAME\" in \"$(pwd)\""
plugin_call SOURCE_UNPACK $SOURCE_CACHE/$1
if [ "$?" != 0 ] ; then
message "${PROBLEM_COLOR}! Error while unpacking ${FILE_COLOR}$SOURCE_CACHE/$1${DEFAULT_COLOR}${PROBLEM_COLOR}${DEFAULT_COLOR}"
return 1
fi
}
# usage: verify_all_sources $MODULE
# check all sources regarding verification method
verify_all_sources() {
(
debug_msg "verify_all_sources ($@)"
MAX_SOURCES=${MAX_SOURCES:-100}
if ! run_details $1 ; then
return 1
fi
if [ -n "$WANT_VERSION" ] ; then
message "${PROBLEM_COLOR}WARNING:${DEFAULT_COLOR}${MESSAGE_COLOR} Integrity checking is disabled when using \"--want\"!${DEFAULT_COLOR}"
return 0
fi
for (( C=1 ; C<=$MAX_SOURCES ; C++ )) ; do
TEMP=SOURCE$((C))
TEMP=${TEMP/%SOURCE1/SOURCE}
eval SRC=\$${TEMP}
[ -z "$SRC" ] && break
# it needs to exist prior before we can check it:
if ! verify_source $SRC ; then
return 1
fi
eval VFYS=\${${TEMP}_VFY[@]}
# cumulate result:
unset RESULT
if [ -n "$VFYS" ] ; then
# we need to check ALL args for validity... if one fails we should not
# trust the source
for VFY in $VFYS ; do
plugin_call SOURCE_VERIFY $SRC $VFY
if [ $? == 1 ]; then
RESULT=1
fi
done
# so what if?
if [ "$RESULT" == "1" ] ; then
# remove?
MODULE=$1
message "${MESSAGE_COLOR}You should remove ${DEFAULT_COLOR}${FILE_COLOR}$SRC${DEFAULT_COLOR}${MESSAGE_COLOR} !${DEFAULT_COLOR}"
if query "Remove \"$SOURCE_CACHE/$SRC\" ? " y ; then
rm -f $SOURCE_CACHE/$SRC
fi
fi
fi
done
# result?
if [ -n "$RESULT" ] ; then
return 1
fi
# if we removed something we better make sure we break:
if ! verify_source $(sources $1) ; then
return 1
fi
)
}
rm_source_dir() {
local DEAD_DIR
debug_msg "rm_source_dir ($@)"
if [ "$KEEP_SOURCE" == "on" ] ; then
return 0
fi
cd $BUILD_DIRECTORY
DEAD_DIR=$1
DEAD_DIR=${DEAD_DIR:-$SOURCE_DIRECTORY}
verbose_msg "destroying building dir \"$DEAD_DIR\""
if grep -q $DEAD_DIR /proc/mounts
then
umount $DEAD_DIR
fi
rm -rf $DEAD_DIR 2> /dev/null
}
mk_source_dir() {
local NEW_DIR
debug_msg "mk_source_dir ($@)"
# yes this sounds weird but it might happen: no dir $BUILD_DIRECTORY on
# clean boxes!
if [ ! -e "$BUILD_DIRECTORY" ] ; then
mkdir -p "$BUILD_DIRECTORY"
fi
cd "$BUILD_DIRECTORY"
NEW_DIR=$1
NEW_DIR=${NEW_DIR:-$SOURCE_DIRECTORY}
verbose_msg "creating building dir \"$NEW_DIR\""
if [ -d $NEW_DIR ] ; then
verbose_msg "Removing old source directory first!"
rm_source_dir $NEW_DIR
fi
mkdir -p $NEW_DIR
if [ ${KEEP_SOURCE:-off} != on -a ${TMPFS_BUILD:-off} == on ]
then
if grep $NEW_DIR /proc/mounts > /dev/null
then
umount $NEW_DIR
fi
mount -t tmpfs tmpfs $NEW_DIR
fi
}
validate_source_dir() {
debug_msg "validate_source_dir ($@)"
verbose_msg "validating \"$SOURCE_DIRECTORY\""
if [[ -n $SOURCE_DIRECTORY &&
$SOURCE_DIRECTORY != $BUILD_DIRECTORY &&
$SOURCE_DIRECTORY =~ $BUILD_DIRECTORY ]]; then
true
else
message "\$SOURCE_DIRECTORY and \$BUILD_DIRECTORY must not be the same."
message "\$SOURCE_DIRECTORY must not be empty."
message "\$SOURCE_DIRECTORY must be a subdirectory of \$BUILD_DIRECTORY"
false
fi
}