summaryrefslogtreecommitdiff
path: root/build-repo.sh
blob: 038e4f6d434fb8fa05e13a94765f96027fb419a9 (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
93
94
95
#!/bin/bash

XIBUILD=./xibuild

fetch-pkg-builds () {
    git clone https://git.davidovski.xyz/xilinux/xipkgs

    mkdir dist

    for REPO in $(du -h xipkgs/repo/* | awk '{print $2}'); do
        REPO_NAME=$(echo $REPO | cut -d"/" -f2-)

        REPO_INDEX=dist/$REPO_NAME/index.html
        REPO_LIST=dist/$REPO_NAME/packages.txt

        echo "<html>
        <head>
            <title>packages for $REPO_NAME</title>
            <link rel='stylesheet' type='text/css' href='/style.css'>
        </head>
        <body>
        <h1>Packages in <a href='../'>$REPO_NAME</a></h1>
        <table>" > $REPO_INDEX

        printf "" > xibuild.report.log
        for BUILD_FILE in $REPO/*; do
            DEST=dist/$REPO_NAME

            $XIBUILD -o $DEST $BUILD_FILE

            PKG_NAME=$(basename $BUILD_FILE .xibuild)
            DESC=$(grep $PKG_NAME xibuild.report.log | cut -d" " -f3-)

            COLOR="none"
            if grep $PKG_NAME xibuild.report.log | grep -q new; then 
                COLOR="lime"
            fi
            if grep $PKG_NAME xibuild.report.log | grep -q fail; then
                if [ ! -f $DEST ]; then 
                    COLOR="orange"
                else
                    COLOR="red"
                fi
            fi
            echo "
    <tr style='background-color: $COLOR'>
    <td>$PKG_NAME</td>
    <td><a href='src/$PKG_NAME.xibuild'>src</a></td>
    <td><a href='logs/$PKG_NAME.log'>log</a></td>
    <td>$DESC</td>
    <td><a href='$PKG_NAME.xipkg'>$PKG_NAME.xipkg</a></td>
    <td><a href='$PKG_NAME.xipkg.info'>.info</a></td>
</tr>
" >> $REPO_INDEX
        done;

        rm xibuild.report.log

        echo "</table>

        <p>Latest builds: <b>$(date)</b></p>

        <h3>Legend:</h3>
        <ul>
            <li style='background-color: none'>build skipped; no updates</li>
            <li style='background-color: red'>build failed; no previous version</li>
            <li style='background-color: orange'>build failed; previous version exists</li>
            <li style='background-color: lime'>build passed: new update</li>
        </ul>
        </body>
        </html>
        " >> $REPO_INDEX

        cd dist/$REPO_NAME
        ls -1 *.xipkg.info > packages.txt
        cd -

        # move logs and sources
        mv logs/* dist/$REPO_NAME/logs
        
        mkdir -p dist/$REPO_NAME/src
        mv $REPO/* dist/$REPO_NAME/src/
        
        # add key for whole repo
        cp keychain/xi.pub dist/repo/
    done;
    

    rm -rf xipkgs
    rm -rf logs
    rm -rf tmp
    rm -rf xibuild.log
}

fetch-pkg-builds