From e1bda9ee5e5cd2ba15fb8ddce9451135a545e1f3 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Tue, 2 Apr 2019 15:38:19 -0400 Subject: [PATCH] appimg-builder renamed to realmfs-builder --- {appimg-builder => realmfs-builder}/README | 30 +++---- .../basic-image.conf | 0 .../build-template.conf | 12 +-- .../common.inc | 4 +- .../realmfs-files/000apt-cacher-ng-proxy | 12 +++ .../realmfs-files}/configure-host0.service | 0 .../realmfs-files}/configure-host0.sh | 0 .../realmfs-files}/launch | 1 + .../org.gnome.settings-daemon.enums.xml | 83 +++++++++++++++++++ ...tings-daemon.plugins.xsettings.gschema.xml | 35 ++++++++ .../realmfs-files/realm-apt-cacher-ng.service | 15 ++++ .../realmfs-modules/add-xsettings-schema | 5 ++ realmfs-builder/realmfs-modules/apt-cacher-ng | 17 ++++ .../realmfs-modules}/configure-locale | 0 .../realmfs-modules}/configure-systemd | 4 + .../realmfs-modules}/create-user | 0 .../realmfs-modules}/install-configure-host0 | 0 .../realmfs-modules}/install-launch-script | 0 .../realmfs-modules}/install-packages | 0 .../realmfs-modules}/loginctl-enable-linger | 0 .../realmfs-modules}/no-install-recommends | 0 .../realmfs-modules}/set-hostname | 2 +- .../realmfs-modules}/setup-theme-symlinks | 0 .../realmfs-modules}/utility-library | 6 +- .../realmfs-modules}/write-apt-sources | 0 .../stage-one.sh | 61 +++++++++----- .../stage-two.sh | 6 +- 27 files changed, 242 insertions(+), 51 deletions(-) rename {appimg-builder => realmfs-builder}/README (80%) rename {appimg-builder => realmfs-builder}/basic-image.conf (100%) rename {appimg-builder => realmfs-builder}/build-template.conf (87%) rename {appimg-builder => realmfs-builder}/common.inc (69%) create mode 100644 realmfs-builder/realmfs-files/000apt-cacher-ng-proxy rename {appimg-builder/appimg-files => realmfs-builder/realmfs-files}/configure-host0.service (100%) rename {appimg-builder/appimg-files => realmfs-builder/realmfs-files}/configure-host0.sh (100%) rename {appimg-builder/appimg-files => realmfs-builder/realmfs-files}/launch (93%) create mode 100644 realmfs-builder/realmfs-files/org.gnome.settings-daemon.enums.xml create mode 100644 realmfs-builder/realmfs-files/org.gnome.settings-daemon.plugins.xsettings.gschema.xml create mode 100644 realmfs-builder/realmfs-files/realm-apt-cacher-ng.service create mode 100644 realmfs-builder/realmfs-modules/add-xsettings-schema create mode 100644 realmfs-builder/realmfs-modules/apt-cacher-ng rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/configure-locale (100%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/configure-systemd (76%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/create-user (100%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/install-configure-host0 (100%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/install-launch-script (100%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/install-packages (100%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/loginctl-enable-linger (100%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/no-install-recommends (100%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/set-hostname (78%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/setup-theme-symlinks (100%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/utility-library (90%) rename {appimg-builder/appimg-modules => realmfs-builder/realmfs-modules}/write-apt-sources (100%) rename {appimg-builder => realmfs-builder}/stage-one.sh (72%) rename {appimg-builder => realmfs-builder}/stage-two.sh (90%) diff --git a/appimg-builder/README b/realmfs-builder/README similarity index 80% rename from appimg-builder/README rename to realmfs-builder/README index 3c842e3..7ce4abe 100644 --- a/appimg-builder/README +++ b/realmfs-builder/README @@ -1,10 +1,10 @@ -Application Image Builder +Base RealmFS Image Builder ========================= -Application Images (or appimgs for short) are created with this builder -framework. The build is controlled by a configuration file which can customize -the build process in various ways such as adding extra packages and specifying -shell functions to be run at certain stages. +RealmFS Images are created with this builder framework. The build is controlled +by a configuration file which can customize the build process in various ways +such as adding extra packages and specifying shell functions to be run at certain +stages. The configuration file is really just a shell script but it should follow the conventions described in the Configuration File section of this document. @@ -20,17 +20,17 @@ directory the rootfs is built on.If you are tweaking a config and making repeate builds this is not only a lot faster, but will also avoid hammering SSD drives with excessive writes (and write amplification). -By default the application image builder is self-hosting and can always be +By default the RealmFS image builder is self-hosting and can always be run from inside images that it creates. Building an image is as easy as: mkdir work && cd work : Make a directory to work in - appimg-builder --new : writes a template file build.conf in current directory + realmfs-builder --new : writes a template file build.conf in current directory vim build.conf : (optionally) make some changes to the template - sudo appimg-builder : Build an application image + sudo realmfs-builder : Build a RealmFS image If you want you can even skip the steps of creating and editing a config file and -just run appimg-build in a work directory and it will build the default appimg we use -with Citadel. +just run realmfs-build in a work directory and it will build the default base realmfs +image we use with Citadel. Stage One --------- @@ -44,7 +44,7 @@ Stage Two The stage-two.sh script mostly just orchestrates the execution of small fragments of shell script code that are called 'modules'. The base framework -modules can be found in the directory /usr/share/appimg-builder/appimg-modules. +modules can be found in the directory /usr/share/realmfs-builder/realmfs-modules. It imports the configuration file with the 'source' command after all the key variables and functions have been defined. It's possible to override any of @@ -81,7 +81,7 @@ corresponding 'base' variable that could be overidden if necessary. - Modules Modules can be functions that you define or they can be loaded from files on -disk. To use files rather than functions a directory named 'appimg-modules' +disk. To use files rather than functions a directory named 'realmfs-modules' must exist as a subdirectory of the directory containing the configuration file. Any files you place in this directory will be found by name during the module execution stages. @@ -89,7 +89,7 @@ execution stages. - Installing Files If you would like to have external files such as configuration files copied into -the image, create 'appimg-files' as a subdirectory of the directory containing +the image, create 'realmfs-files' as a subdirectory of the directory containing the configuration file. You can then use the install_file command inside of a module to copy the files from this directory. You can either store the files to install in a flat directory or organize them into subdirectories mirroring the @@ -99,14 +99,14 @@ refers to the directory in which your configuration file is located. (1): install_file [mode] [file] [target directory] - Example: Install BASE/appimg-files/my_config.conf + Example: Install BASE/realmfs-files/my_config.conf to /etc/mydaemon/my_config.conf install_file 0644 my_config.conf /etc/mydaemon (2): install_file [mode] [full path] - Example: Install BASE/appimg-files/etc/mydaemon/my_config.conf + Example: Install BASE/realmfs-files/etc/mydaemon/my_config.conf to /etc/mydaemon/my_config.conf install_file 0644 /etc/mydaemon/my_config.conf diff --git a/appimg-builder/basic-image.conf b/realmfs-builder/basic-image.conf similarity index 100% rename from appimg-builder/basic-image.conf rename to realmfs-builder/basic-image.conf diff --git a/appimg-builder/build-template.conf b/realmfs-builder/build-template.conf similarity index 87% rename from appimg-builder/build-template.conf rename to realmfs-builder/build-template.conf index 39216c6..b2f6950 100644 --- a/appimg-builder/build-template.conf +++ b/realmfs-builder/build-template.conf @@ -1,14 +1,14 @@ # -# Application Image Builder configuration file template +# RealmFS Image Builder configuration file template # # Synopsis: # # mkdir work && cd work -# appimg-builder --new +# realmfs-builder --new # vim build.conf -# sudo appimg-builder build.conf +# sudo realmfs-builder build.conf # -# Full documentation in /usr/share/appimg-builder/README +# Full documentation in /usr/share/realmfs-builder/README # # @@ -62,11 +62,11 @@ example-module() { } # -# If you add a subdirectory called 'appimg-files' to the +# If you add a subdirectory called 'realmfs-files' to the # directory containing this build config file and then # add a file 'example.service': # -# THISDIR/appimg-files/example.service +# THISDIR/realmfs-files/example.service # # You can then install it by running install_file in a module # like this: diff --git a/appimg-builder/common.inc b/realmfs-builder/common.inc similarity index 69% rename from appimg-builder/common.inc rename to realmfs-builder/common.inc index 20339bb..817f1f0 100644 --- a/appimg-builder/common.inc +++ b/realmfs-builder/common.inc @@ -2,11 +2,11 @@ : ${DEBIAN_MIRROR:="https://deb.debian.org/debian"} : ${DEBIAN_RELEASE:="buster"} -BASE_PACKAGES="debootstrap iproute2 less xz-utils sudo dbus libpam-systemd openssh-client packagekit-gtk3-module libcanberra-gtk3-module libpulse0 fonts-roboto-hinted bash-completion" +BASE_PACKAGES="iproute2 less xz-utils sudo dbus libpam-systemd openssh-client packagekit-gtk3-module libcanberra-gtk3-module libpulse0 fonts-roboto-hinted bash-completion" BASE_PRE_INSTALL_MODULES="utility-library configure-locale create-user set-hostname no-install-recommends write-apt-sources" -BASE_POST_INSTALL_MODULES="loginctl-enable-linger configure-systemd install-configure-host0 install-launch-script setup-theme-symlinks" +BASE_POST_INSTALL_MODULES="loginctl-enable-linger configure-systemd install-configure-host0 install-launch-script setup-theme-symlinks apt-cacher-ng add-xsettings-schema" trap "exit 1" TERM export TOP_PID=$$ diff --git a/realmfs-builder/realmfs-files/000apt-cacher-ng-proxy b/realmfs-builder/realmfs-files/000apt-cacher-ng-proxy new file mode 100644 index 0000000..029128d --- /dev/null +++ b/realmfs-builder/realmfs-files/000apt-cacher-ng-proxy @@ -0,0 +1,12 @@ +# This configuration snipped is intended to be stored in /etc/apt/apt.conf.d/ +# on the client system in order to change a regular setup to use apt-cacher-ng. +# +Acquire::http::Proxy "http://172.17.0.213:3142/"; + +# Little optimization. A value of 10 has been used in earlier version of +# apt-get but was disabled in the beginning of the second decade because of +# incompatibilities with certain HTTP proxies. However, it still beneficial +# with proxy servers that support it good enough (like apt-cacher-ng). +# +Acquire::http::Pipeline-Depth "23"; + diff --git a/appimg-builder/appimg-files/configure-host0.service b/realmfs-builder/realmfs-files/configure-host0.service similarity index 100% rename from appimg-builder/appimg-files/configure-host0.service rename to realmfs-builder/realmfs-files/configure-host0.service diff --git a/appimg-builder/appimg-files/configure-host0.sh b/realmfs-builder/realmfs-files/configure-host0.sh similarity index 100% rename from appimg-builder/appimg-files/configure-host0.sh rename to realmfs-builder/realmfs-files/configure-host0.sh diff --git a/appimg-builder/appimg-files/launch b/realmfs-builder/realmfs-files/launch similarity index 93% rename from appimg-builder/appimg-files/launch rename to realmfs-builder/realmfs-files/launch index 81d56bd..adf9890 100644 --- a/appimg-builder/appimg-files/launch +++ b/realmfs-builder/realmfs-files/launch @@ -1,5 +1,6 @@ #!/bin/bash export REALM_NAME +export GDK_BACKEND export DISPLAY=:0 export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus export XDG_RUNTIME_DIR=/run/user/1000 diff --git a/realmfs-builder/realmfs-files/org.gnome.settings-daemon.enums.xml b/realmfs-builder/realmfs-files/org.gnome.settings-daemon.enums.xml new file mode 100644 index 0000000..68d78a5 --- /dev/null +++ b/realmfs-builder/realmfs-files/org.gnome.settings-daemon.enums.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/realmfs-builder/realmfs-files/org.gnome.settings-daemon.plugins.xsettings.gschema.xml b/realmfs-builder/realmfs-files/org.gnome.settings-daemon.plugins.xsettings.gschema.xml new file mode 100644 index 0000000..56996f4 --- /dev/null +++ b/realmfs-builder/realmfs-files/org.gnome.settings-daemon.plugins.xsettings.gschema.xml @@ -0,0 +1,35 @@ + + + + + 'grayscale' + Antialiasing + The type of antialiasing to use when rendering fonts. Possible values are: “none” for no antialiasing, “grayscale” for standard grayscale antialiasing, and “rgba” for subpixel antialiasing (LCD screens only). + + + 'slight' + Hinting + The type of hinting to use when rendering fonts. Possible values are: “none” for no hinting and “slight” for fitting only to the Y-axis like Microsoft’s ClearType, DirectWrite and Adobe’s proprietary font rendering engine. Ignores native hinting within the font, generates hints algorithmically. Used on Ubuntu by default. Recommended. The meaning of “medium” and “full” depends on the font format (.ttf, .otf, .pfa/.pfb) and the installed version of FreeType. They usually try to fit glyphs to both the X and the Y axis (except for .otf: Y-only). This can lead to distortion and/or inconsistent rendering depending on the quality of the font, the font format and the state of FreeType’s font engines. + + + 'rgb' + RGBA order + The order of subpixel elements on an LCD screen; only used when antialiasing is set to “rgba”. Possible values are: “rgb” for red on left (most common), “bgr” for blue on left, “vrgb” for red on top, “vbgr” for red on bottom. + + + [] + List of explicitly disabled GTK+ modules + A list of strings representing the GTK+ modules that will not be loaded, even if enabled by default in their configuration. + + + [] + List of explicitly enabled GTK+ modules + A list of strings representing the GTK+ modules that will be loaded, usually in addition to conditional and forcibly disabled ones. + + + {} + A dictionary of XSETTINGS to override + This dictionary maps XSETTINGS names to overrides values. The values must be either strings, signed int32s or (in the case of colors), 4-tuples of uint16 (red, green, blue, alpha; 65535 is fully opaque). + + + diff --git a/realmfs-builder/realmfs-files/realm-apt-cacher-ng.service b/realmfs-builder/realmfs-files/realm-apt-cacher-ng.service new file mode 100644 index 0000000..0e290ec --- /dev/null +++ b/realmfs-builder/realmfs-files/realm-apt-cacher-ng.service @@ -0,0 +1,15 @@ +[Unit] +Description=Apt-Cacher NG software download proxy +After=network.target +ConditionPathExists=/usr/share/apt-cacher-ng/conf + +[Service] +ExecStart=/usr/sbin/apt-cacher-ng -c /usr/share/apt-cacher-ng/conf ForeGround=1 +User=1000 +Group=1000 +# this can be changed to notify if the support was enabled at build time +Type=notify +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/realmfs-builder/realmfs-modules/add-xsettings-schema b/realmfs-builder/realmfs-modules/add-xsettings-schema new file mode 100644 index 0000000..2a0cb4e --- /dev/null +++ b/realmfs-builder/realmfs-modules/add-xsettings-schema @@ -0,0 +1,5 @@ + +SCHEMA_DIR=/usr/share/glib-2.0/schemas +install_file 0644 org.gnome.settings-daemon.enums.xml $SCHEMA_DIR +install_file 0644 org.gnome.settings-daemon.plugins.xsettings.gschema.xml $SCHEMA_DIR +glib-compile-schemas $SCHEMA_DIR diff --git a/realmfs-builder/realmfs-modules/apt-cacher-ng b/realmfs-builder/realmfs-modules/apt-cacher-ng new file mode 100644 index 0000000..464a68f --- /dev/null +++ b/realmfs-builder/realmfs-modules/apt-cacher-ng @@ -0,0 +1,17 @@ +info "Setting up apt-cacher-ng" + +apt-get --assume-no install apt-cacher-ng +systemctl -q disable apt-cacher-ng.service + +# +# Configure RealmFS to use download updates through apt-cacher realm +# +install_file 0644 000apt-cacher-ng-proxy /etc/apt/apt.conf.d/ +sed -i 's%https:%http://HTTPS/%' /etc/apt/sources.list + +# +# Configure RealmFS to potentially run as apt-cacher system realm +# +mkdir -p /usr/share/apt-cacher-ng +install_file 0644 realm-apt-cacher-ng.service /usr/lib/systemd/system +systemctl -q enable realm-apt-cacher-ng.service diff --git a/appimg-builder/appimg-modules/configure-locale b/realmfs-builder/realmfs-modules/configure-locale similarity index 100% rename from appimg-builder/appimg-modules/configure-locale rename to realmfs-builder/realmfs-modules/configure-locale diff --git a/appimg-builder/appimg-modules/configure-systemd b/realmfs-builder/realmfs-modules/configure-systemd similarity index 76% rename from appimg-builder/appimg-modules/configure-systemd rename to realmfs-builder/realmfs-modules/configure-systemd index 6240e63..aa0f226 100644 --- a/appimg-builder/appimg-modules/configure-systemd +++ b/realmfs-builder/realmfs-modules/configure-systemd @@ -14,3 +14,7 @@ cat > ${loginconfdir}/50-no-kill-user-processes.conf << EOF [Login] KillUserProcesses=no EOF + +info "Creating /var/log/journal" +mkdir -p /var/log/journal +systemd-tmpfiles --create --prefix /var/log/journal diff --git a/appimg-builder/appimg-modules/create-user b/realmfs-builder/realmfs-modules/create-user similarity index 100% rename from appimg-builder/appimg-modules/create-user rename to realmfs-builder/realmfs-modules/create-user diff --git a/appimg-builder/appimg-modules/install-configure-host0 b/realmfs-builder/realmfs-modules/install-configure-host0 similarity index 100% rename from appimg-builder/appimg-modules/install-configure-host0 rename to realmfs-builder/realmfs-modules/install-configure-host0 diff --git a/appimg-builder/appimg-modules/install-launch-script b/realmfs-builder/realmfs-modules/install-launch-script similarity index 100% rename from appimg-builder/appimg-modules/install-launch-script rename to realmfs-builder/realmfs-modules/install-launch-script diff --git a/appimg-builder/appimg-modules/install-packages b/realmfs-builder/realmfs-modules/install-packages similarity index 100% rename from appimg-builder/appimg-modules/install-packages rename to realmfs-builder/realmfs-modules/install-packages diff --git a/appimg-builder/appimg-modules/loginctl-enable-linger b/realmfs-builder/realmfs-modules/loginctl-enable-linger similarity index 100% rename from appimg-builder/appimg-modules/loginctl-enable-linger rename to realmfs-builder/realmfs-modules/loginctl-enable-linger diff --git a/appimg-builder/appimg-modules/no-install-recommends b/realmfs-builder/realmfs-modules/no-install-recommends similarity index 100% rename from appimg-builder/appimg-modules/no-install-recommends rename to realmfs-builder/realmfs-modules/no-install-recommends diff --git a/appimg-builder/appimg-modules/set-hostname b/realmfs-builder/realmfs-modules/set-hostname similarity index 78% rename from appimg-builder/appimg-modules/set-hostname rename to realmfs-builder/realmfs-modules/set-hostname index dcf50df..54d3363 100644 --- a/appimg-builder/appimg-modules/set-hostname +++ b/realmfs-builder/realmfs-modules/set-hostname @@ -1,4 +1,4 @@ -local hostname=${APPIMG_HOSTNAME:-"subgraph"} +local hostname=${REALMFS_HOSTNAME:-"subgraph"} info "Setting hostname to '$hostname' in /etc/hosts and /etc/hostname" printf "127.0.0.1\t${hostname} localhost\n" > /etc/hosts printf "${hostname}\n" > /etc/hostname diff --git a/appimg-builder/appimg-modules/setup-theme-symlinks b/realmfs-builder/realmfs-modules/setup-theme-symlinks similarity index 100% rename from appimg-builder/appimg-modules/setup-theme-symlinks rename to realmfs-builder/realmfs-modules/setup-theme-symlinks diff --git a/appimg-builder/appimg-modules/utility-library b/realmfs-builder/realmfs-modules/utility-library similarity index 90% rename from appimg-builder/appimg-modules/utility-library rename to realmfs-builder/realmfs-modules/utility-library index 053975b..f5b9ad7 100644 --- a/appimg-builder/appimg-modules/utility-library +++ b/realmfs-builder/realmfs-modules/utility-library @@ -1,6 +1,6 @@ info "utility library loaded" -SEARCH_PATH="/tmp/appimg-build;${APPIMG_BUILDER_BASE}" +SEARCH_PATH="/tmp/realmfs-build;${REALMFS_BUILDER_BASE}" # Searches for modules and files in SEARCH_PATH directories # @@ -9,7 +9,7 @@ SEARCH_PATH="/tmp/appimg-build;${APPIMG_BUILDER_BASE}" # search_item() { local IFS=";" subtype=${1} item=${2} - local subdir="appimg-${subtype}s" + local subdir="realmfs-${subtype}s" for dir in ${SEARCH_PATH}; do local fullpath=${dir}/${subdir}/${item} @@ -25,7 +25,7 @@ search_item() { # # Execute a module by name. If a function exists with the # requested module name it will be executed, otherwise scripts -# with this name are searched for in SEARCH_PATH /appimg-modules +# with this name are searched for in SEARCH_PATH /realmfs-modules # subdirectories. # diff --git a/appimg-builder/appimg-modules/write-apt-sources b/realmfs-builder/realmfs-modules/write-apt-sources similarity index 100% rename from appimg-builder/appimg-modules/write-apt-sources rename to realmfs-builder/realmfs-modules/write-apt-sources diff --git a/appimg-builder/stage-one.sh b/realmfs-builder/stage-one.sh similarity index 72% rename from appimg-builder/stage-one.sh rename to realmfs-builder/stage-one.sh index 9bdeb1e..631897d 100755 --- a/appimg-builder/stage-one.sh +++ b/realmfs-builder/stage-one.sh @@ -1,7 +1,7 @@ #!/bin/bash -: ${APPIMG_BUILDER_BASE:="/usr/share/appimg-builder"} -source ${APPIMG_BUILDER_BASE}/common.inc +: ${REALMFS_BUILDER_BASE:="/usr/share/realmfs-builder"} +source ${REALMFS_BUILDER_BASE}/common.inc umount_if_tmpfs() { if findmnt -t tmpfs -M ${1} > /dev/null; then @@ -46,14 +46,14 @@ setup_chroot() { mount chsys ${ROOTFS}/sys -t sysfs mount chtmp ${ROOTFS}/tmp -t tmpfs - # Install a copy of appimg-builder inside new image + # Install a copy of realmfs-builder inside new image mkdir -p ${ROOTFS}/usr/share - cp -a ${APPIMG_BUILDER_BASE} ${ROOTFS}/usr/share - ln -s /usr/share/appimg-builder/stage-one.sh ${ROOTFS}/usr/bin/appimg-builder + cp -a ${REALMFS_BUILDER_BASE} ${ROOTFS}/usr/share + ln -s /usr/share/realmfs-builder/stage-one.sh ${ROOTFS}/usr/bin/realmfs-builder - # $BUILDFILE and any extra files go in /tmp/appimg-build of rootfs - mkdir -p ${ROOTFS}/tmp/appimg-build - cp ${BUILDFILE} ${ROOTFS}/tmp/appimg-build/build.conf + # $BUILDFILE and any extra files go in /tmp/realmfs-build of rootfs + mkdir -p ${ROOTFS}/tmp/realmfs-build + cp ${BUILDFILE} ${ROOTFS}/tmp/realmfs-build/build.conf } cleanup_chroot() { @@ -79,14 +79,14 @@ run_chroot_stage() { DEBCONF_NONINTERACTIVE_SEEN=true \ LC_ALL=C LANGUAGE=C LANG=C \ DEBIAN_RELEASE=${DEBIAN_RELEASE} DEBIAN_MIRROR=${DEBIAN_MIRROR} \ - chroot ${ROOTFS} /usr/share/appimg-builder/stage-two.sh /tmp/appimg-build/build.conf + chroot ${ROOTFS} /usr/share/realmfs-builder/stage-two.sh /tmp/realmfs-build/build.conf info "chroot installation stage finished, cleaning chroot setup" cleanup_chroot } generate_tarball() { - local tarball=${WORKDIR}/appimg-rootfs.tar + local tarball=${WORKDIR}/realmfs-rootfs.tar info "----- Generating rootfs tarball -----" tar -C ${ROOTFS} --numeric-owner -c --xattrs --xattrs-include=* -f $tarball . @@ -100,20 +100,31 @@ generate_tarball() { echo } +generate_image() { +# BLOCKS=$(du -ks ${ROOTFS} | cut -f1) +# BLOCKS=$(expr ${BLOCKS} \* 12 / 10) +# SIZE=$(expr ${BLOCKS} \* 1024) +# echo "Size is ${SIZE}" + BLOCKS=$(expr 340 \* 1024) + # allow online resize up to 32G + dd if=/dev/zero of=${WORKDIR}/citadel-realmfs.ext4 seek=${BLOCKS} count=0 bs=4096 + mkfs.ext4 -d ${ROOTFS} -i 4096 -b 4096 -F ${WORKDIR}/citadel-realmfs.ext4 ${BLOCKS} +} + usage() { cat <<-EOF -USAGE: appimg-builder [options] [config-file] +USAGE: realmfs-builder [options] [config-file] OPTIONS --new Create a configuration file template called build.conf in the current directory - -d Choose a non-default directory for build output (currently: $(pwd)/appimg) + -d Choose a non-default directory for build output (currently: $(pwd)/realmfs) -t Create a tarball but don't compress it -z Create a tarball compressed with xz --no-tmpfs Do not use tmpfs as rootfs build directory --no-confirm Do not ask for confirmation before beginning -For more documentation see /usr/share/appimg-builder/README +For more documentation see /usr/share/realmfs-builder/README EOF exit 0 @@ -123,7 +134,7 @@ ask_confirm() { local use_tmpfs="No" [[ ${USE_TMPFS} -eq 1 ]] && use_tmpfs="Yes" - printf "About to build application image with the following parameters:\n\n" + printf "About to build RealmFS image with the following parameters:\n\n" printf "\tBuild Configuration File : ${BUILDFILE}\n" printf "\tOutput rootfs directory : ${ROOTFS}\n" printf "\tBuild rootfs on tmpfs : ${use_tmpfs}\n" @@ -141,12 +152,13 @@ try_config() { printf "${rp}" } -WORKDIR="$(pwd)/appimg" +WORKDIR="$(pwd)/realmfs" DO_TAR=0 DO_XZ=0 USE_TMPFS=1 NO_CONFIRM=0 +DO_IMG=0 while [[ $# -gt 0 ]]; do key=${1} @@ -167,6 +179,10 @@ while [[ $# -gt 0 ]]; do DO_TAR=1 DO_XZ=1 shift ;; + -i) + DO_IMG=1 + shift + ;; --no-tmpfs) USE_TMPFS=0 @@ -179,7 +195,7 @@ while [[ $# -gt 0 ]]; do ;; --new) - cp --verbose ${APPIMG_BUILDER_BASE}/build-template.conf build.conf + cp --verbose ${REALMFS_BUILDER_BASE}/build-template.conf build.conf exit 0 ;; @@ -199,12 +215,12 @@ while [[ $# -gt 0 ]]; do done if [ "$EUID" -ne 0 ]; then - echo "The appimg-builder must be run with root privileges." + echo "The realmfs-builder must be run with root privileges." exit 1 fi if [[ -z ${BUILDFILE} ]]; then - BUILDFILE=$(try_config "${PWD}/build.conf" || try_config "${APPIMG_BUILDER_BASE}/basic-image.conf") || fatal "Could not find a configuration file to use" + BUILDFILE=$(try_config "${PWD}/build.conf" || try_config "${REALMFS_BUILDER_BASE}/basic-image.conf") || fatal "Could not find a configuration file to use" fi ROOTFS=${WORKDIR}/rootfs @@ -213,9 +229,9 @@ CACHE_DIR=${WORKDIR}/var-cache-apt-archives [[ ${NO_CONFIRM} -ne 1 ]] && ask_confirm # black magick from stack overflow -exec > >(tee -a $WORKDIR/appimg-build.log) 2>&1 +exec > >(tee -a $WORKDIR/realmfs-build.log) 2>&1 -info "Starting build of application image from configuration file ${BUILDFILE}" +info "Starting build of RealmFS image from configuration file ${BUILDFILE}" source ${BUILDFILE} @@ -225,10 +241,13 @@ run_debootstrap run_chroot_stage + info "rootfs build is completed:" info " $(du -sh ${ROOTFS})" -if [[ ${DO_TAR} -eq 1 ]]; then +if [[ ${DO_IMG} -eq 1 ]]; then + generate_image +elif [[ ${DO_TAR} -eq 1 ]]; then generate_tarball fi diff --git a/appimg-builder/stage-two.sh b/realmfs-builder/stage-two.sh similarity index 90% rename from appimg-builder/stage-two.sh rename to realmfs-builder/stage-two.sh index 5d91346..4babc7c 100755 --- a/appimg-builder/stage-two.sh +++ b/realmfs-builder/stage-two.sh @@ -1,12 +1,12 @@ #!/bin/bash -APPIMG_BUILDER_BASE="/usr/share/appimg-builder" +REALMFS_BUILDER_BASE="/usr/share/realmfs-builder" # # If you're looking for the base lists of packages that are always installed # and modules that are always run, they're defined here in common.inc # -source ${APPIMG_BUILDER_BASE}/common.inc +source ${REALMFS_BUILDER_BASE}/common.inc if [ "$EUID" -ne 0 ]; then fatal "The stage-two.sh script is not running as root." @@ -22,7 +22,7 @@ fi # running module 'utility-library' replaces this function with a more powerful version module() { - local modpath=${APPIMG_BUILDER_BASE}/appimg-modules/${1} + local modpath=${REALMFS_BUILDER_BASE}/realmfs-modules/${1} [[ -f ${modpath} ]] || fatal "Could not find module '${1}'" source ${modpath} }