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
35 INCLUDE_DEBIAN
=aptitude
41 if [ X
$1 = Xi386
]; then
48 if [ `id -u` != 0 ]; then
49 echo "You must be root to create chroots."
52 mknod
$xtmp/test-dev-null c
1 3
54 echo "Cannot create device files on $xtmp, aborting."
55 echo "Perhaps this directory is mounted with option nodev."
59 echo test > $xtmp/test-dev-null
61 echo "Cannot create device files on $xtmp, aborting."
62 echo "Perhaps this directory is mounted with option nodev."
66 rm -f $xtmp/test-dev-null
72 [ -z "$MIRROR_CENTOS" ] && return
73 cat <<EOM > $xtmp/post
75 mkdir -p $xtmp/etc/yum.repos.d/orig
76 cp -p $xtmp/etc/yum.repos.d/*.repo $xtmp/etc/yum.repos.d/orig
77 perl -pi -e 's,mirrorlist=,#mirrorlist=,; s,#baseurl=http://mirror.centos.org,baseurl=$MIRROR_CENTOS,;' $xtmp/etc/yum.repos.d/CentOS-Base.repo
86 [ -z "$MIRROR_SLC" ] && return
87 cat <<EOM > $xtmp/post
89 mkdir -p $xtmp/etc/yum.repos.d/orig
90 cp -p $xtmp/etc/yum.repos.d/*.repo $xtmp/etc/yum.repos.d/orig
91 perl -pi -e 's,baseurl=http://linuxsoft.cern.ch,baseurl=$MIRROR_SLC,;' $xtmp/etc/yum.repos.d/slc$ver-os.repo
92 perl -pi -e 's,baseurl=http://linuxsoft.cern.ch,baseurl=$MIRROR_SLC,;' $xtmp/etc/yum.repos.d/slc$ver-updates.repo
101 chroot
$xtmp aptitude clean
102 rm -f $xtmp/etc
/hostname
$xtmp/etc
/resolv.conf
$xtmp/etc
/machine-id
103 rm $xtmp/var
/lib
/apt
/lists
/*_
*
104 rm -f $xtmp/etc
/udev
/rules.d
/70-persistent-net.rules
110 # check if chroot works
111 echo "Installed packages in chroot:"
112 chroot
$xtmp rpm
-qa|
sort
113 echo -n "CHROOT rpm -qa: "
114 chroot
$xtmp rpm
-qa|
wc -l
116 rm -f $xtmp/etc
/resolv.conf
$xtmp/post
117 if [ -d $xtmp/etc
/yum.repos.d
/orig
]; then
118 mv $xtmp/etc
/yum.repos.d
/orig
/* $xtmp/etc
/yum.repos.d
/
119 rm -rf $xtmp/etc
/yum.repos.d
/orig
126 tar --xattrs --selinux --acl --one-file-system -C $xtmp -cf - . |
$zip > $target.
$ext
134 local domain
=$
(domainname
)
139 $l32 rinse
--directory $xtmp --distribution centos-
$vers --arch $arch --before-post-install $xtmp/post
140 domainname
$domain # workaround for #613377
154 $l32 rinse
--directory $xtmp --distribution slc-
$vers --arch $arch --before-post-install $xtmp/post
165 debootstrap
--arch $arch --exclude=${EXCLUDE_SQUEEZE} squeeze
$xtmp ${MIRROR_DEBIAN}
175 debootstrap
--arch $arch --exclude=${EXCLUDE_WHEEZY} wheezy
$xtmp ${MIRROR_DEBIAN}
185 debootstrap
--arch $arch --exclude=${EXCLUDE_JESSIE} --include=${INCLUDE_DEBIAN} jessie $xtmp ${MIRROR_DEBIAN}
195 debootstrap
--arch $arch --exclude=${EXCLUDE_TRUSTY} --include=${INCLUDE_DEBIAN} trusty $xtmp ${MIRROR_UBUNTU}
203 echo "Unknown distribution. Aborting."
206 CENTOS5_32 CENTOS5_64
207 CENTOS6_32 CENTOS6_64
208 CENTOS7_32 CENTOS7_64
226 while getopts zJd
: opt
; do
229 z
) zip="gzip -9"; ext
=tar.gz
;;
230 J
) zip="xz -8" ext
=tar.xz
;;
233 shift $
(($OPTIND - 1))
235 xtmp
=$
(mktemp
-d $tmpdir/basefiles.XXXXXXXX
)
236 if [ $?
-eq 1 ]; then
237 echo "mktemp failed. Aborting."
241 target
=$1 # also the name of the output file
244 CENTOS5_32
) centos i386
5 ;;
245 CENTOS5_64
) centos amd64
5 ;;
246 CENTOS6_32
) centos i386
6 ;;
247 CENTOS6_64
) centos amd64
6 ;;
248 CENTOS7_32
) centos i386
7 ;;
249 CENTOS7_64
) centos amd64
7 ;;
250 SLC5_32
) slc i386
5 ;;
251 SLC5_64
) slc amd64
5 ;;
252 SLC6_32
) slc i386
6 ;;
253 SLC6_64
) slc amd64
6 ;;
254 TRUSTY32
) trusty i386
;;
255 TRUSTY64
) trusty amd64
;;
256 SQUEEZE32
) squeeze i386
;;
257 SQUEEZE64
) squeeze amd64
;;
258 WHEEZY32
) wheezy i386
;;
259 WHEEZY64
) wheezy amd64
;;
260 JESSIE32
) jessie i386
;;
261 JESSIE64
) jessie amd64
;;