File: iso_run

package info (click to toggle)
debian-cd 3.1.13
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,244 kB
  • sloc: sh: 4,925; perl: 3,730; makefile: 387
file content (130 lines) | stat: -rwxr-xr-x 3,361 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
#
# Helper for image creation
#
PUBDIRJIG=$1
RSYNC_TARGET=$2
ARCH=$3

LOG=~/build.wheezy/log/$ARCH.iso_run
HOSTNAME=`hostname -f`
LOCK=~/iso_run.lock
START=`date -u +%H:%M:%S`

# Check to see if another sync is in progress
if lockfile -! -l 43200 -r-1 "$LOCK"; then  
    echo $HOSTNAME is not doing another iso_run, lock file $LOCK exists
    exit 1
fi
trap "rm -f $LOCK > /dev/null 2>&1" exit  

COPY_START=`date -u +%H:%M:%S`

rm -f $LOG

# Given an ISO image:
# 1. create the torrent file if desired (only for release builds)
# 2. copy all of them into place
process_iso() {
    FILE=$1
    OUTDIR=$2

    echo $OUTDIR/$FILE >> $LOG
    cp -a $FILE $OUTDIR/$FILE

    if [ "$RELEASE_BUILD"x != ""x ] ; then
	~/build.wheezy/mktorrent $FILE >> $LOG
	BTFILE=`echo $FILE.torrent | sed 's/iso-/bt-/'`
	echo $OUTDIR/$BTFILE >> $LOG
	cp -a $BTFILE $OUTDIR/$BTFILE
    fi
}

# Poor man's rsync, but with some local optimisations
copy_files() {
    SRC=$1
    TARGET=$2
    ARCHES=$3

    DISKTYPES="cd dvd bd dlbd"
    DIRTYPES="iso jigdo list"

    # Only make torrent files and dirs for release builds
    if [ "$RELEASE_BUILD"x != ""x ] ; then
	DIRTYPES="$DIRTYPES bt"
    fi

    CURRENT=`pwd`
    cd $SRC
    for ARCH in $ARCHES
    do
        for DISKTYPE in $DISKTYPES; do
            for DIRTYPE in $DIRTYPES; do
                mkdir -p -m775 $TARGET/$ARCH.tmp/$DIRTYPE-$DISKTYPE
            done
        done

        cd $ARCH
        find . -name '*.jigdo' -o -name '*.template' \
	    -o -name '*.list.gz' -o -name '*SUMS*' | \
            xargs tar cf - | (cd $TARGET/$ARCH.tmp/ && tar xvf -) >> $LOG
	
        # Only make torrent files and dirs for release builds
        rm -rf bt-*
        for DISKTYPE in $DISKTYPES; do
	    if [ "$RELEASE_BUILD"x != ""x ] ; then
		mkdir bt-$DISKTYPE
	    fi
	    for FILE in iso-$DISKTYPE/*.iso; do
		if [ -e $FILE ] ; then
		    process_iso $FILE $TARGET/$ARCH.tmp
		fi
	    done
	    if [ "$RELEASE_BUILD"x != ""x ] ; then
		for FILE in $TARGET/$ARCH.tmp/iso-$DISKTYPE/*SUMS*; do
		    if [ -e $FILE ] ; then
			cp -al $FILE $TARGET/$ARCH.tmp/bt-$DISKTYPE/
		    fi
		done
	    fi
	done

	if [ "$RELEASE_BUILD"x = ""x ] ; then
	    # Only populate the HEADER.html file for regular weekly
	    # builds; we don't want it for releases
            DATE=`date -u`
            sed "s/ARCH/$ARCH/g;s/DATE/$DATE/g" ~/build.wheezy/weekly.html \
		> $TARGET/$ARCH.tmp/HEADER.html
	fi

	# Now clean up any directories without any real content
	# (i.e. empty dir, or just containing checksum files)
	for dir in $TARGET/$ARCH.tmp/*-* ; do
	    num=`ls -l $dir | grep -v -e SUMS -e total | wc -l`
	    if [ $num = 0 ] ; then 
		rm -rf $dir
	    fi
	done	

        cd ..

    done
    cd $CURRENT
}

copy_files $PUBDIRJIG $RSYNC_TARGET $ARCH

echo "$START: Starting $ARCH sync from $PUBDIRJIG to $RSYNC_TARGET" >> $LOG
if [ -e $RSYNC_TARGET/$ARCH ] ; then
    mv -f $RSYNC_TARGET/$ARCH $RSYNC_TARGET/$ARCH.old
fi
mv $RSYNC_TARGET/$ARCH.tmp $RSYNC_TARGET/$ARCH
rm -rf $RSYNC_TARGET/$ARCH.old &

# Update the trace file now to force a sync on free.hands.com after each arch
mkdir -p $RSYNC_TARGET/trace
date -u > $RSYNC_TARGET/trace/cdimage.debian.org

END=`date -u +%H:%M:%S`
echo "$ARCH synced across to $RSYNC_TARGET; started at $START, copying started at $COPY_START, ended at $END"
echo "$END: Finished" >> $LOG