source: build-files/freebsd-update/scripts/9-STABLE/build.subr @ 635dc54

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1
Last change on this file since 635dc54 was 635dc54, checked in by Kris Moore <kris@…>, 17 months ago

Add our freebsd-update code to GIT

This will become a dumping ground for mods we may make to the freebsd-update
build process, as well as the specific patches we have going into a release

  • Property mode set to 100644
File size: 5.5 KB
Line 
1# Overrides to FreeBSD Update build subroutines for FreeBSD 9.0.
2
3# Download and verify a release ISO image.
4fetchiso () {
5}
6
7# Extract the released trees and, if appropriate, construct a world (base
8# plus source code) in which to perform builds.
9extractiso () {
10
11        # Extract the various components into different directories
12        log "Extracting components"
13        for C in ${WORLDPARTS}; do
14                mkdir -p ${WORKDIR}/release/R/trees/world/${C}
15                mkdir -p ${WORKDIR}/ftp/${REL}/ 2>/dev/null
16                fetch -o ${WORKDIR}/ftp/${REL}/${C}.txz ${FTP}/${REL}/${TARGET}/dist/${C}.txz
17                cat ${WORKDIR}/ftp/${REL}/${C}.txz |
18                    tar -xpf - -C ${WORKDIR}/release/R/trees/world/${C}
19        done
20        for C in ${KERNELPARTS}; do
21                mkdir -p ${WORKDIR}/release/R/trees/kernel/${C}
22                mkdir -p ${WORKDIR}/ftp/${REL}/ 2>/dev/null
23                fetch -o ${WORKDIR}/ftp/${REL}/${C}.txz ${FTP}/${REL}/${TARGET}/dist/${C}.txz
24                cat ${WORKDIR}/ftp/${REL}/${C}.txz |
25                    tar -xpf - -C ${WORKDIR}/release/R/trees/kernel/${C}
26        done
27        for C in ${SOURCEPARTS}; do
28                mkdir -p ${WORKDIR}/release/R/trees/src/${C}
29                mkdir -p ${WORKDIR}/ftp/${REL}/ 2>/dev/null
30                fetch -o ${WORKDIR}/ftp/${REL}/${C}.txz ${FTP}/${REL}/${TARGET}/dist/${C}.txz
31                cat ${WORKDIR}/ftp/${REL}/${C}.txz |
32                    tar -xpf - -C ${WORKDIR}/release/R/trees/src/${C}
33        done
34
35        # If the release ISO we're handling belongs to the platform
36        # we're running right now, create a world image for future use.
37        if [ ${TARGET} = ${HOSTPLATFORM} ]; then
38                log "Constructing world+src image"
39
40                # Create directory for world
41                mkdir ${WORKDIR}/world/
42
43                # Extract world and source distributions
44                for C in ${WORLDPARTS}; do
45                        cat ${WORKDIR}/ftp/${REL}/${C}.txz |
46                            tar -xpf - -C ${WORKDIR}/world/
47                done
48                for C in ${SOURCEPARTS}; do
49                        cat ${WORKDIR}/ftp/${REL}/${C}.txz |
50                            tar -xpf - -C ${WORKDIR}/world/
51                done
52
53                # build a single tarball of them.
54                tar -czf ${WORKDIR}/../world.tgz -C ${WORKDIR}/world .
55
56                # clean up
57                nuke world
58        fi
59
60}
61
62# Perform a build in ${WORKDIR}/$1 with BRANCH_OVERRIDE set to $2
63buildworld () {
64        # We need a devfs inside the jail.  Note that we are using a
65        # jail here in order to keep the environment as "clean" as
66        # possible, not for security reasons; we assume that the
67        # original source code plus patches we add personally will
68        # not do anything evil.
69        mount -t devfs devfs ${WORKDIR}/$1/dev
70
71        # We need to be able to set file flags
72        sysctl security.jail.chflags_allowed=1 >/dev/null
73
74        # Build stuff.
75        jail ${WORKDIR}/$1 ${BUILDHOSTNAME} 127.1.2.3                   \
76            /usr/bin/env -i PATH=${PATH} RELP=${RELP}                   \
77                BRANCH_OVERRIDE=$2 JFLAG=${JFLAG}                       \
78                TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}             \
79            /bin/sh -e <<-"EOF" 2>&1 >${WORKDIR}/$1-build.log
80                # Function for logging what we're doing
81                log () {
82                        echo "`date` $1 for FreeBSD/${TARGET} ${RELP}" 1>&2
83                }
84
85                # Build the world
86                log "Building world"
87                cd /usr/src &&
88                    make buildworld ${JFLAG} 2>&1
89
90                # Build and kernel
91                log "Building kernel"
92                cd /usr/src &&
93                    make buildkernel ${JFLAG} 2>&1
94
95                # Build and install release images
96                log "Building release"
97                cd /usr/src/release &&
98                    make release 2>&1 &&
99                    make install DESTDIR=/R 2>&1
100        EOF
101
102        # Put all the components into the right places.
103        log "Moving components into staging area"
104        jail ${WORKDIR}/$1 ${BUILDHOSTNAME} 127.1.2.3                   \
105            /usr/bin/env -i PATH=${PATH}                                \
106                WORLDPARTS="${WORLDPARTS}"                              \
107                KERNELPARTS="${KERNELPARTS}"                            \
108                SOURCEPARTS="${SOURCEPARTS}"                            \
109            /bin/sh -e <<-"EOF" 2>&1 >>${WORKDIR}/$1-build.log
110                # Create area for uncompressed components
111                mkdir -p /R/trees
112
113                # Move world components into place
114                for C in ${WORLDPARTS}; do
115                        mkdir -p /R/trees/world/${C}
116                        cat /R/ftp/${C}.txz |
117                            tar -xpzf - -C /R/trees/world/${C}
118                done
119
120                # Move kernel components into place
121                for C in ${KERNELPARTS}; do
122                        mkdir -p /R/trees/kernel/${C}
123                        cat /R/ftp/${C}.txz |
124                            tar -xpzf - -C /R/trees/kernel/${C}
125                done
126
127                # Extract src components into place
128                for C in ${SOURCEPARTS}; do
129                        mkdir -p /R/trees/src/${C}
130                        cat /R/ftp/${C}.txz |
131                            tar -xpzf - -C /R/trees/src/${C}
132                done
133        EOF
134
135        # Get rid of the devfs we no longer need.
136        umount ${WORKDIR}/$1/dev
137}
138
139# Perform a build in ${WORKDIR}/$1, but with the date set 400 days
140# into the future.  Turn off NTP before we change the date and
141# turn it back on afterwards.
142futurebuildworld () {
143        # Turn off ntpd if necessary
144        if /etc/rc.d/ntpd status |
145            grep -q 'is running'; then
146                ntpd_was_running=1
147                log "Turning off NTP"
148                /etc/rc.d/ntpd stop >/dev/null
149        else
150                ntpd_was_running=0
151        fi
152
153        date -n `date -j -v+400d "+%y%m%d%H%M.%S"` >/dev/null
154        buildworld $1 FUTUREBUILD
155        date -n `date -j -v-400d "+%y%m%d%H%M.%S"` >/dev/null
156
157        # Turn ntpd back on, if appropriate
158        if [ ${ntpd_was_running} = 1 ]; then
159                log "Turning NTP back on"
160                /etc/rc.d/ntpd start >/dev/null
161        fi
162}
163
164# Add extra docs to ${WORKDIR}/$1
165addextradocs () {
166        log "Extracting extra docs"
167
168        # 8.0 doesn't have any extra docs
169}
170
171# Fixup: the "kernel" kernel is really the "generic" kernel.
172indexpublish () {
173        sed -E 's,kernel\|kernel,kernel|generic,'
174}               
175
176# Print a list of stamped files and filestamps located, in order to
177# allow the user to verify that everything is working properly.
178printstamps () {
179        if [ ! -e "${WORKDIR}/stampedfiles.new" ] ; then
180           echo "No stampedfiles.new created..."
181           return
182        fi
183        echo
184        echo "Files found which include build stamps:"
185        cat ${WORKDIR}/stampedfiles.new
186        echo
187        echo "Values of build stamps, excluding library archive headers:"
188        cat ${WORKDIR}/stampvalues.new |
189            grep -vE '.*/[0-9]* *[0-9]{10}  0     0     (0|100644)'
190}
Note: See TracBrowser for help on using the repository browser.