From be4bfa0c13174b4d6c514df30098ab33a1553d8f Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Mon, 2 May 2016 12:14:23 -0700 Subject: [PATCH 01/10] Addede comments and default image name --- build.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/build.sh b/build.sh index e3f7a6e..568ccbc 100755 --- a/build.sh +++ b/build.sh @@ -3,8 +3,13 @@ run_sub_stage() { log "Begin ${SUB_STAGE_DIR}" + pushd ${SUB_STAGE_DIR} > /dev/null + + # Loop through each substage for i in {00..99}; do + + # Check for debconf stage if [ -f ${i}-debconf ]; then log "Begin ${SUB_STAGE_DIR}/${i}-debconf" on_chroot sh -e - << EOF @@ -14,6 +19,8 @@ SELEOF EOF log "End ${SUB_STAGE_DIR}/${i}-debconf" fi + + # Install any packages with no-install-recommends set if [ -f ${i}-packages-nr ]; then log "Begin ${SUB_STAGE_DIR}/${i}-packages-nr" PACKAGES=`cat $i-packages-nr | tr '\n' ' '` @@ -24,6 +31,8 @@ EOF fi log "End ${SUB_STAGE_DIR}/${i}-packages-nr" fi + + # Install any packages normally if [ -f ${i}-packages ]; then log "Begin ${SUB_STAGE_DIR}/${i}-packages" PACKAGES=`cat $i-packages | tr '\n' ' '` @@ -34,6 +43,8 @@ EOF fi log "End ${SUB_STAGE_DIR}/${i}-packages" fi + + # Apply any patches if [ -d ${i}-patches ]; then log "Begin ${SUB_STAGE_DIR}/${i}-patches" pushd ${STAGE_WORK_DIR} > /dev/null @@ -60,11 +71,15 @@ EOF popd > /dev/null log "End ${SUB_STAGE_DIR}/${i}-patches" fi + + # Run the substages run script if [ -x ${i}-run.sh ]; then log "Begin ${SUB_STAGE_DIR}/${i}-run.sh" ./${i}-run.sh log "End ${SUB_STAGE_DIR}/${i}-run.sh" fi + + # Run the substages chroot script if [ -f ${i}-run-chroot ]; then log "Begin ${SUB_STAGE_DIR}/${i}-run-chroot" on_chroot sh -e - < ${i}-run-chroot @@ -77,49 +92,77 @@ EOF run_stage(){ log "Begin ${STAGE_DIR}" + pushd ${STAGE_DIR} > /dev/null + + # Unmount this stage's folder on the filesystem unmount ${WORK_DIR}/${STAGE} + + # Set the working directory for this stage STAGE_WORK_DIR=${WORK_DIR}/${STAGE} + + # Set the root directory for this stage ROOTFS_DIR=${STAGE_WORK_DIR}/rootfs + + # Check to see if we should skip this stage (seemingly never) if [ ! -f SKIP ]; then + + # Clean the rootfs, if requested if [ "${CLEAN}" = "1" ]; then if [ -d ${ROOTFS_DIR} ]; then rm -rf ${ROOTFS_DIR} fi fi + + # Run the pre-run script if [ -x prerun.sh ]; then log "Begin ${STAGE_DIR}/prerun.sh" ./prerun.sh log "End ${STAGE_DIR}/prerun.sh" fi + + # For each substage, run the run_sub_stage command for it for SUB_STAGE_DIR in ${STAGE_DIR}/*; do if [ -d ${SUB_STAGE_DIR} ]; then run_sub_stage fi done fi + + # Unmount the stag again unmount ${WORK_DIR}/${STAGE} + + # Set the previous stage info to this stage for the next stage to use PREV_STAGE=${STAGE} PREV_STAGE_DIR=${STAGE_DIR} PREV_ROOTFS_DIR=${ROOTFS_DIR} + popd > /dev/null + log "End ${STAGE_DIR}" } +# Require Root to run if [ "$(id -u)" != "0" ]; then echo "Please run as root" 1>&2 exit 1 fi +# Source a config file if it exists if [ -f config ]; then source config fi +# Set image name +#TODO: Add way to set this, plus defaults. Defaulting to raspbian for now +IMG_NAME="raspbian" + if [ -z "${IMG_NAME}" ]; then echo "IMG_NAME not set" 1>&2 exit 1 fi +# Set other env variables export IMG_DATE=${IMG_DATE:-"$(date -u +%Y-%m-%d)"} export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -151,9 +194,11 @@ export -f on_chroot export -f copy_previous export -f update_issue +# Create working directory mkdir -p ${WORK_DIR} log "Begin ${BASE_DIR}" +# Successively build each stage for STAGE_DIR in ${BASE_DIR}/stage*; do STAGE=$(basename ${STAGE_DIR}) run_stage From 953a40e0036df685cfd34cc39e31dcda587c9185 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Mon, 2 May 2016 12:15:13 -0700 Subject: [PATCH 02/10] Created an initial script that builds an image from a generated stage rootfs --- create-image.sh | 157 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100755 create-image.sh diff --git a/create-image.sh b/create-image.sh new file mode 100755 index 0000000..300dd03 --- /dev/null +++ b/create-image.sh @@ -0,0 +1,157 @@ +#!/bin/bash + +for i in "$@" +do +case $i in + # Path to the working directory from which to build the image + -p=*|--path=*) + WORKSPACE_PATH="${i#*=}" + shift + ;; + + # Name for image + -n=*|--name=*) + IMAGE_NAME="${i#*=}" + shift + ;; + + # unknown option + *) + ;; +esac +done + +if [ ${EUID} -ne 0 ]; then + echo "this tool must be run as root" + exit 1 +fi + +if [ -z "$IMAGE_NAME" ] +then + echo "No image name specified, defaulting to \"raspbian\"" + IMAGE_NAME="raspbian" +fi + +if [ -z "$WORKSPACE_PATH" ] +then + echo "You must specify a workspace path. Ex) --path=./work/2016-05-02-openrov/stage3" + exit 2 +fi + +work_path=$(readlink -f $WORKSPACE_PATH) + +if [ ! -d "$work_path" ] +then + echo "Error resolving workspace path. Does not exist: work_path=\"${work_path}\"" + exit 3 +fi + +echo "Creating image using rootfs in: ${work_path}" + +bootsize="64M" +deb_release="jessie" + +mkdir -p rpi + +# define destination folder where created image file will be stored +buildenv="${PWD}/rpi" + +# Set directory of rootfs and bootfs +rootfs="${buildenv}/rootfs" +bootfs="${buildenv}/boot" + +today=`date +%Y%m%d` + +mkdir -p ${buildenv} + +# Construct image name +image="${buildenv}/images/${IMAGE_NAME}_${deb_release}_${today}.img" + +# Create a blank image file +dd if=/dev/zero of=${image} bs=1MB count=3800 + +# Mount it on the loop back adapter +device=`losetup -f --show ${image}` + +echo "image ${image} created and mounted as ${device}" + +# Set up partition descriptor +fdisk ${device} << EOF +n +p +1 + ++${bootsize} +t +c +n +p +2 + + +w +EOF + + +if [ "${image}" != "" ]; then + # Delete the loopback device + losetup -d ${device} + + # Mount the disk image + device=`kpartx -va ${image} | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1` + echo device + device="/dev/mapper/${device}" + echo device + + # Get paths to boot and root partitions + bootp=${device}p1 + rootp=${device}p2 +fi + +# Create the filesystems +mkfs.vfat ${bootp} +mkfs.ext4 ${rootp} + +# Set the path to the rootfs +mkdir -p ${rootfs} + +# Mount the rootfs to the root partition +mount ${rootp} ${rootfs} + +# copy +rootfs_work="${work_path}/rootfs" +rsync -a ${rootfs_work}/ ${rootfs} + +# Remove the contents of the boot folder, but not the boot folder itself +rm -rf ${rootfs}/boot/* + +#unmount +umount ${rootp} + +sync + +bootfs_work="${rootfs_work}/boot" +mkdir -p ${bootfs} + +mount ${bootp} ${bootfs} + +cp -R ${bootfs_work}/* ${bootfs} + +umount ${bootfs} + +sync + +rm -rf ${rootfs} +rm -rf ${bootfs} + +# Remove device mapper bindings. Avoids running out of loop devices if run repeatedly. +dmsetup remove_all + +echo "finishing ${image}" + +if [ "${image}" != "" ]; then + kpartx -d ${image} + echo "created image ${image}" +fi + +echo "done." From fcac3a1456f0513dd25eb5a9b3497b9f17f92edb Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Mon, 2 May 2016 12:16:03 -0700 Subject: [PATCH 03/10] Added alternate chroot function that uses systemd-nspawn instead of chroot, for host systems that use systemd. Haven't tested yet. --- scripts/common | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/common b/scripts/common index 814f37f..936e0a4 100644 --- a/scripts/common +++ b/scripts/common @@ -63,6 +63,11 @@ on_chroot() { chroot ${ROOTFS_DIR}/ "$@" } +# This should be used if building on a system that uses systemd (?) +on_chroot2() { + systemd-nspawn -D ${ROOTFS_DIR}/ "$@" +} + update_issue() { echo -e "Raspberry Pi reference ${DATE}\nGenerated using Pi-gen, https://github.com/RPi-Distro/Pi-gen, ${1}" > ${ROOTFS_DIR}/etc/rpi-issue } From e13e2ee2ede69bf14d6b8b06a1747b96d1a00d28 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Mon, 2 May 2016 12:16:52 -0700 Subject: [PATCH 04/10] Added comments --- stage0/01-configure-apt/00-run.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stage0/01-configure-apt/00-run.sh b/stage0/01-configure-apt/00-run.sh index 9b2bd2e..99adb68 100755 --- a/stage0/01-configure-apt/00-run.sh +++ b/stage0/01-configure-apt/00-run.sh @@ -1,8 +1,10 @@ #!/bin/bash -e +# Install source lists install -m 644 files/sources.list ${ROOTFS_DIR}/etc/apt/ install -m 644 files/raspi.list ${ROOTFS_DIR}/etc/apt/sources.list.d/ +# Set up proxy, if it exists if [ -n "$APT_PROXY" ]; then install -m 644 files/51cache ${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache sed ${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache -i -e "s|APT_PROXY|${APT_PROXY}|" @@ -10,8 +12,13 @@ else rm -f ${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache fi +# Add the raspberry pi gpg key on_chroot apt-key add - < files/raspberrypi.gpg.key + +# Update and dist upgrade on_chroot sh -e - << EOF + apt-get update apt-get dist-upgrade -y + EOF From a015170c39bd5738cce925684195f19df0c53f30 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Mon, 2 May 2016 12:17:38 -0700 Subject: [PATCH 05/10] Added step to install fstab file, otherwise booting fails in created image because the fstab is empty --- stage1/01-sys-tweaks/00-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage1/01-sys-tweaks/00-run.sh b/stage1/01-sys-tweaks/00-run.sh index 5c6ce7e..ac7c428 100755 --- a/stage1/01-sys-tweaks/00-run.sh +++ b/stage1/01-sys-tweaks/00-run.sh @@ -3,7 +3,7 @@ install -d ${ROOTFS_DIR}/etc/systemd/system/getty@tty1.service.d install -m 644 files/noclear.conf ${ROOTFS_DIR}/etc/systemd/system/getty@tty1.service.d/noclear.conf install -m 744 files/policy-rc.d ${ROOTFS_DIR}/usr/sbin/policy-rc.d -#install -v -m 644 files/fstab ${ROOTFS_DIR}/etc/fstab TODO: Necessary in systemd? +install -v -m 644 files/fstab ${ROOTFS_DIR}/etc/fstab on_chroot sh -e - </dev/null 2>&1; then From e5533608a24915ba9ada9b483e2471d75020e77b Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Mon, 2 May 2016 12:21:01 -0700 Subject: [PATCH 06/10] Elaborated on original fstab file --- stage1/01-sys-tweaks/files/fstab | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stage1/01-sys-tweaks/files/fstab b/stage1/01-sys-tweaks/files/fstab index 68e5816..3024bcf 100644 --- a/stage1/01-sys-tweaks/files/fstab +++ b/stage1/01-sys-tweaks/files/fstab @@ -1,3 +1,5 @@ proc /proc proc defaults 0 0 -/dev/mmcblk0p1 /boot vfat defaults 0 2 +/dev/mmcblk0p1 /boot vfat defaults,noatime 0 2 /dev/mmcblk0p2 / ext4 defaults,noatime 0 1 +tmpfs /tmp tmpfs defaults,noatime,nodev,nosuid,mode=1777 0 0 +tmpfs /var/log tmpfs defaults,size=20m,noatime,nodev,nosuid,mode=1777 0 0 \ No newline at end of file From 0e6041b131a4bc64880d2c56de794f08c2369f1f Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Mon, 2 May 2016 12:21:30 -0700 Subject: [PATCH 07/10] Update, reconfigure, and set default locale info --- stage2/01-sys-tweaks/00-debconf | 4 ++-- stage2/01-sys-tweaks/01-run.sh | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/stage2/01-sys-tweaks/00-debconf b/stage2/01-sys-tweaks/00-debconf index afd3914..214b497 100644 --- a/stage2/01-sys-tweaks/00-debconf +++ b/stage2/01-sys-tweaks/00-debconf @@ -9,10 +9,10 @@ tzdata tzdata/Areas select Etc tzdata tzdata/Zones/Etc select UTC # Locales to be generated: # Choices: All locales, aa_DJ ISO-8859-1, aa_DJ.UTF-8 UTF-8, aa_ER UTF-8, aa_ER@saaho UTF-8, aa_ET UTF-8, af_ZA ISO-8859-1, af_ZA.UTF-8 UTF-8, ak_GH UTF-8, am_ET UTF-8, an_ES ISO-8859-15, an_ES.UTF-8 UTF-8, anp_IN UTF-8, ar_AE ISO-8859-6, ar_AE.UTF-8 UTF-8, ar_BH ISO-8859-6, ar_BH.UTF-8 UTF-8, ar_DZ ISO-8859-6, ar_DZ.UTF-8 UTF-8, ar_EG ISO-8859-6, ar_EG.UTF-8 UTF-8, ar_IN UTF-8, ar_IQ ISO-8859-6, ar_IQ.UTF-8 UTF-8, ar_JO ISO-8859-6, ar_JO.UTF-8 UTF-8, ar_KW ISO-8859-6, ar_KW.UTF-8 UTF-8, ar_LB ISO-8859-6, ar_LB.UTF-8 UTF-8, ar_LY ISO-8859-6, ar_LY.UTF-8 UTF-8, ar_MA ISO-8859-6, ar_MA.UTF-8 UTF-8, ar_OM ISO-8859-6, ar_OM.UTF-8 UTF-8, ar_QA ISO-8859-6, ar_QA.UTF-8 UTF-8, ar_SA ISO-8859-6, ar_SA.UTF-8 UTF-8, ar_SD ISO-8859-6, ar_SD.UTF-8 UTF-8, ar_SS UTF-8, ar_SY ISO-8859-6, ar_SY.UTF-8 UTF-8, ar_TN ISO-8859-6, ar_TN.UTF-8 UTF-8, ar_YE ISO-8859-6, ar_YE.UTF-8 UTF-8, as_IN UTF-8, ast_ES ISO-8859-15, ast_ES.UTF-8 UTF-8, ayc_PE UTF-8, az_AZ UTF-8, be_BY CP1251, be_BY.UTF-8 UTF-8, be_BY@latin UTF-8, bem_ZM UTF-8, ber_DZ UTF-8, ber_MA UTF-8, bg_BG CP1251, bg_BG.UTF-8 UTF-8, bho_IN UTF-8, bn_BD UTF-8, bn_IN UTF-8, bo_CN UTF-8, bo_IN UTF-8, br_FR ISO-8859-1, br_FR.UTF-8 UTF-8, br_FR@euro ISO-8859-15, brx_IN UTF-8, bs_BA ISO-8859-2, bs_BA.UTF-8 UTF-8, byn_ER UTF-8, ca_AD ISO-8859-15, ca_AD.UTF-8 UTF-8, ca_ES ISO-8859-1, ca_ES.UTF-8 UTF-8, ca_ES.UTF-8@valencia UTF-8, ca_ES@euro ISO-8859-15, ca_ES@valencia ISO-8859-15, ca_FR ISO-8859-15, ca_FR.UTF-8 UTF-8, ca_IT ISO-8859-15, ca_IT.UTF-8 UTF-8, cmn_TW UTF-8, crh_UA UTF-8, cs_CZ ISO-8859-2, cs_CZ.UTF-8 UTF-8, csb_PL UTF-8, cv_RU UTF-8, cy_GB ISO-8859-14, cy_GB.UTF-8 UTF-8, da_DK ISO-8859-1, da_DK.UTF-8 UTF-8, de_AT ISO-8859-1, de_AT.UTF-8 UTF-8, de_AT@euro ISO-8859-15, de_BE ISO-8859-1, de_BE.UTF-8 UTF-8, de_BE@euro ISO-8859-15, de_CH ISO-8859-1, de_CH.UTF-8 UTF-8, de_DE ISO-8859-1, de_DE.UTF-8 UTF-8, de_DE@euro ISO-8859-15, de_LI.UTF-8 UTF-8, de_LU ISO-8859-1, de_LU.UTF-8 UTF-8, de_LU@euro ISO-8859-15, doi_IN UTF-8, dv_MV UTF-8, dz_BT UTF-8, el_CY ISO-8859-7, el_CY.UTF-8 UTF-8, el_GR ISO-8859-7, el_GR.UTF-8 UTF-8, en_AG UTF-8, en_AU ISO-8859-1, en_AU.UTF-8 UTF-8, en_BW ISO-8859-1, en_BW.UTF-8 UTF-8, en_CA ISO-8859-1, en_CA.UTF-8 UTF-8, en_DK ISO-8859-1, en_DK.ISO-8859-15 ISO-8859-15, en_DK.UTF-8 UTF-8, en_GB ISO-8859-1, en_GB.ISO-8859-15 ISO-8859-15, en_GB.UTF-8 UTF-8, en_HK ISO-8859-1, en_HK.UTF-8 UTF-8, en_IE ISO-8859-1, en_IE.UTF-8 UTF-8, en_IE@euro ISO-8859-15, en_IN UTF-8, en_NG UTF-8, en_NZ ISO-8859-1, en_NZ.UTF-8 UTF-8, en_PH ISO-8859-1, en_PH.UTF-8 UTF-8, en_SG ISO-8859-1, en_SG.UTF-8 UTF-8, en_US ISO-8859-1, en_US.ISO-8859-15 ISO-8859-15, en_US.UTF-8 UTF-8, en_ZA ISO-8859-1, en_ZA.UTF-8 UTF-8, en_ZM UTF-8, en_ZW ISO-8859-1, en_ZW.UTF-8 UTF-8, eo ISO-8859-3, eo.UTF-8 UTF-8, es_AR ISO-8859-1, es_AR.UTF-8 UTF-8, es_BO ISO-8859-1, es_BO.UTF-8 UTF-8, es_CL ISO-8859-1, es_CL.UTF-8 UTF-8, es_CO ISO-8859-1, es_CO.UTF-8 UTF-8, es_CR ISO-8859-1, es_CR.UTF-8 UTF-8, es_CU UTF-8, es_DO ISO-8859-1, es_DO.UTF-8 UTF-8, es_EC ISO-8859-1, es_EC.UTF-8 UTF-8, es_ES ISO-8859-1, es_ES.UTF-8 UTF-8, es_ES@euro ISO-8859-15, es_GT ISO-8859-1, es_GT.UTF-8 UTF-8, es_HN ISO-8859-1, es_HN.UTF-8 UTF-8, es_MX ISO-8859-1, es_MX.UTF-8 UTF-8, es_NI ISO-8859-1, es_NI.UTF-8 UTF-8, es_PA ISO-8859-1, es_PA.UTF-8 UTF-8, es_PE ISO-8859-1, es_PE.UTF-8 UTF-8, es_PR ISO-8859-1, es_PR.UTF-8 UTF-8, es_PY ISO-8859-1, es_PY.UTF-8 UTF-8, es_SV ISO-8859-1, es_SV.UTF-8 UTF-8, es_US ISO-8859-1, es_US.UTF-8 UTF-8, es_UY ISO-8859-1, es_UY.UTF-8 UTF-8, es_VE ISO-8859-1, es_VE.UTF-8 UTF-8, et_EE ISO-8859-1, et_EE.ISO-8859-15 ISO-8859-15, et_EE.UTF-8 UTF-8, eu_ES ISO-8859-1, eu_ES.UTF-8 UTF-8, eu_ES@euro ISO-8859-15, eu_FR ISO-8859-1, eu_FR.UTF-8 UTF-8, eu_FR@euro ISO-8859-15, fa_IR UTF-8, ff_SN UTF-8, fi_FI ISO-8859-1, fi_FI.UTF-8 UTF-8, fi_FI@euro ISO-8859-15, fil_PH UTF-8, fo_FO ISO-8859-1, fo_FO.UTF-8 UTF-8, fr_BE ISO-8859-1, fr_BE.UTF-8 UTF-8, fr_BE@euro ISO-8859-15, fr_CA ISO-8859-1, fr_CA.UTF-8 UTF-8, fr_CH ISO-8859-1, fr_CH.UTF-8 UTF-8, fr_FR ISO-8859-1, fr_FR.UTF-8 UTF-8, fr_FR@euro ISO-8859-15, fr_LU ISO-8859-1, fr_LU.UTF-8 UTF-8, fr_LU@euro ISO-8859-15, fur_IT UTF-8, fy_DE UTF-8, fy_NL UTF-8, ga_IE ISO-8859-1, ga_IE.UTF-8 UTF-8, ga_IE@euro ISO-8859-15, gd_GB ISO-8859-15, gd_GB.UTF-8 UTF-8, gez_ER UTF-8, gez_ER@abegede UTF-8, gez_ET UTF-8, gez_ET@abegede UTF-8, gl_ES ISO-8859-1, gl_ES.UTF-8 UTF-8, gl_ES@euro ISO-8859-15, gu_IN UTF-8, gv_GB ISO-8859-1, gv_GB.UTF-8 UTF-8, ha_NG UTF-8, hak_TW UTF-8, he_IL ISO-8859-8, he_IL.UTF-8 UTF-8, hi_IN UTF-8, hne_IN UTF-8, hr_HR ISO-8859-2, hr_HR.UTF-8 UTF-8, hsb_DE ISO-8859-2, hsb_DE.UTF-8 UTF-8, ht_HT UTF-8, hu_HU ISO-8859-2, hu_HU.UTF-8 UTF-8, hy_AM UTF-8, hy_AM.ARMSCII-8 ARMSCII-8, ia_FR UTF-8, id_ID ISO-8859-1, id_ID.UTF-8 UTF-8, ig_NG UTF-8, ik_CA UTF-8, is_IS ISO-8859-1, is_IS.UTF-8 UTF-8, it_CH ISO-8859-1, it_CH.UTF-8 UTF-8, it_IT ISO-8859-1, it_IT.UTF-8 UTF-8, it_IT@euro ISO-8859-15, iu_CA UTF-8, iw_IL ISO-8859-8, iw_IL.UTF-8 UTF-8, ja_JP.EUC-JP EUC-JP, ja_JP.UTF-8 UTF-8, ka_GE GEORGIAN-PS, ka_GE.UTF-8 UTF-8, kk_KZ PT154, kk_KZ RK1048, kk_KZ.UTF-8 UTF-8, kl_GL ISO-8859-1, kl_GL.UTF-8 UTF-8, km_KH UTF-8, kn_IN UTF-8, ko_KR.EUC-KR EUC-KR, ko_KR.UTF-8 UTF-8, kok_IN UTF-8, ks_IN UTF-8, ks_IN@devanagari UTF-8, ku_TR ISO-8859-9, ku_TR.UTF-8 UTF-8, kw_GB ISO-8859-1, kw_GB.UTF-8 UTF-8, ky_KG UTF-8, lb_LU UTF-8, lg_UG ISO-8859-10, lg_UG.UTF-8 UTF-8, li_BE UTF-8, li_NL UTF-8, lij_IT UTF-8, lo_LA UTF-8, lt_LT ISO-8859-13, lt_LT.UTF-8 UTF-8, lv_LV ISO-8859-13, lv_LV.UTF-8 UTF-8, lzh_TW UTF-8, mag_IN UTF-8, mai_IN UTF-8, mg_MG ISO-8859-15, mg_MG.UTF-8 UTF-8, mhr_RU UTF-8, mi_NZ ISO-8859-13, mi_NZ.UTF-8 UTF-8, mk_MK ISO-8859-5, mk_MK.UTF-8 UTF-8, ml_IN UTF-8, mn_MN UTF-8, mni_IN UTF-8, mr_IN UTF-8, ms_MY ISO-8859-1, ms_MY.UTF-8 UTF-8, mt_MT ISO-8859-3, mt_MT.UTF-8 UTF-8, my_MM UTF-8, nan_TW UTF-8, nan_TW@latin UTF-8, nb_NO ISO-8859-1, nb_NO.UTF-8 UTF-8, nds_DE UTF-8, nds_NL UTF-8, ne_NP UTF-8, nhn_MX UTF-8, niu_NU UTF-8, niu_NZ UTF-8, nl_AW UTF-8, nl_BE ISO-8859-1, nl_BE.UTF-8 UTF-8, nl_BE@euro ISO-8859-15, nl_NL ISO-8859-1, nl_NL.UTF-8 UTF-8, nl_NL@euro ISO-8859-15, nn_NO ISO-8859-1, nn_NO.UTF-8 UTF-8, nr_ZA UTF-8, nso_ZA UTF-8, oc_FR ISO-8859-1, oc_FR.UTF-8 UTF-8, om_ET UTF-8, om_KE ISO-8859-1, om_KE.UTF-8 UTF-8, or_IN UTF-8, os_RU UTF-8, pa_IN UTF-8, pa_PK UTF-8, pap_AN UTF-8, pap_AW UTF-8, pap_CW UTF-8, pl_PL ISO-8859-2, pl_PL.UTF-8 UTF-8, ps_AF UTF-8, pt_BR ISO-8859-1, pt_BR.UTF-8 UTF-8, pt_PT ISO-8859-1, pt_PT.UTF-8 UTF-8, pt_PT@euro ISO-8859-15, quz_PE UTF-8, ro_RO ISO-8859-2, ro_RO.UTF-8 UTF-8, ru_RU ISO-8859-5, ru_RU.CP1251 CP1251, ru_RU.KOI8-R KOI8-R, ru_RU.UTF-8 UTF-8, ru_UA KOI8-U, ru_UA.UTF-8 UTF-8, rw_RW UTF-8, sa_IN UTF-8, sat_IN UTF-8, sc_IT UTF-8, sd_IN UTF-8, sd_IN@devanagari UTF-8, se_NO UTF-8, shs_CA UTF-8, si_LK UTF-8, sid_ET UTF-8, sk_SK ISO-8859-2, sk_SK.UTF-8 UTF-8, sl_SI ISO-8859-2, sl_SI.UTF-8 UTF-8, so_DJ ISO-8859-1, so_DJ.UTF-8 UTF-8, so_ET UTF-8, so_KE ISO-8859-1, so_KE.UTF-8 UTF-8, so_SO ISO-8859-1, so_SO.UTF-8 UTF-8, sq_AL ISO-8859-1, sq_AL.UTF-8 UTF-8, sq_MK UTF-8, sr_ME UTF-8, sr_RS UTF-8, sr_RS@latin UTF-8, ss_ZA UTF-8, st_ZA ISO-8859-1, st_ZA.UTF-8 UTF-8, sv_FI ISO-8859-1, sv_FI.UTF-8 UTF-8, sv_FI@euro ISO-8859-15, sv_SE ISO-8859-1, sv_SE.ISO-8859-15 ISO-8859-15, sv_SE.UTF-8 UTF-8, sw_KE UTF-8, sw_TZ UTF-8, szl_PL UTF-8, ta_IN UTF-8, ta_LK UTF-8, te_IN UTF-8, tg_TJ KOI8-T, tg_TJ.UTF-8 UTF-8, th_TH TIS-620, th_TH.UTF-8 UTF-8, the_NP UTF-8, ti_ER UTF-8, ti_ET UTF-8, tig_ER UTF-8, tk_TM UTF-8, tl_PH ISO-8859-1, tl_PH.UTF-8 UTF-8, tn_ZA UTF-8, tr_CY ISO-8859-9, tr_CY.UTF-8 UTF-8, tr_TR ISO-8859-9, tr_TR.UTF-8 UTF-8, ts_ZA UTF-8, tt_RU UTF-8, tt_RU@iqtelif UTF-8, ug_CN UTF-8, uk_UA KOI8-U, uk_UA.UTF-8 UTF-8, unm_US UTF-8, ur_IN UTF-8, ur_PK UTF-8, uz_UZ ISO-8859-1, uz_UZ.UTF-8 UTF-8, uz_UZ@cyrillic UTF-8, ve_ZA UTF-8, vi_VN UTF-8, wa_BE ISO-8859-1, wa_BE.UTF-8 UTF-8, wa_BE@euro ISO-8859-15, wae_CH UTF-8, wal_ET UTF-8, wo_SN UTF-8, xh_ZA ISO-8859-1, xh_ZA.UTF-8 UTF-8, yi_US CP1255, yi_US.UTF-8 UTF-8, yo_NG UTF-8, yue_HK UTF-8, zh_CN GB2312, zh_CN.GB18030 GB18030, zh_CN.GBK GBK, zh_CN.UTF-8 UTF-8, zh_HK BIG5-HKSCS, zh_HK.UTF-8 UTF-8, zh_SG GB2312, zh_SG.GBK GBK, zh_SG.UTF-8 UTF-8, zh_TW BIG5, zh_TW.EUC-TW EUC-TW, zh_TW.UTF-8 UTF-8, zu_ZA ISO-8859-1, zu_ZA.UTF-8 UTF-8 -locales locales/locales_to_be_generated multiselect en_GB.UTF-8 UTF-8 +locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8 # Default locale for the system environment: # Choices: None, C.UTF-8, en_GB.UTF-8 -locales locales/default_environment_locale select en_GB.UTF-8 +locales locales/default_environment_locale select en_US.UTF-8 # Key to function as AltGr: # Choices: The default for the keyboard layout, No AltGr key, Right Alt (AltGr), Right Control, Right Logo key, Menu key, Left Alt, Left Logo key, Keypad Enter key, Both Logo keys, Both Alt keys keyboard-configuration keyboard-configuration/altgr select The default for the keyboard layout diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index 2813047..b034521 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -10,6 +10,11 @@ install -m 644 files/ttyoutput.conf ${ROOTFS_DIR}/etc/systemd/system/rc-local. install -m 644 files/50raspi ${ROOTFS_DIR}/etc/apt/apt.conf.d/ install -m 644 files/98-rpi.conf ${ROOTFS_DIR}/etc/sysctl.d/ +on_chroot sh -e - < Date: Mon, 2 May 2016 12:29:36 -0700 Subject: [PATCH 08/10] Updated readme with example usage --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 74d54f9..54d98fb 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,7 @@ #Dependencies `quilt kpartx realpath qemu-user-static debootstrap zerofree` + +# Example usage to build a bootable raspbian lite image: +sudo ./build.sh +sudo ./create-image.sh --path=./work/2016-05-02-raspbian/stage3 --name="raspbian-lite" \ No newline at end of file From 4dc06c7f7c696156586570fc5b2bbca8e17fcfc8 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Mon, 2 May 2016 12:31:43 -0700 Subject: [PATCH 09/10] Added boot tweak substage to stage2. Having the init_resize at the end of cmdline.txt causes boot failure after first boot for some reason. Changed some default network details. Disabled bluetooth for normal UART operation and serial console --- stage2/03-boot-tweaks/00-run.sh | 5 ++ stage2/03-boot-tweaks/files/cmdline.txt | 1 + stage2/03-boot-tweaks/files/config.txt | 59 +++++++++++++++++++++ stage2/03-boot-tweaks/files/interfaces | 11 ++++ stage2/{03-cleanup => 04-cleanup}/00-run.sh | 0 5 files changed, 76 insertions(+) create mode 100755 stage2/03-boot-tweaks/00-run.sh create mode 100644 stage2/03-boot-tweaks/files/cmdline.txt create mode 100644 stage2/03-boot-tweaks/files/config.txt create mode 100644 stage2/03-boot-tweaks/files/interfaces rename stage2/{03-cleanup => 04-cleanup}/00-run.sh (100%) diff --git a/stage2/03-boot-tweaks/00-run.sh b/stage2/03-boot-tweaks/00-run.sh new file mode 100755 index 0000000..6dfe897 --- /dev/null +++ b/stage2/03-boot-tweaks/00-run.sh @@ -0,0 +1,5 @@ +#!/bin/bash -ex + +install -m 644 files/cmdline.txt ${ROOTFS_DIR}/boot/ +install -m 644 files/config.txt ${ROOTFS_DIR}/boot/ +install -m 644 files/interfaces ${ROOTFS_DIR}/etc/network/ \ No newline at end of file diff --git a/stage2/03-boot-tweaks/files/cmdline.txt b/stage2/03-boot-tweaks/files/cmdline.txt new file mode 100644 index 0000000..5a9f603 --- /dev/null +++ b/stage2/03-boot-tweaks/files/cmdline.txt @@ -0,0 +1 @@ +dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait \ No newline at end of file diff --git a/stage2/03-boot-tweaks/files/config.txt b/stage2/03-boot-tweaks/files/config.txt new file mode 100644 index 0000000..bf60b1e --- /dev/null +++ b/stage2/03-boot-tweaks/files/config.txt @@ -0,0 +1,59 @@ +# For more options and information see +# http://www.raspberrypi.org/documentation/configuration/config-txt.md +# Some settings may impact device functionality. See link above for details + +# uncomment if you get no picture on HDMI for a default "safe" mode +#hdmi_safe=1 + +# uncomment this if your display has a black border of unused pixels visible +# and your display can output without overscan +#disable_overscan=1 + +# uncomment the following to adjust overscan. Use positive numbers if console +# goes off screen, and negative if there is too much border +#overscan_left=16 +#overscan_right=16 +#overscan_top=16 +#overscan_bottom=16 + +# uncomment to force a console size. By default it will be display's size minus +# overscan. +#framebuffer_width=1280 +#framebuffer_height=720 + +# uncomment if hdmi display is not detected and composite is being output +#hdmi_force_hotplug=1 + +# uncomment to force a specific HDMI mode (this will force VGA) +#hdmi_group=1 +#hdmi_mode=1 + +# uncomment to force a HDMI mode rather than DVI. This can make audio work in +# DMT (computer monitor) modes +#hdmi_drive=2 + +# uncomment to increase signal to HDMI, if you have interference, blanking, or +# no display +#config_hdmi_boost=4 + +# uncomment for composite PAL +#sdtv_mode=2 + +#uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 + +# Uncomment some or all of these to enable the optional hardware interfaces +#dtparam=i2c_arm=on +#dtparam=i2s=on +#dtparam=spi=on + +# Uncomment this to enable the lirc-rpi module +#dtoverlay=lirc-rpi + +# Additional overlays and parameters are documented /boot/overlays/README + +# Enable audio (loads snd_bcm2835) +dtparam=audio=on + +# Disable bluetooth and move UART back to the original pllc +dtoverlay=pi3-disable-bt \ No newline at end of file diff --git a/stage2/03-boot-tweaks/files/interfaces b/stage2/03-boot-tweaks/files/interfaces new file mode 100644 index 0000000..c4e2c97 --- /dev/null +++ b/stage2/03-boot-tweaks/files/interfaces @@ -0,0 +1,11 @@ +auto lo + +iface lo inet loopback +iface eth0 inet dhcp + +allow-hotplug eth0 +iface eth0 inet dhcp +metric 0 +address 192.168.0.100 +netmask 255.255.255.0 +gateway 192.168.0.1 \ No newline at end of file diff --git a/stage2/03-cleanup/00-run.sh b/stage2/04-cleanup/00-run.sh similarity index 100% rename from stage2/03-cleanup/00-run.sh rename to stage2/04-cleanup/00-run.sh From 8b46b7544c1492306abc0176c6a742637ddb0b7f Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Mon, 2 May 2016 14:15:42 -0700 Subject: [PATCH 10/10] Made fix to create-image script. Create rpi/images dir before using dd --- create-image.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/create-image.sh b/create-image.sh index 300dd03..4b20210 100755 --- a/create-image.sh +++ b/create-image.sh @@ -51,8 +51,6 @@ echo "Creating image using rootfs in: ${work_path}" bootsize="64M" deb_release="jessie" -mkdir -p rpi - # define destination folder where created image file will be stored buildenv="${PWD}/rpi" @@ -63,6 +61,7 @@ bootfs="${buildenv}/boot" today=`date +%Y%m%d` mkdir -p ${buildenv} +mkdir -p ${buildenv}/images # Construct image name image="${buildenv}/images/${IMAGE_NAME}_${deb_release}_${today}.img"