Allow for distro and release specific custom files in rootfs, use etc/apt/sources...
authorDaniel Abrecht <public@danielabrecht.ch>
Fri, 5 Jul 2019 23:27:39 +0000 (01:27 +0200)
committerDaniel Abrecht <public@danielabrecht.ch>
Fri, 5 Jul 2019 23:27:39 +0000 (01:27 +0200)
12 files changed:
chroot-build-helper/makefile
config/defaults.mk
packages_install_debootstrap
packages_install_early [new file with mode: 0644]
packages_install_target
rootfs_custom_files/etc/apt/sources.list.in
rootfs_custom_files/etc/apt/sources.list.in::debian [new file with mode: 0644]
rootfs_custom_files/etc/apt/sources.list.in::devuan [new file with mode: 0644]
rootfs_custom_files/etc/apt/sources.list.in::ubuntu [new file with mode: 0644]
script/debootstrap.sh
script/getrfsfile.sh [new file with mode: 0755]
script/rootfs_setup.sh

index a9e289b8051d7755ece79c6b349e11a67bbfa260..4ff5725dbab5d040b6a056324654555bd5df1cd2 100644 (file)
@@ -45,11 +45,11 @@ build-env/$(DISTRO)/$(RELEASE): build-env/.dir $(CHROOT_DUMMY_PACKAGES_FILES)
        chmod 666 "$@.tmp/dev/null"
        chmod +x "$@.tmp/root/helper/mknod" "$@.tmp/root/helper/mount"
        $(SETUPBUILDENV) uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" /debootstrap/debootstrap --second-stage
