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
://http.us.debian.org
/debian
24 #MIRROR_DEBIAN=http://localmirror/debian/
25 MIRROR_UBUNTU
=http
://mirror.netcologne.de
/ubuntu
/
26 MIRROR_TRISQUEL
=http
://mirror.fsf.org
/trisquel
/
27 MIRROR_CENTOS
=http
://mirror.netcologne.de
/
28 #MIRROR_CENTOS=http://localmirror
29 #MIRROR_SLC=http://localmirror
31 EXCLUDE_SQUEEZE
=isc-dhcp-client
,isc-dhcp-common
,info
,tasksel
,tasksel-data
32 EXCLUDE_WHEEZY
=isc-dhcp-client
,isc-dhcp-common
,info
,tasksel
,tasksel-data
33 EXCLUDE_JESSIE
=isc-dhcp-client
,isc-dhcp-common
,info
,tasksel
,tasksel-data
34 EXCLUDE_BELENOS
=dhcp3-client
,dhcp3-common
,info
35 EXCLUDE_TRUSTY
=dhcp3-client
,dhcp3-common
,info
36 EXCLUDE_XENIAL
=isc-dhcp-client
,isc-dhcp-common
,udhcpc
,dibbler-client
,dhcpcd5
,info
,tasksel
,tasksel-data
38 INCLUDE_DEBIAN
=aptitude
44 if [ X
$1 = Xi386
]; then
51 if [ `id -u` != 0 ]; then
52 echo "You must be root to create chroots."
55 mknod
$xtmp/test-dev-null c
1 3
57 echo "Cannot create device files on $xtmp, aborting."
58 echo "Perhaps this directory is mounted with option nodev."
62 echo test > $xtmp/test-dev-null
64 echo "Cannot create device files on $xtmp, aborting."
65 echo "Perhaps this directory is mounted with option nodev."
69 rm -f $xtmp/test-dev-null
75 [ -z "$MIRROR_CENTOS" ] && return
76 cat <<EOM > $xtmp/post
78 mkdir -p $xtmp/etc/yum.repos.d/orig
79 cp -p $xtmp/etc/yum.repos.d/*.repo $xtmp/etc/yum.repos.d/orig
80 perl -pi -e 's,mirrorlist=,#mirrorlist=,; s,#baseurl=http://mirror.centos.org,baseurl=$MIRROR_CENTOS,;' $xtmp/etc/yum.repos.d/CentOS-Base.repo
89 [ -z "$MIRROR_SLC" ] && return
90 cat <<EOM > $xtmp/post
92 mkdir -p $xtmp/etc/yum.repos.d/orig
93 cp -p $xtmp/etc/yum.repos.d/*.repo $xtmp/etc/yum.repos.d/orig
94 perl -pi -e 's,baseurl=http://linuxsoft.cern.ch,baseurl=$MIRROR_SLC,;' $xtmp/etc/yum.repos.d/slc$ver-os.repo
95 perl -pi -e 's,baseurl=http://linuxsoft.cern.ch,baseurl=$MIRROR_SLC,;' $xtmp/etc/yum.repos.d/slc$ver-updates.repo
104 chroot
$xtmp aptitude clean
105 rm -f $xtmp/etc
/hostname
$xtmp/etc
/resolv.conf
$xtmp/etc
/machine-id
106 rm $xtmp/var
/lib
/apt
/lists
/*_
*
107 rm -f $xtmp/etc
/udev
/rules.d
/70-persistent-net.rules
113 # check if chroot works
114 echo "Installed packages in chroot:"
115 chroot
$xtmp rpm
-qa|
sort
116 echo -n "CHROOT rpm -qa: "
117 chroot
$xtmp rpm
-qa|
wc -l
119 rm -f $xtmp/etc
/resolv.conf
$xtmp/post
120 if [ -d $xtmp/etc
/yum.repos.d
/orig
]; then
121 mv $xtmp/etc
/yum.repos.d
/orig
/* $xtmp/etc
/yum.repos.d
/
122 rm -rf $xtmp/etc
/yum.repos.d
/orig
129 tar --xattrs --selinux --acl --one-file-system -C $xtmp -cf - . |
$zip > $target.
$ext
137 local domain
=$
(domainname
)
142 $l32 rinse
--directory $xtmp --distribution centos-
$vers --arch $arch --before-post-install $xtmp/post
143 domainname
$domain # workaround for #613377
157 $l32 rinse
--directory $xtmp --distribution slc-
$vers --arch $arch --before-post-install $xtmp/post
168 debootstrap
--arch $arch --exclude=${EXCLUDE_SQUEEZE} squeeze
$xtmp ${MIRROR_DEBIAN}
178 debootstrap
--arch $arch --exclude=${EXCLUDE_WHEEZY} wheezy
$xtmp ${MIRROR_DEBIAN}
188 debootstrap
--arch $arch --exclude=${EXCLUDE_JESSIE} --include=${INCLUDE_DEBIAN} jessie $xtmp ${MIRROR_DEBIAN}
198 debootstrap
--arch $arch --exclude=${EXCLUDE_JESSIE} --include=${INCLUDE_DEBIAN} stretch $xtmp ${MIRROR_DEBIAN}
208 debootstrap
--arch $arch --exclude=${EXCLUDE_TRUSTY} --include=${INCLUDE_DEBIAN} trusty $xtmp ${MIRROR_UBUNTU}
218 debootstrap
--arch $arch --exclude=${EXCLUDE_XENIAL} --include=${INCLUDE_DEBIAN} xenial $xtmp ${MIRROR_UBUNTU}
225 ln -sf gutsy
/usr
/share
/debootstrap
/scripts
/belenos
229 debootstrap
--arch $arch --exclude=${EXCLUDE_BELENOS} --include=${INCLUDE_DEBIAN} belenos $xtmp ${MIRROR_TRISQUEL}
236 echo "Unknown distribution. Aborting."
239 CENTOS5_32 CENTOS5_64
240 CENTOS6_32 CENTOS6_64
241 CENTOS7_32 CENTOS7_64
261 while getopts zJd
: opt
; do
264 z
) zip="gzip -9"; ext
=tar.gz
;;
265 J
) zip="xz -8" ext
=tar.xz
;;
268 shift $
(($OPTIND - 1))
270 xtmp
=$
(mktemp
-d $tmpdir/basefiles.XXXXXXXX
)
271 if [ $?
-eq 1 ]; then
272 echo "mktemp failed. Aborting."
276 target
=$1 # also the name of the output file
279 CENTOS5_32
) centos i386
5 ;;
280 CENTOS5_64
) centos amd64
5 ;;
281 CENTOS6_32
) centos i386
6 ;;
282 CENTOS6_64
) centos amd64
6 ;;
283 CENTOS7_32
) centos i386
7 ;;
284 CENTOS7_64
) centos amd64
7 ;;
285 SLC5_32
) slc i386
5 ;;
286 SLC5_64
) slc amd64
5 ;;
287 SLC6_32
) slc i386
6 ;;
288 SLC6_64
) slc amd64
6 ;;
289 SLC7_64
) slc amd64
7 ;;
290 TRUSTY32
) trusty i386
;;
291 TRUSTY64
) trusty amd64
;;
292 BELENOS64
) belenos amd64
;;
293 XENIAL32
) xenial i386
;;
294 XENIAL64
) xenial amd64
;;
295 SQUEEZE32
) squeeze i386
;;
296 SQUEEZE64
) squeeze amd64
;;
297 WHEEZY32
) wheezy i386
;;
298 WHEEZY64
) wheezy amd64
;;
299 JESSIE32
) jessie i386
;;
300 JESSIE64
) jessie amd64
;;
301 STRETCH64
) stretch amd64
;;