| 1 | #!/bin/sh -x |
|---|
| 2 | |
|---|
| 3 | # usage: xen-clone hg_repository dest_dir orig_linux_dir |
|---|
| 4 | # |
|---|
| 5 | # this script contains some CL site specific details, but can easily be adapted |
|---|
| 6 | # |
|---|
| 7 | |
|---|
| 8 | # test which site we're on |
|---|
| 9 | [ -d /usr/groups/xeno/ -a -d /usr/groups/srgboot ] && SITE=UCCL |
|---|
| 10 | |
|---|
| 11 | case "$SITE" in |
|---|
| 12 | UCCL) |
|---|
| 13 | BK_REP=${1:-http://hg.srg.cl.cam.ac.uk/xen-unstable.hg} |
|---|
| 14 | LINUX_DIR=${3:-/usr/groups/xeno/archive/} |
|---|
| 15 | ;; |
|---|
| 16 | *) |
|---|
| 17 | BK_REP=${1:-http://xenbits.xensource.com/xen-unstable.hg} |
|---|
| 18 | LINUX_DIR=${3:-.:..} |
|---|
| 19 | ;; |
|---|
| 20 | esac |
|---|
| 21 | |
|---|
| 22 | DEST_DIR=${2:-xeno-clone} |
|---|
| 23 | DEST_BK_REP=`basename "${BK_REP}"` |
|---|
| 24 | DEST_VER=`basename ${DEST_BK_REP} .hg` |
|---|
| 25 | |
|---|
| 26 | echo usage: xen-clone hg dest_dir orig_linux_dir |
|---|
| 27 | echo Source BK Repository : ${BK_REP} |
|---|
| 28 | echo Destination Dir/Repository : ${DEST_DIR}/${DEST_BK_REP} |
|---|
| 29 | echo Pristine Linux Source directory : ${LINUX_DIR} |
|---|
| 30 | |
|---|
| 31 | mkdir -p ${DEST_DIR} |
|---|
| 32 | cd ${DEST_DIR} |
|---|
| 33 | TOP=`/bin/pwd` |
|---|
| 34 | |
|---|
| 35 | # site-specific set up of installation directories |
|---|
| 36 | case "$SITE" in |
|---|
| 37 | UCCL) |
|---|
| 38 | PATH=$PATH:/usr/groups/xeno/build_tools/bin |
|---|
| 39 | mkdir -p install/boot |
|---|
| 40 | cd install/boot |
|---|
| 41 | ln -sf ../../../xeno-roots/roots . |
|---|
| 42 | ln -sf ../../../xeno-roots/usr . |
|---|
| 43 | ln -sf ../lib . |
|---|
| 44 | ln -sf ../bin . |
|---|
| 45 | ln -sf /usr/groups/srgboot/${USER}/xenoboot.sh . |
|---|
| 46 | ln -sf `pwd` /usr/groups/srgboot/${USER}/${DEST_DIR} |
|---|
| 47 | ln -sf xen.gz image.gz |
|---|
| 48 | cd ../.. |
|---|
| 49 | ;; |
|---|
| 50 | esac |
|---|
| 51 | |
|---|
| 52 | # clone the master repository (now checked-out by default) |
|---|
| 53 | if [ ! -d ${DEST_BK_REP} ] |
|---|
| 54 | then |
|---|
| 55 | mkdir -p ${DEST_BK_REP} ; cd ${DEST_BK_REP} ; hg init ${BK_REP} ; hg co ; cd ${TOP} |
|---|
| 56 | else |
|---|
| 57 | cd ${DEST_BK_REP} |
|---|
| 58 | hg pull ; hg co |
|---|
| 59 | cd ${TOP} |
|---|
| 60 | fi |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | if [ -d ${DEST_BK_REP}/linux-2.4*-xen-sparse ] |
|---|
| 64 | then |
|---|
| 65 | # this is a new style Xen repository so building is dead easy |
|---|
| 66 | |
|---|
| 67 | export LINUX_SRC_PATH=${LINUX_DIR} |
|---|
| 68 | |
|---|
| 69 | cd ${DEST_BK_REP} |
|---|
| 70 | |
|---|
| 71 | # Recent repositories install into 'dist/install' rather than 'install'. |
|---|
| 72 | if [ -f install.sh ] |
|---|
| 73 | then |
|---|
| 74 | mkdir -p dist |
|---|
| 75 | ln -sf ../../install dist/install |
|---|
| 76 | else |
|---|
| 77 | ln -sf ../install install |
|---|
| 78 | fi |
|---|
| 79 | |
|---|
| 80 | make -j4 KERNELS=linux-* world |
|---|
| 81 | #make -j4 linux24 |
|---|
| 82 | cd ../install/boot |
|---|
| 83 | if [ -r vmlinuz-2.6-xen0 ] |
|---|
| 84 | then |
|---|
| 85 | ln -s vmlinuz-2.6-xen0 xenolinux.gz |
|---|
| 86 | else |
|---|
| 87 | kern=`ls vmlinuz-2.6.*-xen0 | head -1` |
|---|
| 88 | [ -r "$kern" ] && ln -s "$kern" xenolinux.gz |
|---|
| 89 | fi |
|---|
| 90 | |
|---|
| 91 | else |
|---|
| 92 | # old style repository without 'make world' |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | # identify this version of linux |
|---|
| 96 | LINUX_VER=`( /bin/ls -ld ${DEST_BK_REP}/*xenolinux-sparse || /bin/ls -ld ${DEST_BK_REP}/*xenolinux-*-sparse ) 2>/dev/null | sed -e 's!^.*xenolinux-\(.\+\)-sparse!\1!'` |
|---|
| 97 | |
|---|
| 98 | if [ -z "${LINUX_VER}" ] |
|---|
| 99 | then |
|---|
| 100 | echo Unable to identify Linux version. Bailing. |
|---|
| 101 | exit -1 |
|---|
| 102 | fi |
|---|
| 103 | |
|---|
| 104 | # copy in the master Linux tree for this kernel |
|---|
| 105 | if [ ! -d linux-${LINUX_VER} ] |
|---|
| 106 | then |
|---|
| 107 | tar -jxf ${LINUX_DIR}/linux-${LINUX_VER}.tar.bz2 || tar -zxf ${LINUX_DIR}/linux-${LINUX_VER}.tar.gz || tar -zxf ${LINUX_DIR}/linux-${LINUX_VER}.tgz || cp -a ${LINUX_DIR}/linux-${LINUX_VER} . || wget ftp://ftp.kernel.org/pub/linux/kernel/v2.4/linux-${LINUX_VER}.tar.gz -O- | tar -zxf - || exit -1 |
|---|
| 108 | fi |
|---|
| 109 | |
|---|
| 110 | # build and install Xen and tools |
|---|
| 111 | cd ${DEST_BK_REP} |
|---|
| 112 | make dist || make install |
|---|
| 113 | |
|---|
| 114 | # Turn linux into xenolinux then build it |
|---|
| 115 | cd xenolinux-${LINUX_VER}-sparse |
|---|
| 116 | bash ./mkbuildtree ../../linux-${LINUX_VER} |
|---|
| 117 | cd ../.. |
|---|
| 118 | mv linux-${LINUX_VER} xenolinux-${LINUX_VER} |
|---|
| 119 | cd xenolinux-${LINUX_VER} |
|---|
| 120 | |
|---|
| 121 | # cope with the change from ARCH=xeno to ARCH=xen |
|---|
| 122 | cd arch; XEN=`/bin/ls -d xen*`; cd .. |
|---|
| 123 | |
|---|
| 124 | # built it all |
|---|
| 125 | ARCH=$XEN make oldconfig |
|---|
| 126 | ARCH=$XEN make dep |
|---|
| 127 | ARCH=$XEN make bzImage |
|---|
| 128 | ARCH=$XEN make dist || ARCH=xen make install |
|---|
| 129 | ARCH=$XEN make modules |
|---|
| 130 | ARCH=$XEN make INSTALL_MOD_PATH=${TOP}/install modules_install |
|---|
| 131 | cd .. |
|---|
| 132 | |
|---|
| 133 | fi |
|---|
| 134 | |
|---|