-       printf "deb %s %s main\ndeb-src %s %s main\n" "$(REPO)" "$(RELEASE)" "$(REPO)" "$(RELEASE)" >"$@.tmp/etc/apt/sources.list"
+       CHROOT_REPO="$$REPO" ../script/getrfsfile.sh "etc/apt/sources.list" >"$@.tmp/etc/apt/sources.list"
        $(SETUPBUILDENV) uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" apt-get update
        $(SETUPBUILDENV) uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" sh -c "dpkg -i /root/dummy-debs/*.deb"
        $(SETUPBUILDENV) uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" apt-get -y install --no-install-recommends build-essential dh-make debhelper devscripts fakeroot
-       printf "deb file:///root/devrepo/ ./\n" "$(REPO)" "$(RELEASE)" "$(REPO)" "$(RELEASE)" >>"$@.tmp/etc/apt/sources.list"
+       printf "\ndeb file:///root/devrepo/ ./\n" >>"$@.tmp/etc/apt/sources.list"
        mv "$@.tmp" "$@"
 
 build-env/$(DISTRO)/$(RELEASE)/root/%/src/.source: repo/%/.repo build-env/$(DISTRO)/$(RELEASE)
index 0204b2222e89735c1d7cbf9db08aa67a20c8c22d..0433a9f9bdb917814c5cd07d8d2a49c82525ade0 100644 (file)
@@ -6,10 +6,12 @@ REPO = http://pkgmaster.devuan.org/merged/
 CHROOT_REPO = $(REPO)
 
 REPO-devuan = http://pkgmaster.devuan.org/merged/
-REPO-debian = http://deb.debian.org/debian
+REPO-debian = http://deb.debian.org/debian/
+REPO-ubuntu = http://ports.ubuntu.com/ubuntu-ports/
 
 DEFAULT_RELEASE-devuan = beowulf
 DEFAULT_RELEASE-debian = buster
+DEFAULT_RELEASE-ubuntu = disco
 
 IMAGE_NAME = $(DISTRO)-$(RELEASE)-librem5-$(BOARD)-base.img
 
index 79bd50f789250e7b6b25a60824dab93cda2b309b..5f1825fbdb2471fbc0d022e4ab786aa3fe01e4e2 100644 (file)
@@ -5,17 +5,3 @@ u-boot-tools
 # Required by rootfs_setup.sh and first_boot_setup.sh
 dpkg-dev
 initramfs-tools
-
-# Do make the text readable
-console-setup
-
-# For getting dialogs when we install or reconfigure stuff later on the device
-dialog
-
-# Other useful stuff which is needed before first boot
-ifupdown
-
-# Other useful stuff
-net-tools
-file
-less
diff --git a/packages_install_early b/packages_install_early
new file mode 100644 (file)
index 0000000..6e97365
--- /dev/null
@@ -0,0 +1,15 @@
+locales # Has to be installed before console keyboard, because it needs locale C.UTF-8
+
+# Do make the text readable
+console-setup
+
+# For getting dialogs when we install or reconfigure stuff later on the device
+dialog
+
+# Other useful stuff which is needed before first boot
+ifupdown
+
+# Other useful stuff
+net-tools
+file
+less
index 2bcd07da81e15dc6888f04e269686c03e3f9acb9..3968fc0bcbff78855f1e9c28762b7849f0a1811e 100644 (file)
@@ -1,3 +1,2 @@
 keyboard-configuration
-locales
 console-common
index dc39682f04fce99e30d94b412274a943a5e22605..51e661713669d2c71a835b139c6e3a8b5d6d6110 100644 (file)
@@ -1,11 +1,2 @@
-
-
-deb     $CHROOT_REPO $RELEASE           main
-deb-src $CHROOT_REPO $RELEASE           main
-deb     $CHROOT_REPO $RELEASE-updates   main
-deb-src $CHROOT_REPO $RELEASE-updates   main
-deb     $CHROOT_REPO $RELEASE-backports main
-deb-src $CHROOT_REPO $RELEASE-backports main
-#deb     $CHROOT_REPO $RELEASE-security  main
-#deb-src $CHROOT_REPO $RELEASE-security  main
-
+deb     $CHROOT_REPO $RELEASE main
+deb-src $CHROOT_REPO $RELEASE main
diff --git a/rootfs_custom_files/etc/apt/sources.list.in::debian b/rootfs_custom_files/etc/apt/sources.list.in::debian
new file mode 100644 (file)
index 0000000..5038d1c
--- /dev/null
@@ -0,0 +1,7 @@
+deb     $CHROOT_REPO $RELEASE           main
+deb-src $CHROOT_REPO $RELEASE           main
+deb     $CHROOT_REPO $RELEASE-updates   main
+deb-src $CHROOT_REPO $RELEASE-updates   main
+deb     $CHROOT_REPO $RELEASE-backports main
+deb-src $CHROOT_REPO $RELEASE-backports main
+
diff --git a/rootfs_custom_files/etc/apt/sources.list.in::devuan b/rootfs_custom_files/etc/apt/sources.list.in::devuan
new file mode 100644 (file)
index 0000000..65cc479
--- /dev/null
@@ -0,0 +1,9 @@
+deb     $CHROOT_REPO $RELEASE           main
+deb-src $CHROOT_REPO $RELEASE           main
+deb     $CHROOT_REPO $RELEASE-updates   main
+deb-src $CHROOT_REPO $RELEASE-updates   main
+deb     $CHROOT_REPO $RELEASE-backports main
+deb-src $CHROOT_REPO $RELEASE-backports main
+deb     $CHROOT_REPO $RELEASE-security  main
+deb-src $CHROOT_REPO $RELEASE-security  main
+
diff --git a/rootfs_custom_files/etc/apt/sources.list.in::ubuntu b/rootfs_custom_files/etc/apt/sources.list.in::ubuntu
new file mode 100644 (file)
index 0000000..9a256d9
--- /dev/null
@@ -0,0 +1,9 @@
+deb     $CHROOT_REPO $RELEASE           main universe
+deb-src $CHROOT_REPO $RELEASE           main universe
+deb     $CHROOT_REPO $RELEASE-updates   main universe
+deb-src $CHROOT_REPO $RELEASE-updates   main universe
+deb     $CHROOT_REPO $RELEASE-backports main universe
+deb-src $CHROOT_REPO $RELEASE-backports main universe
+deb     $CHROOT_REPO $RELEASE-security  main universe
+deb-src $CHROOT_REPO $RELEASE-security  main universe
+
index 5e49b32f6f615b0b531ea2e412062ffe7be326a0..0d5fb0bc372615b82d21eb716154f7263f2d8dc5 100755 (executable)
@@ -48,6 +48,7 @@ sanitize_pkg_list(){
 
 packages_download_only="$(sanitize_pkg_list < packages_download_only)"
 packages_second_stage="$(sanitize_pkg_list < packages_install_target)"
+packages_early="$(sanitize_pkg_list < packages_install_early)"
 packages="$(sanitize_pkg_list < packages_install_debootstrap)"
 
 if [ "$AARCH64_EXECUTABLE" != yes ]
@@ -83,24 +84,31 @@ cp chroot-build-helper/bin/"$DISTRO"/"$RELEASE"/deb-*/*.deb "$tmp/rootfs/root/te
   cd "$base/rootfs_custom_files/"
   find | while IFS= read -r file
   do
