Merge "Initial centos7 support"
This commit is contained in:
commit
673f6aae9f
3
elements/centos7/README.md
Normal file
3
elements/centos7/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Use Centos 7 cloud images as the baseline for built disk images.
|
||||||
|
|
||||||
|
For further details see the redhat-common README.
|
6
elements/centos7/element-deps
Normal file
6
elements/centos7/element-deps
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
cache-url
|
||||||
|
dib-run-parts
|
||||||
|
redhat-common
|
||||||
|
rpm-distro
|
||||||
|
source-repositories
|
||||||
|
yum
|
1
elements/centos7/element-provides
Normal file
1
elements/centos7/element-provides
Normal file
@ -0,0 +1 @@
|
|||||||
|
operating-system
|
@ -0,0 +1 @@
|
|||||||
|
export DISTRO_NAME=centos7
|
6
elements/centos7/install.d/00-install-cloud-init
Executable file
6
elements/centos7/install.d/00-install-cloud-init
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
install-packages cloud-init
|
22
elements/centos7/pre-install.d/06-yum-repos
Executable file
22
elements/centos7/pre-install.d/06-yum-repos
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
cat << EOF > /etc/yum.repos.d/centos7-latest.repo
|
||||||
|
[rhel7]
|
||||||
|
name=centos7
|
||||||
|
baseurl=http://buildlogs.centos.org/centos/7/os/x86_64-latest/
|
||||||
|
enabled=1
|
||||||
|
metadata_expire=7d
|
||||||
|
gpgcheck=0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat << EOF > /etc/yum.repos.d/epel.repo
|
||||||
|
[epel]
|
||||||
|
name=Extra Packages for Enterprise Linux 7 - \$basearch
|
||||||
|
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch
|
||||||
|
failovermethod=priority
|
||||||
|
enabled=1
|
||||||
|
gpgcheck=0
|
||||||
|
EOF
|
31
elements/centos7/root.d/10-centos7-cloud-image
Executable file
31
elements/centos7/root.d/10-centos7-cloud-image
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
[ -n "$ARCH" ]
|
||||||
|
[ -n "$TARGET_ROOT" ]
|
||||||
|
|
||||||
|
if [ 'amd64' = "$ARCH" ] ; then
|
||||||
|
ARCH="x86_64"
|
||||||
|
fi
|
||||||
|
|
||||||
|
DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-}
|
||||||
|
|
||||||
|
if [ -n "$DIB_LOCAL_IMAGE" ]; then
|
||||||
|
IMAGE_LOCATION=$DIB_LOCAL_IMAGE
|
||||||
|
# No need to copy a local image into the cache directory, so just specify
|
||||||
|
# the cached path as the original path.
|
||||||
|
CACHED_IMAGE=$IMAGE_LOCATION
|
||||||
|
BASE_IMAGE_FILE=$(basename $DIB_LOCAL_IMAGE)
|
||||||
|
BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz
|
||||||
|
else
|
||||||
|
DIB_RELEASE=${DIB_RELEASE:-Broken-20140620-Nightly}
|
||||||
|
DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://buildlogs.centos.org/centos/7/cloud}
|
||||||
|
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-CentOS-7-$DIB_RELEASE.qcow2}
|
||||||
|
BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz
|
||||||
|
IMAGE_LOCATION=$DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE
|
||||||
|
CACHED_IMAGE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
$TMP_HOOKS_PATH/bin/extract-image $BASE_IMAGE_FILE $BASE_IMAGE_TAR $IMAGE_LOCATION $CACHED_IMAGE
|
1
elements/centos7/source-repository-centos7
Normal file
1
elements/centos7/source-repository-centos7
Normal file
@ -0,0 +1 @@
|
|||||||
|
lsb-release file /opt/stack/lsb-release/lsb_release https://bzr.linuxfoundation.org/loggerhead/lsb/devel/si/download/head:/lsb_release-20060624065236-gakl5b7e37gwk5mg-12/lsb_release
|
@ -22,7 +22,7 @@ import sys
|
|||||||
|
|
||||||
def os_family(distro):
|
def os_family(distro):
|
||||||
family = None
|
family = None
|
||||||
if distro in ['centos', 'fedora', 'rhel', 'rhel7']:
|
if distro in ['centos', 'fedora', 'rhel', 'rhel7', 'centos7']:
|
||||||
family = 'redhat'
|
family = 'redhat'
|
||||||
elif distro in ['debian', 'ubuntu']:
|
elif distro in ['debian', 'ubuntu']:
|
||||||
family = 'debian'
|
family = 'debian'
|
||||||
|
@ -46,31 +46,43 @@ else
|
|||||||
RAW_FILE=$(basename $BASE_IMAGE_FILE)
|
RAW_FILE=$(basename $BASE_IMAGE_FILE)
|
||||||
RAW_FILE=${RAW_FILE#.qcow2}.raw
|
RAW_FILE=${RAW_FILE#.qcow2}.raw
|
||||||
qemu-img convert -f qcow2 -O raw $CACHED_IMAGE $WORKING/$RAW_FILE
|
qemu-img convert -f qcow2 -O raw $CACHED_IMAGE $WORKING/$RAW_FILE
|
||||||
# WARNING: The mattdm image has the root filesystem on the second
|
|
||||||
# partition (p2). If he changes the image the MAGIC_BIT
|
|
||||||
# might also need to change.
|
|
||||||
# UPDATE to above warning alluding to Fedora18:
|
|
||||||
# F19 images have the rootfs partition on p1
|
# F19 images have the rootfs partition on p1
|
||||||
MAGIC_BIT=p1
|
# Centos7 images on p3 (p1 boot, p2 swap)
|
||||||
|
if [[ $DISTRO_NAME = "centos7" ]]; then
|
||||||
|
ROOT_PARTITON=p3
|
||||||
|
else
|
||||||
|
ROOT_PARTITON=p1
|
||||||
|
fi
|
||||||
|
|
||||||
# kpartx fails if no /dev/loop* exists, "losetup -f" prints first unused
|
# kpartx fails if no /dev/loop* exists, "losetup -f" prints first unused
|
||||||
# loop device and creates it if it doesn't exist
|
# loop device and creates it if it doesn't exist
|
||||||
sudo losetup -f
|
sudo losetup -f
|
||||||
|
|
||||||
# XXX: Parsing stdout is dangerous, would like a better way to discover
|
# XXX: Parsing stdout is dangerous, would like a better way to discover
|
||||||
# the device used for the image.
|
# the device used for the image.
|
||||||
# NOTE: On F17 (parted-3.0-10.fc17.x86_64), partprobe of
|
ROOT_LOOPDEV=$(sudo kpartx -av $WORKING/$RAW_FILE | \
|
||||||
# /dev/loop0 does not create /dev/loop0p2, while kpartx at
|
awk "/loop[0-9]+$ROOT_PARTITON/ {print \$3}")
|
||||||
# least creates /dev/mapper/loop0p2.
|
if ! timeout 5 sh -c "while ! [ -e /dev/mapper/$ROOT_LOOPDEV ]; do sleep 1; done"; then
|
||||||
LOOPDEV=$(sudo kpartx -av $WORKING/$RAW_FILE | awk "/loop[0-9]+$MAGIC_BIT/ {print \$3}")
|
echo "Error: Could not find /dev/mapper/$ROOT_LOOPDEV"
|
||||||
if ! timeout 5 sh -c "while ! [ -e /dev/mapper/$LOOPDEV ]; do sleep 1; done"; then
|
|
||||||
echo "Error: Could not find /dev/mapper/$LOOPDEV"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
EACTION="sudo kpartx -d $WORKING/$RAW_FILE;$EACTION"
|
EACTION="sudo kpartx -d $WORKING/$RAW_FILE ; $EACTION"
|
||||||
trap "$EACTION" EXIT
|
trap "$EACTION" EXIT
|
||||||
mkdir $WORKING/mnt
|
mkdir $WORKING/mnt
|
||||||
sudo mount /dev/mapper/$LOOPDEV $WORKING/mnt
|
sudo mount /dev/mapper/$ROOT_LOOPDEV $WORKING/mnt
|
||||||
EACTION="sudo umount -f $WORKING/mnt;$EACTION"
|
EACTION="sudo umount -f $WORKING/mnt ; $EACTION"
|
||||||
trap "$EACTION" EXIT
|
trap "$EACTION" EXIT
|
||||||
|
|
||||||
|
# need to copy the contents of /boot into the image too, so
|
||||||
|
# mount it
|
||||||
|
if [[ $DISTRO_NAME = "centos7" ]]; then
|
||||||
|
BOOT_LOOPDEV=${ROOT_LOOPDEV/p3/p1}
|
||||||
|
sudo mount /dev/mapper/$BOOT_LOOPDEV $WORKING/mnt/boot
|
||||||
|
EACTION="sudo umount -f $WORKING/mnt/boot ; $EACTION"
|
||||||
|
trap "$EACTION" EXIT
|
||||||
|
fi
|
||||||
|
|
||||||
# Chroot in so that we get the correct uid/gid
|
# Chroot in so that we get the correct uid/gid
|
||||||
sudo chroot $WORKING/mnt bin/tar -cz . > $WORKING/tmp.tar
|
sudo chroot $WORKING/mnt bin/tar -cz . > $WORKING/tmp.tar
|
||||||
mv $WORKING/tmp.tar $CACHED_TAR
|
mv $WORKING/tmp.tar $CACHED_TAR
|
||||||
|
@ -113,7 +113,7 @@ function install_grub2 {
|
|||||||
sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub
|
sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub
|
||||||
GRUB_MKCONFIG=update-grub
|
GRUB_MKCONFIG=update-grub
|
||||||
;;
|
;;
|
||||||
'Fedora')
|
'Fedora'|'CentOS')
|
||||||
echo 'GRUB_CMDLINE_LINUX="nofb nomodeset vga=normal"' >>/etc/default/grub
|
echo 'GRUB_CMDLINE_LINUX="nofb nomodeset vga=normal"' >>/etc/default/grub
|
||||||
;;
|
;;
|
||||||
'openSUSE project')
|
'openSUSE project')
|
||||||
|
Loading…
Reference in New Issue
Block a user