/[vps]/stages/build-stages
Gentoo

Contents of /stages/build-stages

Parent Directory Parent Directory | Revision Log Revision Log


Revision 249 - (show annotations) (download)
Thu Feb 23 06:15:37 2006 UTC (8 years, 1 month ago) by hollow
File size: 3686 byte(s)
adapt to catalyst2
1 #!/bin/bash
2 #
3 # build-stages - Build vserver stages
4 # Copyright (C) 2005 Christian Heim <phreak@gentoo.org>
5 # Benedikt Boehm <hollow@gentoo.org>
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 #
21 # v0.1 - initial release
22
23 trap "exit 1" INT
24
25 if [ -r /sbin/functions.sh ]; then
26 source /sbin/functions.sh
27 else
28 echo "/sbin/functions.sh missing. Are you running Gentoo?"
29 fi
30
31 die() {
32 eerror ${1:-<no error message>}
33 exit ${2:-1}
34 }
35
36 usage() {
37 echo "Usage: build-stages <spec>"
38 echo
39 echo "<spec> Stages spec file"
40 }
41
42 # checking command line
43 if [ $# -ne 1 ]; then
44 usage
45 exit
46 fi
47
48 # check root privs
49 [ "$(id -u)" != "0" ] && die "Need root privileges"
50
51 # read spec file
52 [ ! -r $1 ] && die "No read-access to $1"
53 source $1
54
55 # set default values
56 : ${type:=default}
57 : ${version:=$(date +%Y%m%d)}
58 : ${sync_snapshots:=1}
59 : ${sync_source:=ftp.join.uni-muenster.de::gentoo/snapshots/}
60 : ${snapshot:=latest}
61 : ${stage1:=1}
62 : ${stage2:=1}
63 : ${stage3:=1}
64
65 # set subsources
66 stage_name=${arch}-${version}
67 : ${stage1_seed:=seed}
68 : ${stage2_subsource:=${type}/stage1-${stage_name}}
69 : ${stage3_subsource:=${type}/stage2-${stage_name}}
70
71 # setup all the path variables
72 cdir=$(source /etc/catalyst2/catalyst2.conf; echo ${storedir:-/var/tmp/catalyst2})
73 tmpdir=${cdir}/tmp
74 snapdir=${cdir}/snapshots
75 builddir=${cdir}/builds
76 stagedir=${builddir}/${type}
77
78 mkdir -p ${stagedir}
79
80 # check config
81 [ -z "${arch}" ] && die "arch not set. please fix your config file"
82 [ -z "${profile}" ] && die "profile not set. please fix your config file"
83
84 # display some common info
85 einfo "Building stages for:"
86 einfo
87 einfo " arch: ${arch}"
88 einfo " type: ${type}"
89 einfo " version: ${version}"
90 einfo " snapshot: ${snapshot}"
91 einfo " profile: ${profile}"
92 einfo
93 echo
94
95 build_stage() {
96 [ $# -ne 2 ] && return 1
97
98 local target=$1
99 local subsource=$2
100
101 local stagefile=${stagedir}/${target}-${arch}-${version}.tar.bz2
102
103 if [ -f ${stagefile} ]; then
104 einfo "${target} is cached at ${stagefile}"
105 return
106 fi
107
108 einfo "Building ${target} ..."
109
110 # we need a seed stage
111 [ ! -f ${builddir}/${subsource}.tar.bz2 ] && die "subsource ${builddir}/${subsource}.tar.bz2 does not exist"
112
113 # Now run catalyst2 and gather stats about the build
114 /usr/bin/time -v \
115 --output=${stagefile}.stats \
116 catalyst2 -C \
117 subarch=${arch} \
118 version_stamp=${version} \
119 rel_type=${type} \
120 profile=${profile} \
121 snapshot=${snapshot} \
122 target=${target} \
123 source_subpath=${subsource} \
124 || die "catalyst2 failed to build ${target}"
125
126 # Generate digest
127 cd ${stagedir}
128 md5sum $(basename ${stagefile}) > $(basename ${stagefile}).md5
129
130 # Generate file listings of the tarball
131 tar -tjf ${stagefile} > ${stagefile}.CONTENTS
132 }
133
134 if [ ${sync_snapshots} -eq 1 ]; then
135 einfo "Syncing snapshots"
136 rsync -av ${sync_source}/ ${snapdir}/
137 fi
138
139 [ $stage1 -eq 1 ] && build_stage stage1 ${stage1_seed}
140 [ $stage2 -eq 1 ] && build_stage stage2 ${stage2_subsource}
141 [ $stage3 -eq 1 ] && build_stage stage3 ${stage3_subsource}
142
143 einfo "All stages built successfully"

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20