591a87836cce9293b5fd47ec9cd38c94efe2e2ed
3 # mk-basefile, create basefiles for some distributions
5 # Thomas Lange, Uni Koeln, 2011-2015
6 # based on the Makefile implementation of Michael Goetze
8 # Usage example: fai-mk-basefile -J SQUEEZE64
9 # This will create a SQUEEZE64.tar.xz basefile.
11 # Supported distributions (each i386/amd64):
15 # Scientific Linux Cern 5/6
17 # Packages you might want to install to use this command:
18 # debootstrap, rinse, xz-utils
21 # Define your local mirros here
22 # For the first stage, set the CentOS/SLC mirror in /etc/rinse/rinse.conf
23 MIRROR_DEBIAN
=http
://httpredir.debian.org
/debian
/
24 MIRROR_DEBIAN
=http
://localmirror
/debian
/
25 MIRROR_UBUNTU
=http
://mirror.netcologne.de
/ubuntu
/
26 MIRROR_CENTOS
=http
://mirror.netcologne.de
/
27 #MIRROR_CENTOS=http://localmirror
28 #MIRROR_SLC=http://localmirror
30 EXCLUDE_SQUEEZE
=isc-dhcp-client
,isc-dhcp-common
,info
,tasksel
,tasksel-data
31 EXCLUDE_WHEEZY
=isc-dhcp-client
,isc-dhcp-common
,info
,tasksel
,tasksel-data
32 EXCLUDE_JESSIE
=isc-dhcp-client
,isc-dhcp-common
,info
,tasksel
,tasksel-data
33 EXCLUDE_TRUSTY
=dhcp3-client
,dhcp3-common
,info
34 EXCLUDE_XENIAL
=isc-dhcp-client
,isc-dhcp-common
,udhcpc
,dibbler-client
,dhcpcd5
,info
,tasksel
,tasksel-data
36 INCLUDE_DEBIAN
=aptitude
42 if [ X
$1 = Xi386
]; then
49 if [ `id -u` != 0 ]; then
50 echo "You must be root to create chroots."
53 mknod
$xtmp/test-dev-null c
1 3
55 echo "Cannot create device files on $xtmp, aborting."
56 echo "Perhaps this directory is mounted with option nodev."
60 echo test > $xtmp/test-dev-null
62 echo "Cannot create device files on $xtmp, aborting."
63 echo "Perhaps this directory is mounted with option nodev."
67 rm -f $xtmp/test-dev-null
73 [ -z "$MIRROR_CENTOS" ] && return
74 cat <<EOM > $xtmp/post
76 mkdir -p $xtmp/etc/yum.repos.d/orig
77 cp -p $xtmp/etc/yum.repos.d/*.repo $xtmp/etc/yum.repos.d/orig
78 perl -pi -e 's,mirrorlist=,#mirrorlist=,; s,#baseurl=http://mirror.centos.org,baseurl=$MIRROR_CENTOS,;' $xtmp/etc/yum.repos.d/CentOS-Base.repo
87 [ -z "$MIRROR_SLC" ] && return
88 cat <<EOM > $xtmp/post
90 mkdir -p $xtmp/etc/yum.repos.d/orig
91 cp -p $xtmp/etc/yum.repos.d/*.repo $xtmp/etc/yum.repos.d/orig
92 perl -pi -e 's,baseurl=http://linuxsoft.cern.ch,baseurl=$MIRROR_SLC,;' $xtmp/etc/yum.repos.d/slc$ver-os.repo
93 perl -pi -e 's,baseurl=http://linuxsoft.cern.ch,baseurl=$MIRROR_SLC,;' $xtmp/etc/yum.repos.d/slc$ver-updates.repo
102 chroot
$xtmp aptitude clean
103 rm -f $xtmp/etc
/hostname
$xtmp/etc
/resolv.conf
$xtmp/etc
/machine-id
104 rm $xtmp/var
/lib
/apt
/lists
/*_
*
105 rm -f $xtmp/etc
/udev
/rules.d
/70-persistent-net.rules
111 # check if chroot works
112 echo "Installed packages in chroot:"
113 chroot
$xtmp rpm
-qa|
sort
114 echo -n "CHROOT rpm -qa: "
115 chroot
$xtmp rpm
-qa|
wc -l
117 rm -f $xtmp/etc
/resolv.conf
$xtmp/post
118 if [ -d $xtmp/etc
/yum.repos.d
/orig
]; then
119 mv $xtmp/etc
/yum.repos.d
/orig
/* $xtmp/etc
/yum.repos.d
/
120 rm -rf $xtmp/etc
/yum.repos.d
/orig
127 tar --xattrs --selinux --acl --one-file-system -C $xtmp -cf - . |
$zip > $target.
$ext
135 local domain
=$
(domainname
)
140 $l32 rinse
--directory $xtmp --distribution centos-
$vers --arch $arch --before-post-install $xtmp/post
141 domainname
$domain # workaround for #613377
155 $l32 rinse
--directory $xtmp --distribution slc-
$vers --arch $arch --before-post-install $xtmp/post
166 debootstrap
--arch $arch --exclude=${EXCLUDE_SQUEEZE} squeeze
$xtmp ${MIRROR_DEBIAN}
176 debootstrap
--arch $arch --exclude=${EXCLUDE_WHEEZY} wheezy
$xtmp ${MIRROR_DEBIAN}
186 debootstrap
--arch $arch --exclude=${EXCLUDE_JESSIE} --include=${INCLUDE_DEBIAN} jessie $xtmp ${MIRROR_DEBIAN}
196 debootstrap
--arch $arch --exclude=${EXCLUDE_TRUSTY} --include=${INCLUDE_DEBIAN} trusty $xtmp ${MIRROR_UBUNTU}
206 debootstrap
--arch $arch --exclude=${EXCLUDE_XENIAL} --include=${INCLUDE_DEBIAN} xenial $xtmp ${MIRROR_UBUNTU}
214 echo "Unknown distribution. Aborting."
217 CENTOS5_32 CENTOS5_64
218 CENTOS6_32 CENTOS6_64
219 CENTOS7_32 CENTOS7_64
239 while getopts zJd
: opt
; do
242 z
) zip="gzip -9"; ext
=tar.gz
;;
243 J
) zip="xz -8" ext
=tar.xz
;;
246 shift $
(($OPTIND - 1))
248 xtmp
=$
(mktemp
-d $tmpdir/basefiles.XXXXXXXX
)
249 if [ $?
-eq 1 ]; then
250 echo "mktemp failed. Aborting."
254 target
=$1 # also the name of the output file
257 CENTOS5_32
) centos i386
5 ;;
258 CENTOS5_64
) centos amd64
5 ;;
259 CENTOS6_32
) centos i386
6 ;;
260 CENTOS6_64
) centos amd64
6 ;;
261 CENTOS7_32
) centos i386
7 ;;
262 CENTOS7_64
) centos amd64
7 ;;
263 SLC5_32
) slc i386
5 ;;
264 SLC5_64
) slc amd64
5 ;;
265 SLC6_32
) slc i386
6 ;;
266 SLC6_64
) slc amd64
6 ;;
267 SLC7_64
) slc amd64
7 ;;
268 TRUSTY32
) trusty i386
;;
269 TRUSTY64
) trusty amd64
;;
270 XENIAL32
) xenial i386
;;
271 XENIAL64
) xenial amd64
;;
272 SQUEEZE32
) squeeze i386
;;
273 SQUEEZE64
) squeeze amd64
;;
274 WHEEZY32
) wheezy i386
;;
275 WHEEZY64
) wheezy amd64
;;
276 JESSIE32
) jessie i386
;;
277 JESSIE64
) jessie amd64
;;