Revision 759d2f73

b/snf-deploy/MANIFEST.in
1
include README Changelog
2 1
include distribute_setup.py
/dev/null
1
#!/bin/bash
2

  
3
usage(){
4

  
5
  echo "
6
Usage: $0: [options]
7
  -h, --help          Prints this help message
8
  --debian [branch]   Local debian branch to use (default debian)
9
  --upstream [branch] Local upstream branch to use (default master)
10
  --remote [repo]     Remote repo to use (default origin)
11
  --packages [dir]    Where to store the created packages (default ~/packages)
12
  --validate          Fetch remote repo branches and
13
                      check if local are up-to-date (default false)
14
  --push              Whether to push upstream (default false)
15
"
16
  exit 1
17
}
18

  
19
parse_git_branch()
20
{
21
    git branch 2> /dev/null | grep '^*' | sed 's/^*\ //g'
22
}
23

  
24
die()
25
{
26
    echo -e $* 1>&2
27
    echo Aborting.
28
    exit 1
29
}
30

  
31
cleanup()
32
{
33
    trap - EXIT
34

  
35
    echo -n Cleaning up...
36
    if [ ${#CLEANUP[*]} -gt 0 ]; then
37
        LAST_ELEMENT=$((${#CLEANUP[*]}-1))
38
        REVERSE_INDEXES=$(seq ${LAST_ELEMENT} -1 0)
39
        for i in $REVERSE_INDEXES; do
40
            local cmd=${CLEANUP[$i]}
41
            $cmd
42
        done
43
    fi
44
    echo "done"
45
}
46

  
47
add_cleanup() {
48
    local cmd=""
49
    for arg; do cmd+=$(printf "%q " "$arg"); done
50
    CLEANUP+=("$cmd")
51
}
52

  
53

  
54
add_checkpoint()
55
{
56
    commit=$(git reflog | head -n1 | cut -f 1 -d " ")
57
    add_cleanup git reset --hard $commit
58
    LASTCHECKPOINT=$commit
59
}
60

  
61
CLEANUP=( )
62

  
63

  
64
TEMP=$(getopt -o h --long help,validate,push,packages:,upstream:,debian:,remote: -n 'autopkg.sh' -- "$@")
65

  
66
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
67

  
68
eval set -- "$TEMP"
69

  
70
while true ; do
71
  case "$1" in
72
    -h|--help) usage ;;
73
    --upstream) LOCALUPSTREAM=$2 ; shift 2 ;;
74
    --debian) LOCALDEBIAN=$2 ; shift 2 ;;
75
    --remote) REMOTE=$2 ; shift 2 ;;
76
    --packages) PKGAREA=$2 ; shift 2 ;;
77
    --validate) VALIDATE=true ; shift ;;
78
    --push) PUSH=true ; shift ;;
79
    --) shift ; break ;;
80
    *) echo "Internal error!" ; usage ;;
81
  esac
