File: nd_build

package info (click to toggle)
neurodebian 0.43.0
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,960 kB
  • sloc: sh: 2,419; python: 1,978; perl: 412; makefile: 207; javascript: 63
file content (112 lines) | stat: -rwxr-xr-x 2,817 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
108
109
110
111
112
#!/bin/bash

if [ -z "$1" ]; then
cat << EOT
Script to build a source package in one of the available cowbuilders.

Synopsis
--------

  nd_build <family> <codename> [arch] <dsc file> [cowbuilder options]


Examples
--------

Build for a single specific arch:

  nd_build nd+debian lenny i386 someting.dsc


Build for all archs (will just build once for arch 'all'):

  nd_build ubuntu jaunty something.dsc


Build the same way but don't put results in current dir:

  nd_build debian sid something.dsc --buildresult to-upload/

EOT
exit 1
fi

family=$1
dist=$2

set -e

if [ -z "$family" ]; then
  echo "You need to provide a distribution family ('debian', 'ubuntu'); prefix with 'nd+' to enable the NeuroDebian repository."
  exit 1
fi

if [ -z "$dist" ]; then
  echo "You need to provide a distribution codename (e.g. 'lenny', 'squeeze')."
  exit 1
fi

. /etc/neurodebian/cmdsettings.sh

# common options
opts="--distribution $dist --aptcache $aptcache --buildplace $buildplace"

if [ -z "$3" ]; then
  echo "You need to provide a .dsc file"
  exit 1
fi

if [ ! "$3" = "${3%*.dsc}" ]; then
  dscfile=$3
  # must already be the dsc file, hence no arch info given
  if [ "$(grep '^Architecture' $dscfile | awk '{ print $2 }')" = "all" ]; then
    echo "Arch 'all' package detected -- using amd64 system to build it"
    arch="amd64"
  else
    arch="i386 amd64"
  fi
  shift; shift; shift
else
  # must be arch given and dsc as 4th
  arch=$3
  dscfile=$4
  if [ -z "$dscfile" ]; then
    echo "You need to provide a .dsc file"
    exit 1
  fi
  shift; shift; shift; shift
fi

# failed will be set to 1 if any build fails
failed=
for a in $arch; do
  # default
  options="$opts"
  if [ "$a" = "amd64" ]; then
    # only force source into the upload for NeuroDebian
    if [ ! "$family" = "${family#nd+*}" ]; then
      options="$opts --debbuildopts -sa"
    fi
  else
    options="$opts --debbuildopts -B"
  fi

  echo "Building for $family $dist $a ..."
  buildfile="${dscfile%.dsc}_${a}.build"
  tsfile="${buildfile}.timestamp.`date +%s`" # "unique" timestamp file
  /usr/bin/time -f "%E real, %U user, %S sys, %O out" -o "${tsfile}" \
  cowbuilder --build $dscfile \
             --basepath ${cowbuilderroot}/cow/${family}-${dist}-${a}.cow \
             --buildresult . \
             --logfile "${buildfile}" \
             $options \
             "$@" && status='OK' || { status='FAILED'; failed=1; }
  timeinfo=$(tail -n 1 "${tsfile}")
  # Update the summary of builds
  touch summary.build                               # Assure existence
  sed -i -e "s/\(${buildfile}.*out$\)/\1 OLD/g" summary.build  # Mark previous entry as OLD
  echo -e "${buildfile}\t$status\t$timeinfo" >> summary.build  # Add current one
  rm -f "${tsfile}"
done
# Exit with failure status if any built failed
[ -z $failed ] || exit 1