File: debian-cd-pettersson-live

package info (click to toggle)
openstack-debian-images 1.87
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: sh: 3,179; makefile: 11
file content (107 lines) | stat: -rw-r--r-- 2,486 bytes parent folder | download | duplicates (6)
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
98
99
100
101
102
103
104
105
106
107
#!/bin/bash

#set -x

NL="
"
OLDIFS=$IFS

TOP="/w"
LOCALCONF="${TOP}/in"
STATE="${TOP}/state"

. ${LOCALCONF}/common.sh
. ${LOCALCONF}/CONF.sh

# Rename the output files to something more appropriate for our use
RENAME="s,debian-$CODENAME-(.*)-amd64,debian-$VERSION-openstack-amd64,"

mkdir -p ${STATE}
rm -rf ${STATE}/*
BUILDNAME="openstack-$CODENAME"
WORK="${TOP}/work/${BUILDNAME}"
OUT="${TOP}/out/${BUILDNAME}"
LOG="${TOP}/out/log"
mkdir -p ${WORK} ${OUT}

SOURCE_ERROR=0

grab_file () {
    REMOTE=$(echo $1 | tr -d \')
    LOCAL="source/$2"
    SIZE=$3
    SHA=$4

    if [ ! -f $LOCAL ] ; then
	wget -O $LOCAL $REMOTE >> ${LOG}/${BUILDNAME}.log
	local_size=$(stat -c %s $LOCAL)
	check_alg=${SHA%%:*}
	check_prog="sha"${check_alg##SHA}"sum"
	local_check=$(${check_prog} < $LOCAL | awk '{print $1}')
	if [ ${local_size} != $SIZE ] ; then
	    echo "Size mismatch for $REMOTE" >> ${LOG}/${BUILDNAME}.log
	    SOURCE_ERROR=1
	fi
	if [ ${check_alg}":"${local_check} != $SHA ] ; then
	    echo "Checksums mismatch for $REMOTE" >> ${LOG}/${BUILDNAME}.log
	    echo ${check_alg}":"${local_check}
	    echo $SHA
	    SOURCE_ERROR=1
	fi
    fi
}

cd ${WORK}

BUILDSTART=$(now)
log "Starting full OpenStack image build (codename $CODENAME, version $VERSION) at $BUILDSTART"

START=$(now)

build-openstack-debian-image \
    -hs $LOCALCONF/openstack-hook \
    -u http://ftp.se.debian.org/debian \
    -r $CODENAME \
    -is 2 2>&1 >> ${LOG}/${BUILDNAME}.log

ERROR=$?
END=$(now)
time_spent=$(calc_time $CKSUMSTART $END)

if [ $ERROR -eq 0 ] ; then
    log "successful build started at $START, ended at $END (took $time_spent)"
    if [ "$RENAME"x != ""x ] ; then
	rename -v "$RENAME" * >> ${LOG}/${BUILDNAME}.log
    fi

    cd ${WORK}
    mkdir source

    IFS="$NL"
    for line in $(cat sources); do
	IFS=$OLDIFS
	grab_file $line
	IFS="$NL"
    done
    IFS=$OLDIFS
    tar czf debian-$VERSION-openstack-source.tar.gz source
    rm -rf source sources

    mv * ${OUT}

    CKSUMSTART=(now)
    cd ${OUT} && checksum_files
    END=$(now)
    time_spent=$(calc_time $CKSUMSTART $END)
    log "checksums started at $CKSUMSTART, ended at $END (took $time_spent)"
else
    log "FAILED with error $error, build started at $START, ended at $END (took $time_spent)"
fi

if [ $SOURCE_ERROR -ne 0 ] ; then
    log "FAILED to download sources"
    ERROR=2
fi

time_spent=$(calc_time $BUILDSTART $END)
log "DONE. ERROR=$ERROR $BUILDNAME run started at $BUILDSTART, ended at $END (took $time_spent)"