forked from lunar-linux/lunar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsizes.lunar
55 lines (50 loc) · 2.05 KB
/
sizes.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
#!/bin/bash
# #
# This code is written for Lunar Linux, see #
# http://lunar-linux.org #
# #
############################################################
# #
# $FUNCTIONS/sizes #
# includes find_module_size #
# #
# 20020527 #
# #
############################################################
# #
# Copyrighted Kagan Kongar 2002 under GPLv2 #
# #
############################################################
# function: find_module_size
# usage : find_module_size <module> |version|
# purpose : finds the installed size of module in KB
find_module_size() {
local VERSION LINE SIZE0 SIZE
#this functions checks the modules file if there is already size entry
module_size()
{
local SIZE
unset SIZE
[ -e "$MODULE_STATUS" ] &&
SIZE=$(sed -n "s/^$1:.*://p" "$MODULE_STATUS")
[ -n "$SIZE" ] && echo ${SIZE} || false
}
[ -z "$1" ] && return
[ -n "$2" ] && VERSION=$2 || VERSION=`installed_version $1`
[ -z "$VERSION" ] &&
message "${PROBLEM_COLOR}$1 is not installed${DEFAULT_COLOR}" &&
return
# yes, there is a size entry
module_size $1 $VERSION && return
# no :( lets dig through logs
[ -e "$INSTALL_LOGS/$1-$VERSION" ] &&
while read LINE
do
[ -f "$LINE" ] &&
SIZE0=`du "$LINE" |
cut -f 1-1` &&
SIZE=$((SIZE0+SIZE))
done <$INSTALL_LOGS/$1-$VERSION &&
echo ${SIZE}KB ||
message "${PROBLEM_COLOR}Install log for $1 is not found${DEFAULT_COLOR}"
}