forked from lunar-linux/lunar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracking.lunar
143 lines (112 loc) · 4.92 KB
/
tracking.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
#!/bin/bash
# #
# subroutines - Lunar subroutines #
# #
############################################################
# #
# this WAS the subroutines of a source based Linux distro, #
# calls Sorcerer GNU/Linux, or SGL. SGL is no longer #
# available with GPL license. Since this script was taken #
# before licensing scheme change, no legal problems I #
# guess. #
# #
# the code is re-written for Lunar. The previous Copyright #
# notices are kept; just in case some code is left :=) #
# Kagan Kongar <kongar@tsrsb.org.tr>, 20020519 #
# #
############################################################
# #
# Copyright 2001 by Kyle Sallee #
# #
# Parts Copyrighted Hendrik Visage 2002 under GPLv2 #
# #
# Parts Copyrighted Kagan Kongar 2002 under GPLv2 #
# #
############################################################
# function : invoke_installwatch
# usage : invoke_installwatch
# purpose : start logging all disk accesses with installwatch
invoke_installwatch() {
debug_msg "invoke_installwatch ($@)"
if [ -e /usr/lib/installwatch.so ] ; then
export LD_PRELOAD=/usr/lib/installwatch.so
fi
}
# function : devoke_installwatch
# usage : devoke_installwatch
# purpose : stop logging all disk accesses with installwatch
devoke_installwatch() {
debug_msg "devoke_installwatch ($@)"
unset LD_PRELOAD
}
# function : parse_iw
# usage : parse_iw
# purpose : remove unwanted accesses from the installwatch file
parse_iw() {
local OMIT_IN
debug_msg "parse_iw ($@)"
OMIT_IN=" rename\| symlink\| unlink\| fchmod\| access"
grep -v "$OMIT_IN" "$INSTALLWATCHFILE" | cut -f3 | grep -v "^$SOURCE_DIRECTORY" | grep -v -f "$EXCLUDED"
cat "$INSTALLWATCHFILE" | cut -f4 | grep -v "^$SOURCE_DIRECTORY" | grep -v -f "$EXCLUDED" | grep "^/"
}
# function : create_install_log
# usage : create_install_log
# purpose : create an install log
create_install_log() {
local TMP_INST_LOG INST_LOG IFS MISOWNED_SYMLINKS
debug_msg "create_install_log ($@)"
TMP_INST_LOG=$(temp_create "install-log")
INST_LOG="$INSTALL_LOGS/$MODULE-$VERSION"
rm -f $INST_LOG &> /dev/null
message "${MESSAGE_COLOR}Creating ${FILE_COLOR}${INST_LOG}${DEFAULT_COLOR}"
export IFS="$TAB_ENTER_IFS"
parse_iw | sort | uniq | filter "$LOCAL_EXCLUDED" | custom_filters | exists > $TMP_INST_LOG
echo "$INSTALL_LOGS/$MODULE-$VERSION" >> $TMP_INST_LOG
echo "$COMPILE_LOGS/$MODULE-$VERSION.${COMPRESS_METHOD}" >> $TMP_INST_LOG
echo "$MD5SUM_LOGS/$MODULE-$VERSION" >> $TMP_INST_LOG
install -m644 $TMP_INST_LOG $INST_LOG
temp_destroy $TMP_INST_LOG
}
create_md5sum_log() {
local FILE
debug_msg "create_md5sum_log ($@)"
rm -f $MD5SUM_LOGS/$MODULE-$VERSION &> /dev/null
message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$MD5SUM_LOGS/$MODULE-$VERSION${DEFAULT_COLOR}"
IFS=$'\n' files < $INSTALL_LOGS/$MODULE-$VERSION | xargs -d '\n' md5sum >> $MD5SUM_LOGS/$MODULE-$VERSION
}
create_install_cache() {
debug_msg "create_install_cache($@)"
if [ "$ARCHIVE" == "off" ] ; then
return
fi
message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar.${COMPRESS_METHOD}${DEFAULT_COLOR}"
tar cP --no-recursion -T $INSTALL_LOGS/$MODULE-$VERSION | ${COMPRESS_METHOD/bz2/bzip2} $COMPRESS_METHOD_ARGS > "$INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar.${COMPRESS_METHOD}"
}
save_old_install_log() {
local old_version
debug_msg "save_old_install_log ($@)"
export TMP_OLD_INST_LOG=$(temp_create "${MODULE}.oldinstlog")
if module_installed $MODULE; then
old_version=$(installed_version $MODULE)
debug_msg "creating old install log for $MODULE-$old_version ($TMP_OLD_INST_LOG)"
cp "$INSTALL_LOGS/$MODULE-$old_version" $TMP_OLD_INST_LOG
fi
}
delete_old_install_log() {
debug_msg "delete_old_install_log ($@)"
if [ -f $TMP_OLD_INST_LOG ]; then
temp_destroy $TMP_OLD_INST_LOG
fi
}
finish_install() {
debug_msg "finish_install ($@)"
create_install_log &&
create_md5sum_log &&
create_install_cache &&
# TODO: clean up DESTDIR_BUILD feature toggle
if [[ "${DESTDIR_BUILD:-off}" == "on" ]]; then
cleanup_old_module_files "$TMP_OLD_INST_LOG" "$INSTALL_LOGS/$MODULE-$VERSION"
fi &&
add_module $MODULE installed $VERSION $(find_module_size $MODULE $VERSION)
verbose_msg "module size is $(find_module_size $MODULE $VERSION)"
}