source: trunk/packages/xen-3.1/xen-3.1/tools/misc/xen-clone @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

  • Property svn:executable set to *
File size: 3.3 KB
Line 
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
11case "$SITE" in
12UCCL)
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;;
20esac
21
22DEST_DIR=${2:-xeno-clone}
23DEST_BK_REP=`basename "${BK_REP}"`
24DEST_VER=`basename ${DEST_BK_REP} .hg`
25
26echo usage: xen-clone hg dest_dir orig_linux_dir
27echo Source BK Repository : ${BK_REP}
28echo Destination Dir/Repository : ${DEST_DIR}/${DEST_BK_REP}
29echo Pristine Linux Source directory : ${LINUX_DIR}
30
31mkdir -p ${DEST_DIR}
32cd ${DEST_DIR}
33TOP=`/bin/pwd`
34
35# site-specific set up of installation directories
36case "$SITE" in
37UCCL)
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        ;;
50esac
51
52# clone the master repository (now checked-out by default)
53if [ ! -d ${DEST_BK_REP} ] 
54then
55mkdir -p ${DEST_BK_REP} ; cd ${DEST_BK_REP} ; hg init ${BK_REP} ; hg co ; cd ${TOP}
56else
57cd ${DEST_BK_REP}
58hg pull ; hg co
59cd ${TOP}
60fi
61
62
63if [ -d ${DEST_BK_REP}/linux-2.4*-xen-sparse ]
64then
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
91else
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
133fi
134
Note: See TracBrowser for help on using the repository browser.