-    if [ -d "$file" ]
+    file="$(printf "%s" "$file" | sed 's|::[^/]*$||')"
+    source="$file"
+    if   [ -e "$file::$DISTRO-$RELEASE" ]
+      then source="$file::$DISTRO-$RELEASE"
+    elif [ -e "$file::$DISTRO" ]
+      then source="$file::$DISTRO"
+    fi
+    if [ -d "$source" ]
     then
-      mkdir -p "$file"
+      mkdir -p "$tmp/rootfs/$source"
       continue
     fi
-    dir="$tmp/rootfs/$(dirname "$file")"
+    dir="$tmp/rootfs/$(dirname "$source")"
     mkdir -p "$dir"
     case "$file" in
       *.in)
         target="$dir/$(basename "$file" .in)"
         # The sed stuff allows escaping $ using $$
-        sed 's/\$\$/\x1/g' <"$file" | envsubst | sed 's/\x1/\$/g' >"$target"
+        sed 's/\$\$/\x1/g' <"$source" | envsubst | sed 's/\x1/\$/g' >"$target"
       ;;
       *.rm)
         target="$dir/$(basename "$file" .rm)"
        rm "$target"
       ;;
-      *) cp "$file" "$dir" ;;
+      *) cp "$source" "$dir" ;;
     esac
   done
 )
@@ -108,10 +116,18 @@ cp chroot-build-helper/bin/"$DISTRO"/"$RELEASE"/deb-*/*.deb "$tmp/rootfs/root/te
 # Packages to install on device
 echo "$packages_second_stage" | tr ',' '\n' > "$tmp/rootfs/root/packages_to_install"
 
+# Temporary source list
+(
+  CHROOT_REPO="$REPO" ./script/getrfsfile.sh "etc/apt/sources.list"
+  echo
+  echo 'deb file:///root/temp-repo/ ./'
+) >"$tmp/rootfs/root/temporary-local-repo.list"
+
 # Do some stuff inside the chroot
 (
   cp script/rootfs_setup.sh "$tmp/rootfs/root/rootfs_setup.sh"
   export packages="$packages_second_stage $packages_download_only"
+  export install_packages="$packages_early"
   chroot_qemu_static.sh "$tmp/rootfs/" /root/rootfs_setup.sh
   rm "$tmp/rootfs/root/rootfs_setup.sh"
 )
diff --git a/script/getrfsfile.sh b/script/getrfsfile.sh
new file mode 100755 (executable)
index 0000000..5153562
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+set -e
+
+if [ $# != 1 ]
+then
+  echo "Usage: $0 file" 2>&1
+  exit 1
+fi
+
+# Make sure the current working directory is correct
+cd "$(dirname "$0")/../rootfs_custom_files/"
+
+file="$1"
+if   [ -f "$file.in::$DISTRO-$RELEASE" ]
+  then source="$file.in::$DISTRO-$RELEASE"
+elif [ -f "$file::$DISTRO-$RELEASE" ]
+  then source="$file::$DISTRO-$RELEASE"
+elif [ -f "$file.in::$DISTRO" ]
+  then source="$file.in::$DISTRO"
+elif [ -f "$file::$DISTRO" ]
+  then source="$file::$DISTRO"
+elif [ -f "$file.in" ]
+  then source="$file.in"
+elif [ -f "$file" ]
+  then source="$file"
+  else exit 1
+fi
+file="$(printf "%s" "$source" | sed 's|::[^/]*$||')"
+
+case "$file" in
+  *.in) sed 's/\$\$/\x1/g' <"$source" | envsubst | sed 's/\x1/\$/g' ;;
+  *) cat "$source" ;;
+esac
index 5888c3e0a22dc5f5ff6a9bc1b7f28f84482f7db6..d0cdc530b1af96d97095c37c2c0f8192eba5d7f9 100755 (executable)
@@ -18,15 +18,6 @@ Dpkg::Options:: "--force-confold";
 EOF
 export APT_CONFIG=/root/apt-tmp.conf
 
-# Use bootstrapping repos for this
-cat >/root/temporary-local-repo.list <<EOF
-deb $REPO $RELEASE          main
-#deb $REPO $RELEASE-updates  main
-#deb $REPO $RELEASE-security main
-
-deb file:///root/temp-repo/ ./
-EOF
-
 (
   cd /root/temp-repo/
   dpkg-scanpackages -m . > Packages
@@ -51,6 +42,7 @@ dpkg-reconfigure $(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' -W li
 # download packages
 (
   IFS=", "
+  apt-get -y install $install_packages
   for package in $packages
   do
     apt-get -d -y install "$package"
@@ -86,3 +78,6 @@ EOF
 
 # Update package list of local repo
 apt-get update
+
+# In case the C.UTF-8 locale wasn't generated yet. Usually not that important though
+locale-gen || true