File: autobuilder

package info (click to toggle)
debirf 0.34
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 236 kB
  • ctags: 27
  • sloc: sh: 904; makefile: 34
file content (97 lines) | stat: -rwxr-xr-x 3,840 bytes parent folder | download
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
96
97
#!/bin/sh

# automatically build each of the shipped example profiles, log the
# build process, and create indexes and sha256sums of the whole deal.

# NOTE: this will take long time, and consume a lot of disk space.  i
# advise pointing the http_proxy environment variable at a nearby
# proxy.

# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

# Copyright 2011, released under the GPL version 3 or later.

PROFILE_LOC=/usr/share/doc/debirf/example-profiles
DATE_NOW=$(date +%F)
SUITES="${SUITES:-stable unstable}"
ARCH="$(dpkg --print-architecture)"

if ! dpkg -l grub-common syslinux-common xorriso >/dev/null ; then
    printf "Please install the missing packages to do a full debirf autobuild\n" >&2
    exit 1
fi

mkdir -p "profiles/$ARCH" "logs/$ARCH"

errors=0

cat > "profiles/$ARCH/index.html" <<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>debirf $ARCH autobuilt images ($DATE_NOW)</title>
<meta name="robots" content="nofollow" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<h1>autobuilt $ARCH images for <a href="http://cmrg.fifthhorseman.net/wiki/debirf"><tt>debirf</tt></a></h1>
<p>These $ARCH images were auto-generated on $DATE_NOW on $(hostname --fqdn) ($(uname -o)).</p>
<p>To download these images for your own use, you probably want <em>either</em>:</p>
<ul><li>a kernel (<tt>vmlinu*</tt>) and</li><li>an initramfs (<tt>*.cgz</tt>)</li></ul>
<p><em>or</em></p>
<ul><li>a CD image (<tt>*.iso</tt>)</li></ul>
<p>You almost certainly do not need all three files.</p>
<p>Please make sure to review the <a href="sha256sums.txt">checksums</a> after downloading.</p>
EOF

printf "# debirf %s autobuilt images (generated %s on %s)\n" "$ARCH" "$DATE_NOW" "$(hostname --fqdn)" > "profiles/$ARCH/sha256sums.txt"


for DEBIRF_SUITE in $SUITES; do
    export DEBIRF_SUITE
    mkdir -p "profiles/$ARCH/$DEBIRF_SUITE"
    cat >> "profiles/$ARCH/index.html" <<EOF
<h2 id="suite-$DEBIRF_SUITE">$DEBIRF_SUITE images</h2>
<dl>
EOF

    for profile in $(cd "$PROFILE_LOC" && printf "%s " *.tgz); do
	profile=$(basename "$profile" .tgz)

	rm -rf "profiles/$ARCH/$DEBIRF_SUITE/$profile"
	tar xzf "$PROFILE_LOC"/${profile}.tgz -C "profiles/$ARCH/$DEBIRF_SUITE"
	if ! debirf make "profiles/$ARCH/$DEBIRF_SUITE/$profile" > "logs/${ARCH}/${DEBIRF_SUITE}-${profile}.log" 2>&1 ; then
	    printf "Failed to make %s (%s)\n" "$profile" "$DEBIRF_SUITE"
	    errors=$(( $errors + 1 ))
	else
            for bootloader in isolinux grub; do
                if ! DEBIRF_ISO_BOOTLOADER="$bootloader" debirf makeiso "profiles/$ARCH/$DEBIRF_SUITE/$profile" > "logs/${ARCH}/${DEBIRF_SUITE}-${profile}.iso-${bootloader}.log" 2>&1 ; then
	            printf "Failed to makeiso[%s] %s (%s)\n" "$bootloader" "$profile" "$DEBIRF_SUITE"
	            errors=$(( $errors + 1 ))
                fi
            done
	fi
        kernel=
        (cd "profiles/$ARCH"
            printf "<dt id=\"profile-%s-%s\">%s</dt><dd><ul>\n" "$DEBIRF_SUITE" "$profile" "$profile" >> index.html
            for file in \
                "$DEBIRF_SUITE/$profile/vmlinu"* \
                "$DEBIRF_SUITE/$profile/"*.cgz \
                "$DEBIRF_SUITE/$profile/"*.iso 
            do
                if [ -e "$file" ]; then
                    printf "<li><a href=\"%s\">%s</a> (%siB)</li>\n" "$file" "$(basename "$file")" "$(du -h "$file" | cut -f1)" >> index.html
                    sha256sum "$file" >> sha256sums.txt
                fi
            done
            printf "</ul></dd>\n" >>index.html
        )
    done
    printf "</dl>\n" >> "profiles/$ARCH/index.html"
done

printf "</body>\n</html>\n" >> "profiles/$ARCH/index.html"

if [ "$errors" -gt 0 ]; then
    exit 1
fi