summaryrefslogtreecommitdiff
path: root/xibuild/make_infos.sh
blob: 9c5791040bb0b1d8bb9fb39286ca2d21918a493b (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
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
#!/bin/bash


# TODO remember to update this if there are ever changes
XIPKG_INFO_VERSION='02'

get_info() {
        local name=$(basename -s ".xipkg" $1)

        local pkg_ver=$PKG_VER
        [ -z "$pkg_ver" ] && pkg_ver=$BRANCH
        [ -z "$pkg_ver" ] && pkg_ver="latest"
        
        echo "# XiPKG info file version $XIPKG_INFO_VERSION"
        echo "# automatically generated from the built packages"
        echo "NAME=$name"
        echo "DESCRIPTION=$DESC"
        echo "PKG_FILE=$name.xipkg"
        echo "CHECKSUM=$(md5sum $1 | awk '{ print $1 }')"
        echo "VERSION=$pkg_ver"
        echo "SOURCE=$SOURCE"
        echo "DATE=$(date -r $1)"
        echo "DEPS=(${DEPS[*]})"
        echo "MAKE_DEPS=(${MAKE_DEPS[*]})"
}

sign () {
    printf "SIGNATURE="
    openssl dgst -sign $PRIV_KEY $1 | base64 | tr '\n' ' '
    printf "\n"
    openssl dgst -sign $PRIV_KEY $1
}

list_line() {
    local pkg_file=$1
    
    local name=$(basename -s ".xipkg" $pkg_file)
    local filecount=$(gzip -cd $pkg_file | tar -tvv | grep -c ^-)
    local checksum=$(md5sum $pkg_file | awk '{ print $1 }')
    local size=$(stat -c %s $pkg_file)

    echo $name.xipkg $checksum $size $filecount 
}

list_deps() {
    local info_file=$1
    local deps=$(grep -a "^DEPS=(" $info_file | sed -rn "s/DEPS=\((.*)\)/\1/p")
    local name=$(basename -s ".xipkg.info" $info_file)

    echo "$name: $deps"
}


list=$(ls -d "$XIB_EXPORT"/repo/*)
total=$(echo $list | wc -w)
i=0
for repo in $list; do
    file="$repo/packages.list"
    [ -e $file ] && rm $file
    touch $file

    hbar -T "removing old repos" $i $total
    i=$((i+1))
done
hbar -t -T "removing old repos" $i $total

graph_file="$XIB_EXPORT"/repo/deps.graph
[ -f $graph_file ] && rm $graph_file

list=$(ls "$XIB_EXPORT"/repo/*/*.xipkg)
total=$(echo $list | wc -w)
i=0
for pkg in $list; do
        name=$(basename -s ".xipkg" $pkg)
        repo=$(echo $pkg | rev | cut -d/ -f2 | rev)
        info_file="$XIB_EXPORT/repo/$repo/$name.xipkg.info"
        build_file="$XIB_EXPORT/repo/$repo/$name.xibuild"

        source $build_file

        get_info $pkg > $info_file
        sign $pkg >> $info_file
        list_line $pkg >> "$XIB_EXPORT"/repo/$repo/packages.list
        [ -f $info_file ] && list_deps $info_file >> $graph_file

        hbar -T "generating info" $i $total
        i=$((i+1))
done
hbar -t -T "generating info" $i $total
printf "${INFO}Created $i info files!\n"