#!/usr/bin/sudo /bin/sh if [ -z "${BUILD_HOSTNAME}" ]; then . ./rpi2-settings.sh fi set +x if [ "{${UBUNTU_FIRST_USER}_PASS}" = '#EDIT THIS#' ]; then echo "Sorry. You have not set a Password in rpi2-settings.sh" echo "This is verry unsafe. Exit." exit 2 fi if [ ${WriteTo} = 'mmcblk0' ]; then clear echo " #==========================================================#" echo " # #" echo " # AVE #" echo " # #" echo " # This will brutal delete your files on mmcblk0! #" echo " # #" echo " #==========================================================#" echo "" echo -n " Yout want this really? Type YES: ___\b\b\b" read answer echo "" if [ "${answer}" = "YES" ]; then echo "" echo " Ok. So you want ..." echo "" else echo "" echo " Ok. Exit." echo "" exit fi elif [ ${WriteTo} = 'image' ]; then clear echo " #=============================================================#" echo " # #" echo " # Hint: #" echo " # #" echo " # Generate $BASEDIR/${DATE}-ubuntu-${RELEASE}.img" echo " # #" echo " #=============================================================#" echo "" else clear echo " #=============================================================#" echo " # #" echo " # Hint: #" echo " # #" echo " # Generate Ubuntu-installation in ${BUILDDIR}" echo " # #" echo " #=============================================================#" echo "" fi # Don't clobber an old build if [ -e "${BUILDDIR}" ]; then echo "${BUILDDIR} exists, not proceeding" exit 1 fi set -x # Install needed software apt-get update if ! which debootstrap; then apt-get install debootstrap qemu-debootstrap fi if ! which qemu-debootstrap; then apt-get install qemu-debootstrap fi if ! which bmaptool; then apt-get install bmap-tools fi # Set up environment export TZ=UTC mkdir -p ${R} # Base debootstrap apt-get -y install ubuntu-keyring qemu-debootstrap --arch armhf ${RELEASE} ${R} http://ports.ubuntu.com/ # Mount required filesystems mount -t proc none ${R}/proc mount -t sysfs none ${R}/sys # Set up initial sources.list cat <${R}/etc/apt/sources.list deb http://ports.ubuntu.com/ ${RELEASE} main restricted universe multiverse # deb-src http://ports.ubuntu.com/ ${RELEASE} main restricted universe multiverse deb http://ports.ubuntu.com/ ${RELEASE}-updates main restricted universe multiverse # deb-src http://ports.ubuntu.com/ ${RELEASE}-updates main restricted universe multiverse deb http://ports.ubuntu.com/ ${RELEASE}-security main restricted universe multiverse # deb-src http://ports.ubuntu.com/ ${RELEASE}-security main restricted universe multiverse deb http://ports.ubuntu.com/ ${RELEASE}-backports main restricted universe multiverse # deb-src http://ports.ubuntu.com/ ${RELEASE}-backports main restricted universe multiverse EOM chroot ${R} apt-get update chroot ${R} apt-get -y -u dist-upgrade # Install the RPi PPA cat <<"EOM" >${R}/etc/apt/preferences.d/rpi2-ppa Package: * Pin: release o=LP-PPA-fo0bar-rpi2 Pin-Priority: 990 Package: * Pin: release o=LP-PPA-fo0bar-rpi2-staging Pin-Priority: 990 EOM chroot ${R} apt-get -y --force-yes install software-properties-common ubuntu-keyring chroot ${R} apt-add-repository -y ppa:fo0bar/rpi2 chroot ${R} apt-get update # Standard packages chroot ${R} apt-get -y --force-yes install ubuntu-minimal initramfs-tools raspberrypi-bootloader-nokernel rpi2-ubuntu-errata language-pack-en # Kernel installation # Install flash-kernel last so it doesn't try (and fail) to detect the # platform in the chroot. chroot ${R} apt-get -y --force-yes --no-install-recommends install linux-image-rpi2 chroot ${R} apt-get -y --force-yes install flash-kernel ############################ Jörg Reinholz: Software if [ -n ${EXTRA_SOFTWARE} ]; then for w in ${EXTRA_SOFTWARE}; do chroot ${R} apt-get -y --force-yes install ${w}; done; fi if [ -n ${REMOVE_SOFTWARE} ]; then for w in ${REMOVE_SOFTWARE}; do chroot ${R} apt-get -y purge ${w}; done; fi #chroot ${R} apt-get -y install linux-firmware libraspberrypi-bin libraspberrypi-dev libraspberrypi-bin-nonfree #chroot ${R} apt-get -y install dphys-swapfile ############################ VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)" [ -z "${VMLINUZ}" ] && exit 1 cp ${VMLINUZ} ${R}/boot/firmware/kernel7.img INITRD="$(ls -1 ${R}/boot/initrd.img-* | sort | tail -n 1)" [ -z "${INITRD}" ] && exit 1 cp ${INITRD} ${R}/boot/firmware/initrd7.img # Set up fstab cat <${R}/etc/fstab proc /proc proc defaults 0 0 /dev/mmcblk0p3 / ext4 defaults,noatime 0 1 /dev/mmcblk0p1 /boot/firmware vfat defaults,ro 0 2 /dev/mmcblk0p2 none swap sw 0 0 EOM #setting up extra files . ./rpi2-extra-files.sh # Set up default user chroot ${R} adduser --disabled-login --gecos "${UBUNTU_FIRST_USER}" --add_extra_groups ${UBUNTU_FIRST_USER} UBUNTU_FIRST_USER_PASS=`echo "ttt:${UBUNTU_FIRST_USER}_PASS" | chpasswd -S -c SHA512 | sed s/ttt://` chroot ${R} usermod -a -G sudo,adm -p ${UBUNTU_FIRST_USER}_PASS ${UBUNTU_FIRST_USER} unset UBUNTU_FIRST_USER_PASS; # install the firmware-updater: chroot ${R} curl -L --output /usr/bin/rpi-update https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update chroot ${R} chmod +x /usr/bin/rpi-update # update the firmware: if [ -n ${UPDATE_FIRMWARE_USB_SAVE} ]; then chroot ${R} /usr/bin/rpi-update e3e89868ece21abe525dc181c431c8a8b5de58b8 export UPDATE_FIRMWARE='' fi if [ -n ${UPDATE_FIRMWARE} ]; then chroot ${R} /usr/bin/rpi-update fi if [ -n Activate1_2AmpPowerOverUSB ]; then echo "# sets the available current over USB to 1.2A (default is 0 [600mA])" >> ${R}/boot/config.txt echo "max_usb_current=1" >> ${R}/boot/config.txt fi chroot ${R} apt-get autoremove # Clean cached downloads chroot ${R} apt-get clean # Unmount mounted filesystems umount ${R}/proc umount ${R}/sys # Clean up files rm -f ${R}/etc/apt/sources.list.save rm -f ${R}/etc/resolvconf/resolv.conf.d/original rm -rf ${R}/run mkdir -p ${R}/run rm -f ${R}/etc/*- rm -f ${R}/root/.bash_history rm -rf ${R}/tmp/* rm -f ${R}/var/lib/urandom/random-seed [ -L ${R}/var/lib/dbus/machine-id ] || rm -f ${R}/var/lib/dbus/machine-id rm -f ${R}/etc/machine-id set +x echo "" echo "Installation (virtual filesystem) written to: ${R}" echo "" if [ "${WriteTo}" = "mmcblk0" ]; then . ./rpi2-create-mmcblk0.sh elif [ "${WriteTo}" = "image" ]; then . ./rpi2-create-image.sh fi echo "" echo " #=========================================#" echo " # #" echo " # Ready! #" echo " # #" echo " #=========================================#" echo "" exit