-
Notifications
You must be signed in to change notification settings - Fork 6
/
clean_license.sh
executable file
·86 lines (74 loc) · 2 KB
/
clean_license.sh
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
#! /bin/bash
keyword_list="
license_create
license_destroy
screensaver_create
screensaver_destroy
splash_draw_framework
splash_progress
splash_delay
license_on_input
license_on_timeout
license_get_processor_id
#\s*include.*license\/c_files.*
#\s*include.*license\.h
LICENSE_MODIFY_MESSAGE
LICENSE_SET_MESSAGE_OFFSET
LICENSE_CHECK_CUSTIMER_ID
g_license_processor_id
"
license_files="
src/include/license.h
src/misc/license.c
"
function main ()
{
tarball_name="$1"
# get target packet
while [ "$tarball_name" = "" -o ! -f "$tarball_name" ]; do
echo "Not found the file or make a wrong name: $tarball_name."
echo -n "Please input tarball name, or 'q' to exit: "
read tarball_name
if [ "x$tarball_name" = "xq" ];then exit 1; fi
done
#get folder name
tmp_dir=${tarball_name%.*.*}
#decompress packet for clean
echo "Decompresing..."
/bin/tar xf $tarball_name
#empty license file
for file_name in $license_files;do
> $tmp_dir/$file_name
done
#remove resource files for license
rm -rf $tmp_dir/src/sysres/license
#enter
#file_list=`find $tmp_dir -name \*.c`
#find string and clean
echo "Cleaning files..."
#for file_name in $file_list; do
# for keyword in $keyword_list; do
# #sed "s/^\s*$keyword.*\s*//g" -i $file_name
# sed "/$keyword/d" -i $file_name
# done
#done
for keyword in $keyword_list; do
file_list=`find $tmp_dir -name \*.c|xargs grep -l $keyword`
for file_name in $file_list; do
if [[ $keyword == \#* ]]
then
sed "/$keyword/d" -i $file_name
else
sed "/$keyword/d" -i $file_name
#TODO:when the function \n
#sed "/^\s*$keyword.*\s*/,/.*\;/d" -i $file_name
fi
done
done
#make new packet
/bin/rm -rf "$tarball_name"
echo "Making new tarball..."
/bin/tar zcf $tarball_name $tmp_dir
/bin/rm -rf "$tmp_dir"
}
main $*