X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vbuild-init-lxc.sh;h=561be5e8e774cf9c8d69e2daf89b0264de5845b6;hb=f55645814274165797c466ed5bd978ea73be1f7e;hp=f972e2d4b9efa6932698b14757d3969b925974de;hpb=d39d390f3b5ac457d6526be7113418bf0d801200;p=build.git diff --git a/vbuild-init-lxc.sh b/vbuild-init-lxc.sh index f972e2d4..561be5e8 100755 --- a/vbuild-init-lxc.sh +++ b/vbuild-init-lxc.sh @@ -65,7 +65,7 @@ function bridge_init () { address=$(/sbin/ip addr show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $2;}') [ -z "$address" ] && { echo "ERROR: Could not determine IP address for $INTERFACE_LAN" ; exit 1 ; } -broadcast=$(/sbin/ip addr show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $4;}') + broadcast=$(/sbin/ip addr show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $4;}') [ -z "$broadcast" ] && echo "WARNING: Could not determine broadcast address for $INTERFACE_LAN" gateway=$(netstat -rn | grep '^0.0.0.0' | awk '{print $2;}') @@ -242,12 +242,18 @@ function configure_fedora_init() { sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit + # don't mount devpts, for pete's sake + sed -i 's/^.*dev.pts.*$/#\0/' ${rootfs_path}/etc/rc.sysinit + sed -i 's/^.*dev.pts.*$/#\0/' ${rootfs_path}/etc/rc.d/rc.sysinit chroot ${rootfs_path} /sbin/chkconfig udev-post off chroot ${rootfs_path} /sbin/chkconfig network on } - +# this code of course is for guests that do run on systemd function configure_fedora_systemd() { + # so ignore if we can't find /etc/systemd at all + [ -d ${rootfs_path}/etc/systemd ] || return 0 + # otherwise let's proceed unlink ${rootfs_path}/etc/systemd/system/default.target ln -s /lib/systemd/system/multi-user.target ${rootfs_path}/etc/systemd/system/default.target touch ${rootfs_path}/etc/fstab @@ -270,18 +276,31 @@ set -x # check the mini fedora was not already downloaded INSTALL_ROOT=$cache/partial echo $INSTALL_ROOT + + # download a mini fedora into a cache + echo "Downloading fedora minimal ..." + mkdir -p $INSTALL_ROOT if [ $? -ne 0 ]; then echo "Failed to create '$INSTALL_ROOT' directory" return 1 fi - # download a mini fedora into a cache - echo "Downloading fedora minimal ..." - YUM="yum --installroot $INSTALL_ROOT -y --nogpgcheck --releasever=$release" - PKG_LIST="yum initscripts passwd rsyslog vim-minimal dhclient chkconfig rootfiles policycoreutils openssh-server openssh-clients" - - + mkdir -p $INSTALL_ROOT/etc/yum.repos.d + mkdir -p $INSTALL_ROOT/dev + mknod -m 0444 $INSTALL_ROOT/dev/random c 1 8 + mknod -m 0444 $INSTALL_ROOT/dev/urandom c 1 9 + + # copy yum config and repo files + cp /etc/yum.conf $INSTALL_ROOT/etc/ + cp /etc/yum.repos.d/fedora* $INSTALL_ROOT/etc/yum.repos.d/ + + # append fedora repo files with desired $release and $basearch + for f in $INSTALL_ROOT/etc/yum.repos.d/* + do + sed -i "s/\$basearch/$arch/g; s/\$releasever/$release/g;" $f + done + MIRROR_URL=http://mirror.onelab.eu/fedora/releases/$release/Everything/$arch/os RELEASE_URL1="$MIRROR_URL/Packages/fedora-release-$release-1.noarch.rpm" # with fedora18 the rpms are scattered by first name @@ -312,6 +331,9 @@ set -x # http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=cf1095648194104a81a58abead05974a5bfa3b9a # So ideally if we want to be able to build f12 images from f18 we need an rpm that has # this patch undone, like we have in place on our f14 boxes (our f14 boxes need a f18-like rpm) + + YUM="yum --installroot=$INSTALL_ROOT --nogpgcheck -y" + PKG_LIST="yum initscripts passwd rsyslog vim-minimal dhclient chkconfig rootfiles policycoreutils openssh-server openssh-clients" echo "$YUM install $PKG_LIST" $YUM install $PKG_LIST @@ -458,16 +480,16 @@ function configure_yum_in_lxc () { cat > $rootfs_path/etc/yum.repos.d/building.repo </dev/null 2>&1 - if [ $? -ne 0 ]; then + if [ "$(echo $fcdistro | cut -d"f" -f2)" -le "14" ]; then configure_fedora_init else configure_fedora_systemd @@ -587,7 +608,7 @@ function setup_lxc() { $lxc 524288 - exe + exe /sbin/init @@ -914,7 +935,7 @@ function main () { if [ "$personality" == "linux32" ]; then arch=i386 - arch2=x86 + arch2=i686 elif [ "$personality" == "linux64" ]; then arch=x86_64 arch2=x86_64