commit 385cec42b8537ce6cfae29c0986f8a2ab37958af Author: mudler Date: Thu Aug 4 16:50:12 2016 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2c0f48 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +CHROOTS +chroot/* +iso/* +livecd/* +pkgcache/* +sources/* +iso_rsync/* +automatic-changelogs/* +monthly-git-logs/* +images/* +bin/docker-companion diff --git a/README.md b/README.md new file mode 100644 index 0000000..427036d --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Arm molecules + +**Required:** + +* docker running: ```systemctl start docker``` +* docker-companion, available in sabayon repositories, or it will be fetched and placed automatically in bin/docker-companion +* molecules, available in sabayon repositories + +then you can run build.sh inside the folder: ```./build.sh``` diff --git a/bin/sfdisk b/bin/sfdisk new file mode 100755 index 0000000..4976fb0 Binary files /dev/null and b/bin/sfdisk differ diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..5b2167e --- /dev/null +++ b/build.sh @@ -0,0 +1,56 @@ +#!/bin/bash +set -e + +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +update_chroot() { + + local image=$1 + local chroot_name=$2 + + pushd ./sources + + rm -rf $(pwd)/${chroot_name} + [[ -e ./../bin/docker-companion ]] \ + && ./../bin/docker-companion --pull unpack "${image}" $(pwd)/${chroot_name} \ + || docker-companion --pull unpack "${image}" $(pwd)/${chroot_name} + + popd + +} + +update_docker_companion() { + + type docker-companion >/dev/null 2>&1 || { + echo >&2 "Fetching docker-companion for you, and placing it under bin/" + curl -s https://api.github.com/repos/mudler/docker-companion/releases/latest \ + | grep "browser_download_url.*amd64" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + | wget -i - -N -O bin/docker-companion + chmod +x bin/docker-companion +} + +} + +echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-binfmt:' > /proc/sys/fs/binfmt_misc/register || true + +update_docker_companion +update_chroot sabayon/rpi-armhfp rpi +update_chroot sabayon/rpi-mc-armhfp rpi-mc +update_chroot sabayon/odroid-u2-x2-armhfp odroid-u2-x2 +update_chroot sabayon/odroid-c2-armhfp odroid-c2 +update_chroot sabayon/udooneo-armhfp udooneo + +export SABAYON_RELEASE="${SABAYON_RELEASE:-16}" + +echo "Release ${SABAYON_RELEASE}" + +SABAYON_MOLECULE_HOME=$(pwd) molecule molecules/sabayon-arm-rpi-8G.spec +SABAYON_MOLECULE_HOME=$(pwd) molecule molecules/sabayon-arm-rpi-mc-8G.spec +SABAYON_MOLECULE_HOME=$(pwd) molecule molecules/sabayon-arm-odroid-u2-x2-8G.spec +SABAYON_MOLECULE_HOME=$(pwd) molecule molecules/sabayon-arm-odroid-c2-8G.spec +SABAYON_MOLECULE_HOME=$(pwd) molecule molecules/sabayon-arm-udooneo-8G.spec diff --git a/molecules/arm-base.common b/molecules/arm-base.common new file mode 100644 index 0000000..7ca950c --- /dev/null +++ b/molecules/arm-base.common @@ -0,0 +1,130 @@ +# Define an alternative execution strategy, in this case, the value must be +execution_strategy: chroot_to_mmc + +# Prefix command to add to chroot calls, when on x86_64 and touching a i686 +# chroot, set it to "linux32" +# prechroot: + +# Outer source chroot script. It's executed before entering the source_chroot. +# This is the very first thing molecule does. You can use it to setup +# packages cache. +# Variables exported: +# IMAGE_NAME = name of the final MMC image +# DESTINATION_IMAGE_DIR = path to the destination image directory +# CHROOT_DIR = path pointing to the chroot +%env outer_source_chroot_script: ${SABAYON_MOLECULE_HOME:-/sabayon}/scripts/outer_source_chroot_script_arm.sh + +# Inner source chroot script. Called from inside the source_chroot. +# Can be used to spawn package updates inside the chroot. +# inner_source_chroot_script: /sabayon/scripts/inner_source_chroot_update.sh + +# Outer source chroot script, executed after inner_source_chroot_script. +# Can be used to unload resources allocated by outer_source_chroot_script. +# Variables exported: +# IMAGE_NAME = name of the final MMC image +# DESTINATION_IMAGE_DIR = path to the destination image directory +# CHROOT_DIR = path pointing to the chroot +# outer_source_chroot_script_after: /some/path.sh + +# Error script command, executed when something went wrong and molecule has +# to terminate the execution +# error_script: /path/to/some/error_script.sh + +# Pre-image building script. Hook called before image file creation +# IMAGE_NAME = name of the final MMC image +# DESTINATION_IMAGE_DIR = path to the destination image directory +# CHROOT_DIR = path pointing to the chroot +pre_image_script: ${SABAYON_MOLECULE_HOME:-/sabayon}/scripts/pre_mmc.sh + +# Post-image building script. Hook called after image file creation and move +# into destination directory. +# Variables exported: +# IMAGE_NAME = name of the final MMC image +# DESTINATION_IMAGE_DIR = path to the destination image directory +# CHROOT_DIR = path pointing to the chroot +# IMAGE_PATH = path pointing to the destination image file +# IMAGE_CHECKSUM_PATH = path pointing to the destination image file checksum (md5) +%env post_image_script: ${SABAYON_MOLECULE_HOME:-/sabayon}/scripts/post_mmc_image_script.sh + +# Destination directory for the image path (MANDATORY) +%env destination_image_directory: ${SABAYON_MOLECULE_HOME:-/sabayon}/images + +# Release file that will be created onto the root filesystem +release_file: /etc/sabayon-edition + +# Release string (the actual distro name) +release_string: Sabayon Linux + +# Directories to remove completely (comma separated) +paths_to_remove: + /var/lib/entropy/client/database/*/sabayon*, + /root/.subversion, + /lib/udev-state/devices.tar.bz2, + /var/log/scrollkeeper.log, /var/log/genkernel.log, + /var/log/emerge.log, /usr/tmp/portage/*, + /root/.bash_history, + /usr/share/slocate/slocate.db, + /root/test-results.txt, + /root/test.sh, + /usr/portage/distfiles/*, + /usr/portage/packages/*, + /root/.revdep*, + /install-data/games/*, + /var/lib/entropy/store/*, + /var/log/entropy/*, + /var/lib/entropy/caches/*, + /var/lib/entropy/smartapps/*/*, + /var/lib/entropy/smartapps/*/*, + /var/lib/entropy/tmp/*, + /var/tmp/entropy/*, + /*.txt, + /usr/portage/a*, + /usr/portage/b*, + /usr/portage/c*, + /usr/portage/d*, + /usr/portage/e*, + /usr/portage/f*, + /usr/portage/g*, + /usr/portage/h*, + /usr/portage/i*, + /usr/portage/j*, + /usr/portage/k*, + /usr/portage/licenses, + /usr/portage/lxde*, + /usr/portage/m*, + /usr/portage/n*, + /usr/portage/o*, + /usr/portage/packages, + /usr/portage/pe*, + /usr/portage/q*, + /usr/portage/r*, + /usr/portage/s*, + /usr/portage/t*, + /usr/portage/u*, + /usr/portage/v*, + /usr/portage/w*, + /usr/portage/x*, + /usr/portage/y*, + /usr/portage/z*, + /etc/ssh/ssh_host_*, + /entropy, + /tmp/equoerror.txt, + /var/cache/man, + /var/lib/entropy/glsa/*, + /root/local, + /var/tmp/*, + /root/.ssh, + /root/.distcc, + /etc/distcc/.ssh + +# Directories to empty (comma separated) +paths_to_empty: + /home/sabayonuser/.thumbnails/, + /root/.ccache, + /var/tmp/portage, + /var/tmp/ccache, + /var/tmp/portage-pkg, + /var/tmp/binpkgs, + /var/lib/entropy/portage, + /var/lib/entropy/logs, + /var/cache/genkernel diff --git a/molecules/sabayon-arm-odroid-c2-8G.spec b/molecules/sabayon-arm-odroid-c2-8G.spec new file mode 100644 index 0000000..40c2797 --- /dev/null +++ b/molecules/sabayon-arm-odroid-c2-8G.spec @@ -0,0 +1,36 @@ +%env %import ${SABAYON_MOLECULE_HOME:-/sabayon}/molecules/arm-base.common + +%env source_chroot: ${SABAYON_MOLECULE_HOME:-/sabayon}/sources/odroid-c2 + +packages_to_add: + app-misc/sabayon-skel, + net-misc/networkmanager, + openssh, + sys-apps/keyboard-configuration-helpers, + sys-process/vixie-cron + +packages_to_remove: + +# Release desc (the actual release description) +release_desc: armv7l Odroid C2 + +# Release Version (used to generate release_file) +%env release_version: ${SABAYON_RELEASE:-11} + +# Specify image file name (image file name will be automatically +# produced otherwise) +%env image_name: Sabayon_Linux_${SABAYON_RELEASE:-11}_armv7l_Odroid_C2_8GB.img + +# Specify the image file size in Megabytes. This is mandatory. +# To avoid runtime failure, make sure the image is large enough to fit your +# chroot data. +image_mb: 7200 + +# Path to boot partition data (MLO, u-boot.img etc) +%env source_boot_directory: ${SABAYON_MOLECULE_HOME:-/sabayon}/boot/arm/odroid-c2 + +# External script that will generate the image file. +# The same can be copied onto a MMC by using dd +%env image_generator_script: ${SABAYON_MOLECULE_HOME:-/sabayon}/scripts/odroid_c2_image_generator_script.sh + + diff --git a/molecules/sabayon-arm-odroid-u2-x2-8G.spec b/molecules/sabayon-arm-odroid-u2-x2-8G.spec new file mode 100644 index 0000000..589de21 --- /dev/null +++ b/molecules/sabayon-arm-odroid-u2-x2-8G.spec @@ -0,0 +1,37 @@ +%env %import ${SABAYON_MOLECULE_HOME:-/sabayon}/molecules/arm-base.common + +%env source_chroot: ${SABAYON_MOLECULE_HOME:-/sabayon}/sources/odroid-u2-x2 + +packages_to_add: + app-misc/sabayon-skel, + net-misc/ntp, + net-misc/networkmanager, + openssh, + sys-apps/keyboard-configuration-helpers, + sys-process/vixie-cron + +packages_to_remove: + +# Release desc (the actual release description) +release_desc: armv7l Odroid U2/X2 + +# Release Version (used to generate release_file) +%env release_version: ${SABAYON_RELEASE:-11} + +# Specify image file name (image file name will be automatically +# produced otherwise) +%env image_name: Sabayon_Linux_${SABAYON_RELEASE:-11}_armv7l_Odroid_U2_X2_8GB.img + +# Specify the image file size in Megabytes. This is mandatory. +# To avoid runtime failure, make sure the image is large enough to fit your +# chroot data. +image_mb: 7200 + +# Path to boot partition data (MLO, u-boot.img etc) +%env source_boot_directory: ${SABAYON_MOLECULE_HOME:-/sabayon}/boot/arm/odroid-u2-x2 + +# External script that will generate the image file. +# The same can be copied onto a MMC by using dd +%env image_generator_script: ${SABAYON_MOLECULE_HOME:-/sabayon}/scripts/odroid_u2_x2_image_generator_script.sh + + diff --git a/molecules/sabayon-arm-rpi-8G.spec b/molecules/sabayon-arm-rpi-8G.spec new file mode 100644 index 0000000..10180a2 --- /dev/null +++ b/molecules/sabayon-arm-rpi-8G.spec @@ -0,0 +1,25 @@ +%env %import ${SABAYON_MOLECULE_HOME:-/sabayon}/molecules/arm-base.common +# Path to source chroot (mandatory) +%env source_chroot: ${SABAYON_MOLECULE_HOME:-/sabayon}/sources/rpi + +# Release desc (the actual release description) +release_desc: armv7l RPi + +# Release Version (used to generate release_file) +%env release_version: ${SABAYON_RELEASE:-11} + +# Specify image file name (image file name will be automatically +# produced otherwise) +%env image_name: Sabayon_Linux_${SABAYON_RELEASE:-11}_armv7l_RPi_Base_8GB.img + +# Specify the image file size in Megabytes. This is mandatory. +# To avoid runtime failure, make sure the image is large enough to fit your +# chroot data. +image_mb: 7200 + +# Path to boot partition data (MLO, u-boot.img etc) +%env source_boot_directory: ${SABAYON_MOLECULE_HOME:-/sabayon}/boot/arm/rpi + +# External script that will generate the image file. +# The same can be copied onto a MMC by using dd +%env image_generator_script: ${SABAYON_MOLECULE_HOME:-/sabayon}/scripts/raspberry_image_generator_script.sh diff --git a/molecules/sabayon-arm-rpi-mc-8G.spec b/molecules/sabayon-arm-rpi-mc-8G.spec new file mode 100644 index 0000000..1d6d544 --- /dev/null +++ b/molecules/sabayon-arm-rpi-mc-8G.spec @@ -0,0 +1,27 @@ +%env %import ${SABAYON_MOLECULE_HOME:-/sabayon}/molecules/arm-base.common + +# Path to source chroot (mandatory) +%env source_chroot: ${SABAYON_MOLECULE_HOME:-/sabayon}/sources/rpi-mc + +# Release desc (the actual release description) +release_desc: armv7l RPi + +# Release Version (used to generate release_file) +%env release_version: ${SABAYON_RELEASE:-11} + +# Specify image file name (image file name will be automatically +# produced otherwise) +%env image_name: Sabayon_Linux_${SABAYON_RELEASE:-11}_armv7l_RPi_MediaCenter_8GB.img + +# Specify the image file size in Megabytes. This is mandatory. +# To avoid runtime failure, make sure the image is large enough to fit your +# chroot data. +image_mb: 7200 + +# Path to boot partition data (MLO, u-boot.img etc) +%env source_boot_directory: ${SABAYON_MOLECULE_HOME:-/sabayon}/boot/arm/rpi + +# External script that will generate the image file. +# The same can be copied onto a MMC by using dd +%env image_generator_script: ${SABAYON_MOLECULE_HOME:-/sabayon}/scripts/raspberry_image_generator_script.sh + diff --git a/molecules/sabayon-arm-udooneo-8G.spec b/molecules/sabayon-arm-udooneo-8G.spec new file mode 100644 index 0000000..0a9d6eb --- /dev/null +++ b/molecules/sabayon-arm-udooneo-8G.spec @@ -0,0 +1,36 @@ +%env %import ${SABAYON_MOLECULE_HOME:-/sabayon}/molecules/arm-base.common + +%env source_chroot: ${SABAYON_MOLECULE_HOME:-/sabayon}/sources/udooneo + +packages_to_add: + app-misc/sabayon-skel, + net-misc/networkmanager, + openssh, + sys-apps/keyboard-configuration-helpers, + sys-process/vixie-cron + +packages_to_remove: + +# Release desc (the actual release description) +release_desc: armv7l Udoo Neo + +# Release Version (used to generate release_file) +%env release_version: ${SABAYON_RELEASE:-11} + +# Specify image file name (image file name will be automatically +# produced otherwise) +%env image_name: Sabayon_Linux_${SABAYON_RELEASE:-11}_armv7l_Udoo_Neo_8GB.img + +# Specify the image file size in Megabytes. This is mandatory. +# To avoid runtime failure, make sure the image is large enough to fit your +# chroot data. +image_mb: 7200 + +# Path to boot partition data (MLO, u-boot.img etc) +%env source_boot_directory: ${SABAYON_MOLECULE_HOME:-/sabayon}/boot/arm/udooneo + +# External script that will generate the image file. +# The same can be copied onto a MMC by using dd +%env image_generator_script: ${SABAYON_MOLECULE_HOME:-/sabayon}/scripts/udoo_neo_image_generator_script.sh + + diff --git a/scripts/cleanup_pkgcache.sh b/scripts/cleanup_pkgcache.sh new file mode 100755 index 0000000..81fc643 --- /dev/null +++ b/scripts/cleanup_pkgcache.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Remove tarballs not accessed in the last 30 days +# concurrency wrt scripts is handled in crontab + +# Path to molecules.git dir +SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" + +DIR="${SABAYON_MOLECULE_HOME}/pkgcache" +find "${DIR}" -atime +30 -type f -delete diff --git a/scripts/image_error_script.sh b/scripts/image_error_script.sh new file mode 100755 index 0000000..4b04c2c --- /dev/null +++ b/scripts/image_error_script.sh @@ -0,0 +1,19 @@ +#!/bin/sh +if [ -d "${CHROOT_DIR}/proc" ]; then + echo "Unmounting ${CHROOT_DIR}/proc" + umount "${CHROOT_DIR}/proc" +fi + +CHROOT_PKGS_DIR="${CHROOT_DIR}/var/lib/entropy/client/packages" +if [ -d "${CHROOT_PKGS_DIR}" ]; then + echo "Umounting bind to ${CHROOT_PKGS_DIR}" + umount "${CHROOT_PKGS_DIR}" || exit 1 +fi + +echo "trying to umount ${CHROOT_DIR}" +umount "${CHROOT_DIR}" + +#if [ -n "${LOOP_DEVICE}" ]; then +# echo "trying to umount loop device ${LOOP_DEVICE}" +# /sbin/losetup -d "${LOOP_DEVICE}" +#fi diff --git a/scripts/mkcard.txt b/scripts/mkcard.txt new file mode 100755 index 0000000..8c569d1 --- /dev/null +++ b/scripts/mkcard.txt @@ -0,0 +1,77 @@ +#! /bin/sh +# mkcard.sh v0.5 +# (c) Copyright 2009 Graeme Gregory +# Licensed under terms of GPLv2 +# +# Parts of the procudure base on the work of Denys Dmytriyenko +# http://wiki.omap.com/index.php/MMC_Boot_Format + +export LC_ALL=C + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1; +fi + +DRIVE=$1 + +dd if=/dev/zero of=$DRIVE bs=1024 count=1024 + +SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'` + +echo DISK SIZE - $SIZE bytes + +CYLINDERS=`echo $SIZE/255/63/512 | bc` + +echo CYLINDERS - $CYLINDERS + +{ +echo ,9,0x0C,* +echo ,,,- +} | "${SABAYON_MOLECULE_HOME}"/bin/sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE + +sleep 1 + + +"${SABAYON_MOLECULE_HOME}"/bin/sfdisk -R $DRIVE + +# handle various device names. +# note something like fdisk -l /dev/loop0 | egrep -E '^/dev' | cut -d' ' -f1 +# won't work due to https://bugzilla.redhat.com/show_bug.cgi?id=649572 + +PARTITION1=${DRIVE}1 +if [ ! -b ${PARTITION1} ]; then + PARTITION1=${DRIVE}p1 +fi + +DRIVE_NAME=`basename $DRIVE` +DEV_DIR=`dirname $DRIVE` + +if [ ! -b ${PARTITION1} ]; then + PARTITION1=$DEV_DIR/mapper/${DRIVE_NAME}p1 +fi + +PARTITION2=${DRIVE}2 +if [ ! -b ${PARTITION2} ]; then + PARTITION2=${DRIVE}p2 +fi +if [ ! -b ${PARTITION2} ]; then + PARTITION2=$DEV_DIR/mapper/${DRIVE_NAME}p2 +fi + + +# now make partitions. +if [ -b ${PARTITION1} ]; then + umount ${PARTITION1} + mkfs.vfat -F 32 -n "boot" ${PARTITION1} +else + echo "Cant find boot partition in /dev" +fi + +if [ -b ${PARITION2} ]; then + umount ${PARTITION2} + mkfs.ext4 -L "Sabayon" ${PARTITION2} +else + echo "Cant find rootfs partition in /dev" +fi + diff --git a/scripts/mkloopcard.sh b/scripts/mkloopcard.sh new file mode 100755 index 0000000..eb06d7a --- /dev/null +++ b/scripts/mkloopcard.sh @@ -0,0 +1,325 @@ +#! /bin/bash +# (c) Copyright 2012 Fabio Erculiani +# Licensed under terms of GPLv2 + +/usr/sbin/env-update +. /etc/profile + +export LC_ALL=en_US.UTF-8 + +# Path to molecules.git dir +SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" +export SABAYON_MOLECULE_HOME + +# Expected env variables: +# PATHS_TO_REMOVE = ";" separated list of paths to rm -rf +# PATHS_TO_EMPTY = ";" separated list of paths to rm -rf (keeping the dir) +# RELEASE_STRING +# RELEASE_VERSION +# RELEASE_DESC +# RELEASE_FILE +# IMAGE_NAME +# DESTINATION_IMAGE_DIR +# PACKAGES_TO_ADD +# PACKAGES_TO_REMOVE + +if [ ${#} -ne 5 ]; then + echo "usage: ${0} " + exit 1 +fi + +CHROOT_SCRIPT="${1}" +if [ ! -x "${CHROOT_SCRIPT}" ]; then + echo "${CHROOT_SCRIPT} is not executable" + exit 1 +fi +FILE="${2}" +SIZE="${3}" +BOOT_DIR="${4}" +CHROOT_DIR="${5}" +# Should we make a tarball of the rootfs and bootfs? +MAKE_TARBALL="${MAKE_TARBALL:-0}" +SD_FUSE="${SD_FUSE:-}" +DTB_FILES="${DTB_FILES:-}" +# Boot partition type +FIRST_PARTITION_START_CYL="${FIRST_PARTITION_START_CYL:-0}" +BOOT_PART_TYPE="${BOOT_PART_TYPE:-vfat}" +BOOT_PART_TYPE_MBR="${BOOT_PART_TYPE_MBR:-0x0C}" +BOOT_PART_MKFS_ARGS="${BOOT_PART_MKFS_ARGS:--n boot -F 32}" +# Root partition type +ROOT_PART_TYPE="${ROOT_PART_TYPE:-ext4}" +ROOT_PART_MKFS_ARGS="${ROOT_PART_MKFS_ARGS:--L Sabayon}" +# Copy /boot content from Root partition to Boot partition? +BOOT_PART_TYPE_INSIDE_ROOT="${BOOT_PART_TYPE_INSIDE_ROOT:-}" + +# Using /tmp is bad and triggers monitoring notifications +export TMPDIR=/var/tmp + +cleanup_loopbacks() { + cd / + sync + sync + sleep 5 + sync + [[ -n "${tmp_file}" ]] && rm "${tmp_file}" 2> /dev/null + [[ -n "${tmp_dir}" ]] && { umount "${tmp_dir}/proc" &> /dev/null; } + [[ -n "${tmp_dir}" ]] && { umount "${tmp_dir}" &> /dev/null; rmdir "${tmp_dir}" &> /dev/null; } + [[ -n "${boot_tmp_dir}" ]] && { umount "${boot_tmp_dir}" &> /dev/null; rmdir "${boot_tmp_dir}" &> /dev/null; } + sleep 1 + [[ -n "${boot_part}" ]] && losetup -d "${boot_part}" 2> /dev/null + [[ -n "${root_part}" ]] && losetup -d "${root_part}" 2> /dev/null + [[ -n "${DRIVE}" ]] && losetup -d "${DRIVE}" 2> /dev/null + # make sure to have run this + [[ -n "${tmp_dir}" ]] && CHROOT_DIR="${tmp_dir}" "${SABAYON_MOLECULE_HOME}"/scripts/mmc_remaster_post.sh +} +trap "cleanup_loopbacks" 1 2 3 6 9 14 15 EXIT + +# Erase the file +echo "Generating the empty image file at ${FILE}" +dd if=/dev/zero of="${FILE}" bs=1024000 count="${SIZE}" || exit 1 + +DRIVE=$(losetup -f "${FILE}" --show) +if [ -z "${DRIVE}" ]; then + echo "Cannot execute losetup for $FILE" + exit 1 +fi + +echo "Configured the loopback partition at ${DRIVE}" + +# Calculate size using fdisk +SIZE=$(fdisk -l "${DRIVE}" | grep Disk | grep bytes | awk '{print $5}') +CYLINDERS=$((SIZE/255/63/512)) +BOOTPART_CYLS=9 +ENDSECT=$(( 144584 + (EMPTYSIZE/512) )) + +echo "Disk size : ${SIZE} bytes" +echo "Disk cyls : ${CYLINDERS}" +echo "Boot p. cyls : ${BOOTPART_CYLS}" +echo "Boot p. start cyls : ${FIRST_PARTITION_START_CYL}" +echo "End block : ${ENDSECT} block" + +{ +echo ${FIRST_PARTITION_START_CYL},${BOOTPART_CYLS},${BOOT_PART_TYPE_MBR},* +echo $(( BOOTPART_CYLS + FIRST_PARTITION_START_CYL )),,,- +} | "${SABAYON_MOLECULE_HOME}"/bin/sfdisk -D -H 255 -S 63 -C ${CYLINDERS} ${DRIVE} + +sleep 2 + +BOOT_STARTBLOCK=$(fdisk -l "${DRIVE}" | grep "${DRIVE}p1" | awk '{print $3}') +if [ -z "${BOOT_STARTBLOCK}" ]; then + echo "No BOOT_STARTBLOCK" >&2 + exit 1 +fi +BOOT_ENDBLOCK=$(fdisk -l "${DRIVE}" | grep "${DRIVE}p1" | awk '{print $4}') +if [ -z "${BOOT_ENDBLOCK}" ]; then + echo "No BOOT_ENDBLOCK" >&2 + exit 1 +fi + +BOOT_STARTOFFSET=$(( BOOT_STARTBLOCK * 512 )) +BOOT_ENDOFFSET=$(( BOOT_ENDBLOCK * 512 )) +BOOT_MAGICSIZE=$(( BOOT_ENDOFFSET - BOOT_STARTOFFSET )) +echo "Boot start offset : ${BOOT_STARTOFFSET} bytes" +echo "Boot start block : ${BOOT_STARTBLOCK} block" +echo "Boot end block : ${BOOT_ENDBLOCK} block" +echo "Boot size : ${BOOT_MAGICSIZE} bytes" + +ROOT_STARTBLOCK=$(fdisk -l "${DRIVE}" | grep "${DRIVE}p2" | awk '{print $2}') +if [ -z "${ROOT_STARTBLOCK}" ]; then + echo "No ROOT_STARTBLOCK" >&2 + exit 1 +fi +ROOT_ENDBLOCK=$(fdisk -l "${DRIVE}" | grep "${DRIVE}p2" | awk '{print $3}') +if [ -z "${ROOT_ENDBLOCK}" ]; then + echo "No ROOT_ENDBLOCK" >&2 + exit 1 +fi + +ROOT_STARTOFFSET=$(( ROOT_STARTBLOCK * 512 )) +ROOT_ENDOFFSET=$(( ROOT_ENDBLOCK * 512 )) +ROOT_MAGICSIZE=$(( ROOT_ENDOFFSET - ROOT_STARTOFFSET )) +echo "Root start offset : ${ROOT_STARTOFFSET} bytes" +echo "Root start block : ${ROOT_STARTBLOCK} block" +echo "Root end block : ${ROOT_ENDBLOCK} block" +echo "Root size : ${ROOT_MAGICSIZE} bytes" + +# Get other two loopback devices first +boot_part=$(losetup -f --offset "${BOOT_STARTOFFSET}" --sizelimit "${BOOT_MAGICSIZE}" "${FILE}" --show) +if [ -z "${boot_part}" ]; then + echo "Cannot setup the boot partition loopback" + exit 1 +fi + +root_part=$(losetup -f --offset "${ROOT_STARTOFFSET}" --sizelimit "${ROOT_MAGICSIZE}" "${FILE}" --show) +if [ -z "${root_part}" ]; then + echo "Cannot setup the ${ROOT_PART_TYPE} partition loopback" + exit 1 +fi + +echo "Boot Partiton at : ${boot_part}" +echo "Root Partition at : ${root_part}" + +# Format boot +echo "Formatting ${BOOT_PART_TYPE} ${boot_part}..." +"mkfs.${BOOT_PART_TYPE}" ${BOOT_PART_MKFS_ARGS} "${boot_part}" || exit 1 + +# Format rootfs +echo "Formatting ${ROOT_PART_TYPE} ${root_part}..." +"mkfs.${ROOT_PART_TYPE}" ${ROOT_PART_MKFS_ARGS} "${root_part}" || exit 1 + +sleep 2 +sync + +boot_tmp_dir=$(mktemp -d --suffix="boot_tmp_dir") +if [[ -z "${boot_tmp_dir}" ]]; then + echo "Cannot create temporary dir (boot)" + exit 1 +fi +chmod 755 "${boot_tmp_dir}" || exit 1 + +tmp_dir=$(mktemp -d --suffix="root_tmp_dir") +if [[ -z "${tmp_dir}" ]]; then + echo "Cannot create temporary dir" + exit 1 +fi +chmod 755 "${tmp_dir}" || exit 1 + +echo "Setting up the boot directory content, mounting on ${boot_tmp_dir}" +mount "${boot_part}" "${boot_tmp_dir}" +cp -R "${BOOT_DIR}"/* "${boot_tmp_dir}"/ || exit 1 + +echo "Setting up the rootfs directory content, mounting on ${tmp_dir}" +mount "${root_part}" "${tmp_dir}" +rsync -a -H -A -X --delete-during "${CHROOT_DIR}"/ "${tmp_dir}"/ --exclude "/proc/*" --exclude "/sys/*" \ + --exclude "/dev/pts/*" --exclude "/dev/shm/*" || exit 1 + +CHROOT_DIR="${tmp_dir}" "${SABAYON_MOLECULE_HOME}"/scripts/remaster_pre.sh || exit 1 + +# execute PACKAGES_TO_ADD and PACKAGES_TO_REMOVE +export ETP_NONINTERACTIVE=1 +# Entropy doesn't like non-UTF locale encodings +export LC_ALL=en_US.UTF-8 + +# do I have to run "equo update?" +# If we are running outside the DAILY scope, it's +# better to do it here. If instead we're doing a +# DAILY, this is already done by other scripts. +if [ -z "${BUILDING_DAILY}" ]; then + FORCE_EAPI=2 chroot "${tmp_dir}" equo update || \ + FORCE_EAPI=2 chroot "${tmp_dir}" equo update || \ + exit 1 +fi + +if [ -n "${PACKAGES_TO_ADD}" ]; then + add_cmd="equo install ${PACKAGES_TO_ADD}" + chroot "${tmp_dir}" ${add_cmd} || exit 1 +fi +if [ -n "${PACKAGES_TO_REMOVE}" ]; then + rem_cmd="equo remove ${PACKAGES_TO_REMOVE}" + chroot "${tmp_dir}" ${rem_cmd} || exit 1 +fi + +# execute CHROOT_SCRIPT hook inside chroot +chroot_script_name=$(basename "${CHROOT_SCRIPT}") +target_chroot_script="${tmp_dir}"/"${chroot_script_name}" +chroot_hook_inc_name="mkloopcard_chroot.include" +chroot_hook_include="${SABAYON_MOLECULE_HOME}/scripts/${chroot_hook_inc_name}" +target_chroot_hook_inc="${tmp_dir}/${chroot_hook_inc_name}" +cp -p "${chroot_hook_include}" "${target_chroot_hook_inc}" || exit 1 +chmod 0700 "${target_chroot_hook_inc}" || exit 1 +cp -p "${CHROOT_SCRIPT}" "${target_chroot_script}" || exit 1 +chmod 0700 "${target_chroot_script}" || exit 1 +chown root "${target_chroot_script}" || exit 1 +chroot "${tmp_dir}" "/${chroot_script_name}" || exit 1 +rm -f "${target_chroot_script}" "${target_chroot_hook_inc}" + +CHROOT_DIR="${tmp_dir}" "${SABAYON_MOLECULE_HOME}"/scripts/mmc_remaster_post.sh + +# execute final cleanup of entropy stuff +chroot "${tmp_dir}" equo rescue vacuum +chroot "${tmp_dir}" equo cleanup + +# setup sudoers, enable wheel group +if [ -f "${tmp_dir}/etc/sudoers" ]; then + echo "# added by Sabayon Molecule" >> "${tmp_dir}/etc/sudoers" + echo "%wheel ALL=ALL" >> "${tmp_dir}/etc/sudoers" +fi + +export LC_ALL=C + +# work out paths to empty and paths to remove +if [ -n "${PATHS_TO_REMOVE}" ]; then + set -f + for path in $(echo ${PATHS_TO_REMOVE} | tr ";" "\n"); do + echo "Removing: ${path}" + set +f + rm -rf "${tmp_dir}"/${path} + set -f + done + set +f +fi +if [ -n "${PATHS_TO_EMPTY}" ]; then + set -f + for path in $(echo ${PATHS_TO_EMPTY} | tr ";" "\n"); do + set +f + echo "Emptying: ${path}" + rm -rf "${tmp_dir}"/"${path}"/* + set -f + done + set +f +fi + +if [ -n "${RELEASE_FILE}" ]; then + release_file="${tmp_dir}"/"${RELEASE_FILE}" + release_dir=$(dirname "${release_file}") + [[ ! -d "${release_dir}" ]] && { mkdir -p "${release_dir}" || exit 1; } + echo "${RELEASE_STRING} ${RELEASE_VERSION} ${RELEASE_DESC}" > "${release_file}" +fi + +for dtb in ${DTB_FILES}; do + echo "Requested to copy dtb: ${dtb}" + # expect to have just one kernel installed + dtb_files=$(find "${tmp_dir}/lib/dts" -name "${dtb}" -print) + for dtb_file in ${dtb_files}; do + echo "Copying dtb: ${dtb_file} to ${tmp_dir}/boot/" + cp "${dtb_file}" "${tmp_dir}/boot/" || exit 1 + done +done + +# BOOT_PART_TYPE_INSIDE_ROOT +if [ -n "${BOOT_PART_TYPE_INSIDE_ROOT}" ]; then + echo "Copying data from ${tmp_dir}/boot to ${boot_tmp_dir} as requested..." + if [ "${BOOT_PART_TYPE}" = "vfat" ]; then + cp -rL "${tmp_dir}/boot/"* "${boot_tmp_dir}/" || exit 1 + else + cp -rp "${tmp_dir}/boot/"* "${boot_tmp_dir}/" || exit 1 + fi +fi + +umount "${boot_tmp_dir}" || exit 1 + +echo "Umounting cruft..." +umount -f "${tmp_dir}/"{proc,sys,dev/shm,dev/pts} + +if [ -n "${DESTINATION_IMAGE_DIR}" ] && [ "${MAKE_TARBALL}" = "1" ]; then + # Create the rootfs tarball + ROOTFS_TARBALL="${DESTINATION_IMAGE_DIR}/${IMAGE_NAME}.rootfs.tar.xz" + echo "Creating the roofs tarball: ${ROOTFS_TARBALL}" + tmp_file=$(mktemp --suffix=.tar.xz) + [[ -z "${tmp_file}" ]] && exit 1 + cd "${tmp_dir}" || exit 1 + tar --one-file-system --numeric-owner --preserve-permissions --same-owner -cJf "${tmp_file}" ./ || exit 1 + mv "${tmp_file}" "${ROOTFS_TARBALL}" || exit 1 + chmod 644 "${ROOTFS_TARBALL}" || exit 1 + cd "$(dirname "${ROOTFS_TARBALL}")" || exit 1 + md5sum "$(basename "${ROOTFS_TARBALL}")" > "$(basename "${ROOTFS_TARBALL}")".md5 +fi + +umount "${tmp_dir}" || exit 1 + +if [ -n "${SD_FUSE}" ] && [ -x "${SD_FUSE}" ]; then + "${SD_FUSE}" "${DRIVE}" || exit 1 +fi + +cleanup_loopbacks +echo "Your MMC image \"${FILE}\" is ready" diff --git a/scripts/mkloopcard_chroot.include b/scripts/mkloopcard_chroot.include new file mode 100644 index 0000000..77f4ba1 --- /dev/null +++ b/scripts/mkloopcard_chroot.include @@ -0,0 +1,82 @@ +#!/bin/bash + +sd_enable() { + local srv="${1}" + local ext=".${2:-service}" + [[ -x /usr/bin/systemctl ]] && \ + systemctl --no-reload enable -f "${srv}${ext}" +} + +sd_disable() { + local srv="${1}" + local ext=".${2:-service}" + [[ -x /usr/bin/systemctl ]] && \ + systemctl --no-reload disable -f "${srv}${ext}" +} + +setup_displaymanager() { + if [ -n "$(equo match --installed gnome-base/gdm -qv)" ]; then + sd_enable gdm + elif [ -n "$(equo match --installed lxde-base/lxdm -qv)" ]; then + sd_enable lxdm + elif [ -n "$(equo match --installed x11-misc/lightdm-base -qv)" ]; then + sd_enable lightdm + elif [ -n "$(equo match --installed kde-base/kdm -qv)" ]; then + sd_enable kdm + else + sd_enable xdm + fi +} + +setup_desktop_environment() { + local session= + if [ -f "/usr/share/xsessions/LXDE.desktop" ]; then + session="LXDE" + elif [ -f "/usr/share/xsessions/xfce.desktop" ]; then + session="xfce" + elif [ -f "/usr/share/xsessions/gnome.desktop" ]; then + session="gnome" + elif [ -f "/usr/share/xsessions/mate.desktop" ]; then + session="mate" + elif [ -f "/usr/share/xsessions/KDE-4.desktop" ]; then + session="KDE-4" + fi + + if [ -n "${session}" ]; then + echo "[Desktop]" > /etc/skel/.dmrc || return 1 + echo "Session=${session}" >> /etc/skel/.dmrc || return 1 + fi +} + +setup_bootfs_fstab() { + # add /dev/mmcblk0p1 to /etc/fstab + local boot_part_type="${1}" + echo "/dev/mmcblk0p1 /boot ${boot_part_type} defaults 0 2" >> /etc/fstab +} + + +setup_boot() { + sd_enable sshd + sd_enable vixie-cron + sd_enable NetworkManager + #eselect uimage set 1 +} + +setup_users() { + # setup root password to... root! + echo root:root | chpasswd + # setup normal user "sabayon" + ( + if [ ! -x "/sbin/sabayon-functions.sh" ]; then + echo "no /sbin/sabayon-functions.sh found" + exit 1 + fi + . /sbin/sabayon-functions.sh + sabayon_setup_live_user "sabayon" || exit 1 + # setup "sabayon" password to... sabayon! + echo "sabayon:sabayon" | chpasswd + + # also add "sabayon" to disk group + usermod -a -G disk sabayon + ) || return 1 +} diff --git a/scripts/mkloopcard_generic_hook.sh b/scripts/mkloopcard_generic_hook.sh new file mode 100755 index 0000000..d3f5e51 --- /dev/null +++ b/scripts/mkloopcard_generic_hook.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +/usr/sbin/env-update +. /etc/profile + +. /mkloopcard_chroot.include || exit 1 + +setup_displaymanager +setup_desktop_environment +setup_users +setup_boot +#setup_bootfs_fstab "vfat" +#wget http://builder.mdrjr.net/tools/kernel-update.sh -O /usr/local/sbin/kernel-update.sh +#chmod +x /usr/local/sbin/kernel-update.sh +#/usr/local/sbin/kernel-update.sh + +exit 0 diff --git a/scripts/mkloopcard_raspberry_chroot_hook.sh b/scripts/mkloopcard_raspberry_chroot_hook.sh new file mode 100755 index 0000000..ebd68ed --- /dev/null +++ b/scripts/mkloopcard_raspberry_chroot_hook.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +/usr/sbin/env-update +. /etc/profile + +. /mkloopcard_chroot.include || exit 1 + +#setup_boot +#setup_users +#setup_bootfs_fstab "vfat" +# For kodi-raspberrypi +#echo 'SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"' > rpi2/etc/udev/rules.d/10-vchiq-permissions.rules +#usermod -a -G video sabayon + +#/usr/sbin/rpi-update +#timedatectl set-ntp true + +echo -5 | equo conf update +equo cleanup + +exit 0 diff --git a/scripts/mmc_remaster_post.sh b/scripts/mmc_remaster_post.sh new file mode 100755 index 0000000..36e0090 --- /dev/null +++ b/scripts/mmc_remaster_post.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# Path to molecules.git dir +SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" +export SABAYON_MOLECULE_HOME + +PKGS_DIR="${SABAYON_MOLECULE_HOME}/pkgcache" +CHROOT_PKGS_DIR="${CHROOT_DIR}/var/lib/entropy/client/packages" + +# remove entropy hwash +rm -f "${CHROOT_DIR}"/etc/entropy/.hw.hash +# remove entropy pid file +rm -f "${CHROOT_DIR}"/var/run/entropy/entropy.lock + +echo "Umounting bind to ${CHROOT_PKGS_DIR}" +umount "${CHROOT_PKGS_DIR}" || exit 1 + +exit 0 diff --git a/scripts/odroid_c2_image_generator_script.sh b/scripts/odroid_c2_image_generator_script.sh new file mode 100755 index 0000000..2d0f913 --- /dev/null +++ b/scripts/odroid_c2_image_generator_script.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Path to molecules.git dir +SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" +export SABAYON_MOLECULE_HOME + +# rootfs and bootfs tarball is generated by image +export FIRST_PARTITION_START_CYL=1 # ~8Mb +export SD_FUSE="${SABAYON_MOLECULE_HOME}/boot/arm/udooneo/sd_fuse/sd_fusing.sh" +export BOOT_PART_TYPE_INSIDE_ROOT="1" +exec "${SABAYON_MOLECULE_HOME}"/scripts/mkloopcard.sh "${SABAYON_MOLECULE_HOME}"/scripts/mkloopcard_odroid_generic_hook.sh "${@}" diff --git a/scripts/odroid_u2_x2_image_generator_script.sh b/scripts/odroid_u2_x2_image_generator_script.sh new file mode 100755 index 0000000..3585172 --- /dev/null +++ b/scripts/odroid_u2_x2_image_generator_script.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Path to molecules.git dir +SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" +export SABAYON_MOLECULE_HOME + +# rootfs and bootfs tarball is generated by beaglebone image +export FIRST_PARTITION_START_CYL=1 # ~8Mb +export SD_FUSE="${SABAYON_MOLECULE_HOME}/boot/arm/odroid-u2-x2/sd_fuse/sd_fusing.sh" +export BOOT_PART_TYPE_INSIDE_ROOT="1" +exec "${SABAYON_MOLECULE_HOME}"/scripts/mkloopcard.sh "${SABAYON_MOLECULE_HOME}"/scripts/mkloopcard_generic_hook.sh "${@}" diff --git a/scripts/outer_source_chroot_script_arm.sh b/scripts/outer_source_chroot_script_arm.sh new file mode 100755 index 0000000..ab76dd8 --- /dev/null +++ b/scripts/outer_source_chroot_script_arm.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +/usr/sbin/env-update +. /etc/profile + +# Execute this here due to technical problems with qemu-user + +# Update /usr/portage/profiles +# This is actually not strictly needed but several +# gentoo tools expect to find valid /etc/make.profile symlink +# This part is best effort, if it will be able to complete +# correctly, fine. +# For a list of mirrors, see: http://www.gentoo.org/main/en/mirrors-rsync.xml +RSYNC_URI="rsync://rsync.at.gentoo.org/gentoo-portage/profiles" +PROFILES_DIR="${CHROOT_DIR}/usr/portage/profiles" +for x in $(seq 5); do + rsync -av -H -A -X --delete-during "${RSYNC_URI}/" "${PROFILES_DIR}/" && break + sleep 1m || exit 1 +done + +exit 0 diff --git a/scripts/post_mmc_image_script.sh b/scripts/post_mmc_image_script.sh new file mode 100755 index 0000000..bb5e1d2 --- /dev/null +++ b/scripts/post_mmc_image_script.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Compress the freaking MMC image using xz +# +# Available env vars: +# IMAGE_PATH = path to generated image +# IMAGE_CHECKSUM_PATH = path to generated md5 for image +# + +/usr/sbin/env-update +. /etc/profile + +COMPRESSED_IMAGE_PATH="${IMAGE_PATH}.xz" +COMPRESSED_IMAGE_CHECKSUM_PATH="${COMPRESSED_IMAGE_PATH}.md5" + +echo +echo "Spawning xz --compress --force -3 for:" +echo "IMAGE_PATH = ${IMAGE_PATH}" +echo "COMPRESSED_IMAGE_PATH = ${COMPRESSED_IMAGE_PATH}" +echo "COMPRESSED_IMAGE_CHECKSUM_PATH = ${COMPRESSED_IMAGE_CHECKSUM_PATH}" +echo + +xz --compress --force -3 "${IMAGE_PATH}" || exit 1 +[[ ! -f "${COMPRESSED_IMAGE_PATH}" ]] && { echo "${COMPRESSED_IMAGE_PATH} not found"; exit 1; } + +chmod 644 "${COMPRESSED_IMAGE_PATH}" || exit 1 + +cd "$(dirname "${COMPRESSED_IMAGE_PATH}")" || exit 1 +img_name=$(basename "${COMPRESSED_IMAGE_PATH}") +# make sure to not leave zombies +rm -f "${img_name}.md5" +md5sum "${img_name}" > "${COMPRESSED_IMAGE_CHECKSUM_PATH}" || exit 1 + +echo "All done" + +exit ${?} + diff --git a/scripts/pre_mmc.sh b/scripts/pre_mmc.sh new file mode 100644 index 0000000..cd6ae30 --- /dev/null +++ b/scripts/pre_mmc.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +rm -rfv "${DESTINATION_IMAGE_DIR}"/usr/bin/qemu-arm-binfmt || die + +exit 0 diff --git a/scripts/raspberry_image_generator_script.sh b/scripts/raspberry_image_generator_script.sh new file mode 100755 index 0000000..78bb05e --- /dev/null +++ b/scripts/raspberry_image_generator_script.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Path to molecules.git dir +SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" +export SABAYON_MOLECULE_HOME + +# sigh vfat +export BOOT_PART_TYPE_INSIDE_ROOT="1" + +exec "${SABAYON_MOLECULE_HOME}"/scripts/mkloopcard.sh "${SABAYON_MOLECULE_HOME}"/scripts/mkloopcard_raspberry_chroot_hook.sh "${@}" diff --git a/scripts/remaster_error_script.sh b/scripts/remaster_error_script.sh new file mode 100755 index 0000000..321aa33 --- /dev/null +++ b/scripts/remaster_error_script.sh @@ -0,0 +1,11 @@ +#!/bin/sh +if [ -d "${CHROOT_DIR}/proc" ]; then + echo "Unmounting ${CHROOT_DIR}/proc" + umount "${CHROOT_DIR}/proc" +fi + +CHROOT_PKGS_DIR="${CHROOT_DIR}/var/lib/entropy/client/packages" +if [ -d "${CHROOT_PKGS_DIR}" ]; then + echo "Umounting bind to ${CHROOT_PKGS_DIR}" + umount "${CHROOT_PKGS_DIR}" || exit 1 +fi diff --git a/scripts/remaster_post.sh b/scripts/remaster_post.sh new file mode 100755 index 0000000..9df0915 --- /dev/null +++ b/scripts/remaster_post.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# Path to molecules.git dir +SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" +export SABAYON_MOLECULE_HOME + +PKGS_DIR="${SABAYON_MOLECULE_HOME}/pkgcache" +CHROOT_PKGS_DIR="${CHROOT_DIR}/var/lib/entropy/client/packages" + +# load common stuff +. "${SABAYON_MOLECULE_HOME}"/scripts/remaster_post_common.sh + +# make sure to not leak /proc +umount "${CHROOT_DIR}/proc" &> /dev/null +umount "${CHROOT_DIR}/proc" &> /dev/null +umount "${CHROOT_DIR}/proc" &> /dev/null + +echo "Umounting bind to ${CHROOT_PKGS_DIR}" +umount "${CHROOT_PKGS_DIR}" || exit 1 + +exit 0 diff --git a/scripts/remaster_post_common.sh b/scripts/remaster_post_common.sh new file mode 100755 index 0000000..86f618e --- /dev/null +++ b/scripts/remaster_post_common.sh @@ -0,0 +1,31 @@ +# switch to sabayon-weekly repository if the ISO is not a DAILY one +# BUILDING_DAILY is set in scripts/daily_iso_build.sh +if [ -z "${BUILDING_DAILY}" ]; then + # only the first occurence + repo_conf="${CHROOT_DIR}/etc/entropy/repositories.conf" + sed -i "/^officialrepositoryid/ s/sabayonlinux.org/sabayon-weekly/" "${repo_conf}" || exit 1 + sed -i "/^official-repository-id/ s/sabayonlinux.org/sabayon-weekly/" "${repo_conf}" || exit 1 + + # new style repository config files (inside + # repositories.conf.d/ directory) + repo_conf_d="${CHROOT_DIR}/etc/entropy/repositories.conf.d" + src_conf="${repo_conf_d}/entropy_sabayonlinux.org" + dst_conf="${repo_conf_d}/entropy_sabayon-weekly" + if [ -f "${src_conf}" ]; then + mv "${src_conf}" "${dst_conf}" || exit 1 + sed -i "/^\[sabayonlinux.org\]$/ s/sabayonlinux.org/sabayon-weekly/" \ + "${dst_conf}" || exit 1 + fi +fi + +# remove entropy hwash +rm -f "${CHROOT_DIR}"/etc/entropy/.hw.hash +# remove entropy pid file +rm -f "${CHROOT_DIR}"/run/entropy/entropy.lock + +# remove /run/* and /var/lock/* +# systemd mounts them using tmpfs +rm -rf "${CHROOT_DIR}"/run/* +rm -rf "${CHROOT_DIR}"/var/lock/* + +# do not exit!! this file is sourced! diff --git a/scripts/remaster_pre.sh b/scripts/remaster_pre.sh new file mode 100755 index 0000000..d11458c --- /dev/null +++ b/scripts/remaster_pre.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# Path to molecules.git dir +SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" +export SABAYON_MOLECULE_HOME + +PKGS_DIR="${SABAYON_MOLECULE_HOME}/pkgcache" +CHROOT_PKGS_DIR="${CHROOT_DIR}/var/lib/entropy/client/packages" + +[[ ! -d "${PKGS_DIR}" ]] && mkdir -p "${PKGS_DIR}" +[[ ! -d "${CHROOT_PKGS_DIR}" ]] && mkdir -p "${CHROOT_PKGS_DIR}" + +# make sure it's all clean before mounting +echo "Mounting bind to ${CHROOT_PKGS_DIR}" +mkdir -p "${CHROOT_PKGS_DIR}" || exit 1 +mount --bind "${PKGS_DIR}" "${CHROOT_PKGS_DIR}" || exit 1 + +content=$(ls -1 "${CHROOT_DIR}/proc" | wc -l) +if [ "${content}" -le 3 ]; then + echo "Mounting /proc ..." + mount -t proc proc "${CHROOT_DIR}/proc" +fi + +exit 0 diff --git a/scripts/udoo_neo_image_generator_script.sh b/scripts/udoo_neo_image_generator_script.sh new file mode 100755 index 0000000..89b7ae9 --- /dev/null +++ b/scripts/udoo_neo_image_generator_script.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Path to molecules.git dir +SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" +export SABAYON_MOLECULE_HOME + +# rootfs and bootfs tarball is generated by image +export FIRST_PARTITION_START_CYL=1 # ~8Mb +export SD_FUSE="${SABAYON_MOLECULE_HOME}/boot/arm/odroid-c2/sd_fuse/sd_fusing.sh" +export BOOT_PART_TYPE_INSIDE_ROOT="1" +exec "${SABAYON_MOLECULE_HOME}"/scripts/mkloopcard.sh "${SABAYON_MOLECULE_HOME}"/scripts/mkloopcard_generic_hook.sh "${@}"