/[gentoo-x86]/scripts/autodist.sh
Gentoo

Contents of /scripts/autodist.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download) (as text)
Mon Sep 27 20:07:36 2004 UTC (15 years ago) by vapier
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +0 -0 lines
File MIME type: text/x-sh
FILE REMOVED
old stuff; use catalyst

1 #!/bin/bash
2
3 runlog () {
4 echo "Running ${1+${@}}..." 1>&3
5 ${1+"${@}"} 1>&3 2>&1
6 echo 1>&3
7 }
8
9 TODAY=`date '+%Y%m%d'`
10 FIRSTDIR=`pwd`
11
12 # ok, this script builds:
13 #
14 # 1. the build tarball
15 # 2. the sys tarball
16 # 3. the build iso
17 # 4. the sys iso (with all packages)
18
19 [ -z "${PORTDIR}" ] && PORTDIR="/usr/portage"
20 [ -z "${DISTRODIR}" ] && DISTRODIR="${PORTDIR}/distribution"
21 [ -z "${AUTODISTDIR}" ] && AUTODISTDIR="/tmp/autodist"
22 BUILDROOT="${AUTODISTDIR}/buildroot"
23 ISOROOT="${AUTODISTDIR}/isoroot"
24 INITRDROOT="${AUTODISTDIR}/initrdroot"
25 INITRDIMG="${AUTODISTDIR}/initrdimg"
26 USRIMG="${AUTODISTDIR}/usrimg"
27 [ -z "${BUILDTARBALL}" ] && BUILDTARBALL="build-${TODAY}.tbz2"
28 [ -z "${SYSTARBALL}" ] && SYSTARBALL="sys-${TODAY}.tbz2"
29 # shouldn't allow CFLAGS to be overridden
30 export CFLAGS="-O2 -mcpu=i486 -march=i486"
31 export CXXFLAGS="${CFLAGS}"
32 export CHOST="i486-pc-linux-gnu"
33
34 [ -d "${DISTRODIR}" ] || mkdir -p "${DISTRODIR}"
35 [ -z "${CONTINUE}" ] && CONTINUE=no
36 if [ "${CONTINUE}" = "yes" ]
37 then
38 CHECK=yes
39 fi
40
41 [ -z "${ISOINITRD_PACKAGES}" ] && ISOINITRD_PACKAGES=`ls -1 ${PORTDIR}/files/isoinitrd-*.packages | sort | tail -1`
42 [ -z "${BUILD_PACKAGES}" ] && BUILD_PACKAGES=`ls -1 ${PORTDIR}/files/build-*.packages | sort | tail -1`
43 [ -z "${SYS_PACKAGES}" ] && SYS_PACKAGES=`ls -1 ${PORTDIR}/files/sys-*.packages | sort | tail -1`
44 [ -z "${KERNEL_SRC}" ] && KERNEL_SRC="/usr/src/`readlink /usr/src/linux`"
45 [ -z "${KERNEL_VERSION}" ] && KERNEL_VERSION="`echo ${KERNEL_SRC} | sed 's,.*-\([0-9]\.[0-9]\.[0-9]\+\(-ac[0-9]\+\)\?\)$,\1,'`"
46
47 [ -z "${INITRD_USE}" ] && INITRD_USE="lvm ext3"
48 # size of the initrd in kbytes
49 [ -z "${INITRD_SIZE}" ] && INITRD_SIZE=24576
50 [ -z "${INITRD_BSIZE}" ] && INITRD_BSIZE=4096
51 [ -z "${LOOPDEV}" ] && LOOPDEV=/dev/loop/0
52 # check to see if this loop device is in use
53 if losetup ${LOOPDEV} &> /dev/null
54 then
55 echo "${LOOPDEV} is in use. Please specify another loop device by"
56 echo "setting the environment variable LOOPDEV."
57 exit 1
58 fi
59
60 exec 3> ${AUTODISTDIR}/autodist.log
61
62 export PORTDIR
63 export DISTRODIR
64 export AUTODISTDIR
65
66 if grep -qs "${AUTODISTDIR}" /proc/mounts
67 then
68 cat << @@@ 1>&2
69 ${AUTODISTDIR} was found in /proc/mounts. If you have anything
70 mounted under ${AUTODISTDIR} using --bind, you should press ^C now and
71 unmount it, since ${AUTODISTDIR} is cleaned out by this script. (This
72 is probably the case if you have run this script and interrupted it
73 before it completed.) Note that this is just a safety precaution, and
74 if ${AUTODISTDIR} is a separate partition in itself, you might be OK.
75
76 Press ENTER to continue.
77 @@@
78 read
79 fi
80
81 echo ">>> Using PORTDIR=${PORTDIR}"
82 echo ">>> Using AUTODISTDIR=${AUTODISTDIR}"
83 echo ">>> Using BUILDROOT=${BUILDROOT}"
84 echo ">>> Using ISOROOT=${ISOROOT}"
85 echo ">>> Using INITRDROOT=${INITRDROOT}"
86 echo ">>> Using ISOINITRD_PACKAGES=${ISOINITRD_PACKAGES}"
87 echo ">>> Using BUILD_PACKAGES=${BUILD_PACKAGES}"
88 echo ">>> Using SYS_PACKAGES=${SYS_PACKAGES}"
89 echo ">>> Using KERNEL_SRC=${KERNEL_SRC}"
90 echo ">>> Using KERNEL_VERSION=${KERNEL_VERSION}"
91
92 if [ "${CONTINUE}" != "yes" ]
93 then
94 echo ">>> Cleaning up ${AUTODISTDIR}..."
95 rm -rf ${AUTODISTDIR}
96 fi
97
98 echo ">>> Creating ISO directory tree..."
99 mkdir -pv ${ISOROOT}/{doc,gentoo{,/distfiles,/packages{,/All}},isolinux{,/kernels},stuff}
100
101 echo ">>> Building initrd packages..."
102 mkdir -p ${INITRDROOT}
103 ERRQUIT=yes CHECK="${CHECK}" USE="${INITRD_USE}" ROOT="${INITRDROOT}" STEPS="clean unpack compile install qmerge clean" ${PORTDIR}/scripts/autocompile.sh ${ISOINITRD_PACKAGES}
104 if [ ${?} != 0 ]
105 then
106 echo "Error building initrd packages, quitting"
107 exit 1
108 fi
109 echo ">>> Cleaning up ${INITRDROOT}/tmp"
110 rm -rf ${INITRDROOT}/tmp
111 mkdir -p ${INITRDROOT}/tmp
112 chown root.root ${INITRDROOT}/tmp
113 chmod 1777 ${INITRDROOT}/tmp
114
115 echo ">>> Setting up initrd..."
116 find ${INITRDROOT}/etc -name "*._cfg_*" -exec rm -vf {} \;
117 ROOT=${INITRDROOT} rc-update autogen boot force
118 ROOT=${INITRDROOT} rc-update autogen normal force
119 ROOT=${INITRDROOT} rc-update autogen halt force
120
121 echo ">>> Creating initrd.img..."
122 # /usr goes in its own image
123 if [ "${CONTINUE}" != "yes" ] || [ ! -d ${AUTODISTDIR}/initrdusr ]
124 then
125 mv ${INITRDROOT}/usr ${AUTODISTDIR}/initrdusr
126 mkdir ${INITRDROOT}/usr
127 fi
128
129 runlog dd if=/dev/zero of=${AUTODISTDIR}/initrd.img bs=${INITRD_SIZE} count=1024
130 runlog losetup ${LOOPDEV} ${AUTODISTDIR}/initrd.img
131 runlog mke2fs ${LOOPDEV}
132 mkdir -p ${INITRDIMG}
133 runlog mount ${LOOPDEV} ${INITRDIMG}
134 cd ${INITRDROOT}
135 # cpio is best for this kinda thing
136 echo -n ">>> Copying files"
137 find . -print0 | cpio -p -0dm --quiet --dot ${INITRDIMG}
138 echo
139 umount ${INITRDIMG}
140 runlog losetup -d ${LOOPDEV}
141 echo ">>> Compressing initrd..."
142 gzip -9 ${AUTODISTDIR}/initrd.img
143 mv -f ${AUTODISTDIR}/initrd.img.gz ${AUTODISTDIR}/initrd.img
144
145 echo ">>> Creating usr.img..."
146 usrsize=`du -sk ${AUTODISTDIR}/initrdusr | sed 's,\([0-9]\+\).*,\1,'`
147 # it doesn't hurt to pad it a bit :)
148 usrsize=`expr ${usrsize} + 256`
149 # lets make it an even multiple of INITRD_BSIZE bytes
150 bsizek=`expr ${INITRD_BSIZE} / 1024`
151 usrsize=`expr ${usrsize} / ${bsizek}`
152 usrsize=`expr ${usrsize} + 1`
153 runlog dd if=/dev/zero of=${AUTODISTDIR}/usr.img bs=${INITRD_BSIZE} count=${usrsize}
154 mkdir -p ${AUTODISTDIR}/initrdusrimg
155 runlog losetup ${LOOPDEV} ${AUTODISTDIR}/usr.img
156 runlog mke2fs ${LOOPDEV}
157 runlog mount ${LOOPDEV} ${AUTODISTDIR}/initrdusrimg
158 cd ${AUTODISTDIR}/initrdusr
159 # cpio is best for this kinda thing
160 echo -n ">>> Copying files"
161 find . -print0 | cpio -p -0dm --quiet --dot ${AUTODISTDIR}/initrdusrimg
162 echo
163 runlog umount ${AUTODISTDIR}/initrdusrimg
164 runlog losetup -d ${LOOPDEV}
165 echo ">>> Compressing usr.img..."
166 create_compressed_fs ${AUTODISTDIR}/usr.img 65536 > ${AUTODISTDIR}/usr.img.compressed 2>&3
167 mv ${AUTODISTDIR}/usr.img.compressed ${AUTODISTDIR}/usr.img

  ViewVC Help
Powered by ViewVC 1.1.20