]> git.ozlabs.org Git - next-scripts/blob - import-cpuinit
limit the builds access to the network
[next-scripts] / import-cpuinit
1 #!/bin/bash
2
3 log_file=../cpuinit-import.log
4
5 log()
6 {
7         echo "$@" | tee -a $log_file
8 }
9
10 execute()
11 {
12         log "$" $@
13         "$@" 2>&1 | tee -a $log_file
14         [ ${PIPESTATUS[0]} -eq 0 ] || $SHELL -i || exit 1
15 }
16
17 cpuinit="$(cd ../cpuinit;pwd)"
18 sfile="$cpuinit/series"
19 cpwd=$(pwd)
20
21 base=$1
22 log "Importing cpuinit based on $base"
23 base=$(git rev-parse --verify "$base" 2>/dev/null) || {
24         log "Bad base $base"
25         exit 1
26 }
27
28 [ -d "../quilt-tmp" ] ||
29         execute git clone -s -l -n -q . ../quilt-tmp
30
31 log '$' cd ../quilt-tmp
32 cd ../quilt-tmp
33 execute git checkout -b cpuinit/master "$base"
34 git branch cpuinit/master-base
35
36 patches=$(sed -e '/^#/d' -e '/^[ \t]*$/d' "$sfile")
37
38 for f in $patches; do
39         execute git am --patch-format=mbox "$cpuinit/$f"
40 done
41
42 log '$' cd $cpwd
43 cd $cpwd
44
45 execute git fetch -f ../quilt-tmp cpuinit/master-base:cpuinit/master-base
46 execute git fetch -f ../quilt-tmp cpuinit/master:cpuinit/master
47
48 rm -rf ../quilt-tmp
49
50 exit 0