82
done
83

  
84
# The root of the git repository, no matter where we're called from
85
TOPLEVEL="$(git rev-parse --show-toplevel)"
86

  
87
: ${LOCALUPSTREAM:=$(parse_git_branch)}
88
: ${LOCALDEBIAN:=debian}
89
: ${REMOTE:=origin}
90
: ${VALIDATE:=false}
91
: ${PUSH:=false}
92

  
93
: ${PKGAREA:=~/packages}
94
: ${BACKUPAREA:=~/backup}
95

  
96
cd "$TOPLEVEL"
97

  
98
# Prerequisites: Test all important directories exist
99
test -d "$PKGAREA" || die "Package area directory $PKGAREA missing"
100
test -d "$BACKUPAREA" || die "Backup area directory $BACKUPAREA missing"
101

  
102
# Prerequisite: Test the dialog utility is available
103
dialog --help &>/dev/null || die "Could not run the 'dialog' utility"
104

  
105
BUILDAREA=$(mktemp -d --tmpdir=/tmp build-area.XXX)
106
add_cleanup rm -r $BUILDAREA
107

  
108
echo "############################################################################"
109
echo "Will build packages under $BUILDAREA"
110
echo "Local upstream branch: $LOCALUPSTREAM"
111
echo "Local debian branch: $LOCALDEBIAN"
112
$VALIDATE && echo "Will fetch $REMOTE and check if $LOCALUPSTREAM and $LOCALDEBIAN are up-to-date"
113
echo "############################################################################"
114
echo "Press Enter to continue..."
115
read
116

  
117
MODIFIED=$(git status --short | grep -v "??")
118
test -z "$MODIFIED" || die "error: Repository is dirty. Commit your local changes:\n $MODIFIED"
119

  
120
set -e
121
trap cleanup EXIT
122

  
123
add_checkpoint
124

  
125
# Create a temporary debian branch to do everything
126
TMPDEBIAN=$(mktemp -u debian.XXX)
127
git branch --track $TMPDEBIAN  $LOCALDEBIAN
128
add_cleanup git branch -D $TMPDEBIAN
129

  
130
git checkout $TMPDEBIAN
131
add_cleanup git checkout $LOCALUPSTREAM
132

  
133
# Whether we are in snapshot or release mode
134
snap=false
135
mrgextra=-m
136
dchextra=-R
137
mrgmsg="Merge branch '$LOCALUPSTREAM' into $LOCALDEBIAN"
138
dialog --yesno "Create Snapshot?" 5 20 && snap=true  && dchextra=-S && mrgextra= && mrgmsg=
139

  
140
# merge local branch into tmp branch with a nice commit message,
141
# so it can be pushed as is to upstream debian
142
export GIT_MERGE_AUTOEDIT=no
143
git merge $mrgextra ${mrgextra:+"$mrgmsg"} $LOCALUPSTREAM
144

  
145
# auto edit Debian changelog depending on Snapshot or Release mode
146
export EDITOR=/usr/bin/vim
147
git-dch --debian-branch=$TMPDEBIAN --git-author --ignore-regex=".*" --multimaint-merge --since=HEAD $dchextra
148
git add debian/changelog
149

  
150
# get version from the changelog
151
# we add a git tag here, so setup.py sdist works as expected
152
# FIXME: This is a workaround for the way Synnefo packages determine
153
#        the versions for their Python packages
154
version=$(IFS="()" ; read  x v x < debian/changelog  ; echo $v)
155
if ! $snap; then
156
  git commit -s -a -m "Bump new upstream version"
157
  TAGFILE=$(mktemp -t tag.XXX)
158
  add_cleanup rm $TAGFILE
159
  dialog --inputbox "New Debian Tag: " 5 30 "debian/$version" 2>$TAGFILE
160
  git tag $(<$TAGFILE)
161
  add_cleanup git tag -d $(<$TAGFILE)
162
fi
163

  
164
add_cleanup git reset --hard HEAD
165
# Build all packages
166
git-buildpackage --git-export-dir="$BUILDAREA" \
167
                 --git-upstream-branch=$LOCALUPSTREAM \
168
                 --git-debian-branch=$TMPDEBIAN \
169
                 --git-export=INDEX \
170
                 --git-ignore-new -sa
