Add support for Debian

Change-Id: Ibc6bc57dea1eab295fb23cccf40b38f3fcb285c3
This commit is contained in:
Clint Byrum 2014-01-11 13:43:43 -08:00
parent de7deb7ce9
commit d0fd8915f6
3 changed files with 48 additions and 0 deletions

12
elements/debian/README.md Normal file
View File

@ -0,0 +1,12 @@
Create an image based on Debian. We default to unstable but DIB_RELEASE
is mapped to any series of Debian.
Note that the default Debian series is `unstable`, and the default
mirrors for Debian can be problematic for `unstable`. Because apt does
not handle changing Packages files well across multiple out of sync
mirrors, it is recommended that you choose a single mirror of debian,
and pass it in via `DIB_DEBIAN_MIRROR`.
Use of this element will also require the tool 'debootstrap' to be
available on your system. It should be available on Ubuntu, Debian,
and Fedora.

View File

@ -0,0 +1,2 @@
dib-run-parts
dpkg

View File

@ -0,0 +1,34 @@
#!/bin/sh
set -eu
DIB_RELEASE=${DIB_RELEASE:-unstable}
DEBOOTSTRAP_TARBALL=$DIB_IMAGE_CACHE/debootstrap-${DIB_RELEASE}-${ARCH}.tar.gz
DIB_DEBIAN_MIRROR=${DIB_DEBIAN_MIRROR:-http://http.debian.net/debian}
http_proxy=${http_proxy:-}
set -x
if [ -n "$DIB_OFFLINE" ] && [ -f $DEBOOTSTRAP_TARBALL ] ; then
echo $DEBOOTSTRAP_TARBALL found in cache. Using.
sudo tar -C $TARGET_ROOT --numeric-owner -xzf $DEBOOTSTRAP_TARBALL
else
echo Building new tarball for Debian $DIB_RELEASE ARCH=$ARCH
ADD_PACKAGES=cloud-init,cloud-utils,cloud-initramfs-growroot,sudo,adduser,locales,openssh-server,file,less,kbd,curl,bash-completion,linux-image-amd64
sudo sh -c "http_proxy=$http_proxy debootstrap --verbose \
--arch=${ARCH} \
--include=${ADD_PACKAGES} \
$DIB_RELEASE \
$TARGET_ROOT \
$DIB_DEBIAN_MIRROR"
echo "Customizing result for cloud use"
sudo sed -i "s/PermitRootLogin yes/PermitRootLogin without-password/" $TARGET_ROOT/etc/ssh/sshd_config
sudo chroot ${TARGET_ROOT} adduser --gecos Debian-cloud-init-user --disabled-password --quiet debian
sudo install -d -m 0755 -o root -g root ${TARGET_ROOT}/etc/sudoers.d
sudo sh -c "echo 'debian ALL=(ALL) NOPASSWD:ALL' > ${TARGET_ROOT}/etc/sudoers.d/debian-cloud-init"
sudo chmod 0440 ${TARGET_ROOT}/etc/sudoers.d/debian-cloud-init
sudo sh -c "echo 'proc /proc proc nodev,noexec,nosuid 0 0
LABEL=cloudimg-rootfs / ext4 errors=remount-ro 0 1
' > ${TARGET_ROOT}/etc/fstab"
sudo sh -c "echo 'blacklist pcspkr' > ${TARGET_ROOT}/etc/modprobe.d/blacklist.conf"
sudo sh -c "echo 'debian' > ${TARGET_ROOT}/etc/hostname"
echo Caching debootstrap result in $DEBOOTSTRAP_TARBALL
sudo tar -C $TARGET_ROOT -zcf $DEBOOTSTRAP_TARBALL .
fi