summaryrefslogtreecommitdiff
path: root/scripts/mobile-license.post
blob: 13c505dd50dcc4f4bee480981545274ee4eb88c3 (plain)
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
#!/bin/sh
echo "############### mobile-license.post ################"

LICENSE_OLD_DIR=/usr/share/license
LICENSE_DIR=/usr/share/licenses
LICENSE_FILE=/usr/share/license.html
MD5_TEMP_FILE=/usr/share/temp_license_md5

if [[ -f $LICENSE_FILE ]]; then
        rm -f $LICENSE_FILE
fi

if [[ -f $MD5_TEMP_FILE ]]; then
        rm -f $MD5_TEMP_FILE
fi

cd $LICENSE_OLD_DIR
LICENSE_OLD_LIST=`ls $LICENSE_OLD_DIR`

for INPUT in $LICENSE_OLD_LIST; do
        if [[ -f $INPUT ]]; then
                md5sum $INPUT | echo `awk '{print $1 " " $2}'` $LICENSE_OLD_DIR/$INPUT >> $MD5_TEMP_FILE
        fi
done


cd $LICENSE_DIR
LICENSE_LIST=`ls */*`

for INPUT in $LICENSE_LIST; do
        if [[ -f $INPUT ]]; then
		PKG_NAME=`echo $INPUT|cut -d'/' -f1`
                md5sum $INPUT | echo `awk '{print $1}'` $PKG_NAME $LICENSE_DIR/$INPUT >> $MD5_TEMP_FILE
        fi
done

MD5_LIST=`cat $MD5_TEMP_FILE|awk '{print $1}'|sort -u`

echo "<html>" >> $LICENSE_FILE
echo "<head>" >> $LICENSE_FILE
echo "<meta name=\"viewport\" content=\"initial-scale=1.0\">" >> $LICENSE_FILE
echo "</head>" >> $LICENSE_FILE
echo "<body>" >> $LICENSE_FILE
echo "<xmp>" >> $LICENSE_FILE

for INPUT in $MD5_LIST; do
        PKG_LIST=`cat $MD5_TEMP_FILE|grep $INPUT|awk '{print $2}'`
	FILE_LIST=`cat $MD5_TEMP_FILE|grep $INPUT|awk '{print $3}'`
	PKG_FILE=`echo $FILE_LIST |awk '{print $1}'`

        echo "$PKG_LIST :" >> $LICENSE_FILE
        cat $PKG_FILE >> $LICENSE_FILE
        echo  >> $LICENSE_FILE
        echo  >> $LICENSE_FILE
        echo  >> $LICENSE_FILE
done

echo "</xmp>" >> $LICENSE_FILE
echo "</body>" >> $LICENSE_FILE
echo "</html>" >> $LICENSE_FILE

rm -rf $LICENSE_DIR/* $LICENSE_OLD_DIR/* $MD5_TEMP_FILE