171

  
172
# do some dirty backup
173
# pkgarea might be needed by auto-deploy tool
174
rm -f "$PKGAREA"/* || true
175
cp -v "$BUILDAREA"/* "$PKGAREA"/ || true
176
cp -v "$BUILDAREA"/* "$BACKUPAREA"/ || true
177

  
178

  
179

  
180
function check_remote(){
181

  
182
  git fetch $1 2>/dev/null || die "Could not fetch $1"
183
  git fetch $1 $2 2>/dev/null|| die "Could not fetch $1/$2"
184

  
185
  commits_behind=$(git rev-list $2..$1/$2 | wc -l)
186
  if [ $commits_behind -ne 0 ]; then
187
    die "Your local branch is outdated. Please run:\ngit pull --rebase $1/$2"
188
  fi
189

  
190

  
191
}
192

  
193
if $VALIDATE; then
194
  check_remote $REMOTE $LOCALUPSTREAM
195
  check_remote $REMOTE $LOCALDEBIAN
196
fi
197

  
198

  
199
  # trap - EXIT
200
  # here we can push the commits to the remote debian branch as they are
201
echo
202
echo "#################################################"
203
echo "##                  SUCCESS                    ##"
204
echo "#################################################"
205
if $PUSH; then
206
  git push --tags $REMOTE $TMPDEBIAN:$LOCALDEBIAN
207
  git push $REMOTE $LOCALUPSTREAM:$LOCALUPSTREAM
208
fi
209

  
210
exit 0
b/snf-deploy/files/usr/lib/ifup
1
#! /bin/bash
2
# Script to bring a network (tap) device for qemu-kvm up
3
# The idea is to add the tap device to the same bridge
4
# as we have default routing to.
5

  
6
# in order to be able to find brctl
7
PATH=$PATH:/sbin:/usr/sbin
8

  
9
: ${BRIDGE:=auto_nodes_br}
10

  
11
ip=$(which ip)
12

  
13
brctl=$(which brctl)
14

  
15
if [ ! "$ip" -o ! "$brctl" ]; then
16
   echo "W: $0: not doing any bridge processing: ip or brctl utility not found" >&2
17
   exit 0
18
fi
19

  
20
$ip link set "$1" up
21

  
22
brctl addif $BRIDGE "$1"
23

  
24
exit 0
/dev/null
1
#! /bin/bash
2
# Script to bring a network (tap) device for qemu-kvm up
3
# The idea is to add the tap device to the same bridge
4
# as we have default routing to.
5

  
6
# in order to be able to find brctl
7
PATH=$PATH:/sbin:/usr/sbin
8

  
9
: ${BRIDGE:=auto_nodes_br}
10

  
11
ip=$(which ip)
12

  
13
brctl=$(which brctl)
14

  
15
if [ ! "$ip" -o ! "$brctl" ]; then
16
   echo "W: $0: not doing any bridge processing: ip or brctl utility not found" >&2
17
   exit 0
18
fi
19

  
20
$ip link set "$1" up
21

  
22
brctl addif $BRIDGE "$1"
23

  
24
exit 0
/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Y0jwPfBH8J2p84Dj2avPYQKBgEnFNjcDFXHbqTcHE2boCZwuRYfy//JJtGxdPzS5
22
BnCqy63fpazUfd5C8qpEAdgOmXm32p/Uxk2VyTV3aJ/x96DfodZJ84mj/NjH42K9
23
7nXOh/MKZcxCx4C5OE9ti575R5dVnyJUldjQl6eM83cyilEY7ZNjpym9xZJgRMQz
24
ogw1AoGAQSZ/9BhH7XywifPh8M8a17dzDoex9ps/c9ayZFKfifi4fDOFyBovVDLx
25
GMPoeFyR60DjmRFRTPpt7yYDwFOSGLo90M6JAFyZeh86S/Xt6Zi6Fcd6+/VLejMY
26
CSlI/8vIgi5E1YZiT2I4joSUIzaa2lmoGZsSTiDjIxWUuqh3J3k=
27
-----END RSA PRIVATE KEY-----
/dev/null
1
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUsjUNXcojhi1yrMYO6lC8jx6q1REcXBD/8yXAW8Iw2kIQVyvT9/J8FlzJ0FVPYYrs0yB49Pd6/j6ewgkpcZcVdzcS9XltUIhHPtZD7r3bOG6LgHFP8oeO5hLB5TE0IiCpxyoeddocpX87ItE89x9wW7GfD9CMAmMFyscg22kxVTXwQ4GebKBoIVcI912iy92ZXfc2apU5h58YD7oQkfOhomYMEbisgiUb+cHbYrBudtSzhUofN7AjpBlZx2kjq3l9GpJQDJlx/evhsHugvV79HoXrY+8wL/ixkRdcfoH5IuodQ0FAyPLnTazSDDuARWW5y+XZbUtJx3nL1a+hijYH root@fab1

Also available in: Unified diff