summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2016-12-09 02:41:11 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2016-12-09 02:41:11 -0600
commit9acabb63bef0cdf55a2bf490edef91cb8b2f7190 (patch)
treeb9f476610ffae6d1fadecd6f4a2ac1712646492a
downloadimage-9acabb63bef0cdf55a2bf490edef91cb8b2f7190.tar.gz
image-9acabb63bef0cdf55a2bf490edef91cb8b2f7190.tar.bz2
image-9acabb63bef0cdf55a2bf490edef91cb8b2f7190.tar.xz
image-9acabb63bef0cdf55a2bf490edef91cb8b2f7190.zip
Initial commit to Git
-rw-r--r--.gitignore5
-rw-r--r--CONTRIBUTING.rst128
-rw-r--r--README.rst90
-rwxr-xr-xbuild-cd267
-rw-r--r--bzImage-x86bin0 -> 7517968 bytes
-rw-r--r--bzImage-x86_64bin0 -> 5801600 bytes
-rwxr-xr-xcdinit-x86bin0 -> 11892 bytes
-rwxr-xr-xcdinit-x86_64bin0 -> 17352 bytes
-rw-r--r--cdinit.c329
-rw-r--r--packages@adelielinux.org.pub14
10 files changed, 833 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..554e7ef
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+cdroot-*/
+initrd-*
+squashroot-*/
+
+*.iso
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
new file mode 100644
index 0000000..9761579
--- /dev/null
+++ b/CONTRIBUTING.rst
@@ -0,0 +1,128 @@
+=================================================
+ Contribution Guide for Adélie Linux Image Tools
+=================================================
+:Author:
+ * **A. Wilcox**, documentation writer
+:Status:
+ Final
+:Copyright:
+ © 2016 Adélie Linux. NCSA open source licence.
+
+
+
+
+Introduction
+============
+
+This repository contains the Adélie Linux image tools, which are used by the
+Release Engineering team to create the official Adélie Linux ISO images.
+
+License
+```````
+The tools contained in this repository are licensed under the NCSA open source
+license. The bzImage files are created from the ``sys-kernel/easy-kernel``
+package (the ``/boot/vmlinuz`` file created for each architecture is copied
+unchanged to ``bzImage-${ARCH}``), and as such are licensed under the kernel's
+GPL2 license.
+
+Changes
+```````
+Any changes to this repository must be reviewed before being pushed to the
+master branch. There are no exceptions to this rule. For security-sensitive
+updates, contact the Security Team at sec-bugs@adelielinux.org.
+
+
+
+
+Patch Format
+============
+
+This section describes the format required for patches in this repository.
+
+
+Unifed Diff Format
+``````````````````
+
+Patches must be submitted in unifed diff format (``diff -Nu``). There are no
+exceptions to this rule.
+
+
+Size
+````
+
+Patch files must be under 50 Kbyte, and under 500 lines.
+
+
+Directory Level
+```````````````
+
+All patch files must be appliable using ``patch -p1``. This means that the
+``diff`` command must be run one directory above the package's root.
+
+
+Comments
+````````
+
+It is highly encouraged that you use the top matter of your patch file to
+describe the changes being made. This grants other developers and the Adélie
+Linux team the same level of understanding that you have over the patch set.
+The format provided by ``svn`` or ``git`` is acceptable, and a direct upstream
+commit number is even better.
+
+
+
+
+Contributing Changes
+====================
+
+This section describes the usual flows of contribution to this repository.
+
+
+GitLab Pull Requests
+````````````````````
+
+#. If you do not already have a GitLab account, you must create one.
+
+#. Create a *fork* of the packages repository. For more information, consult
+ the GitLab online documentation.
+
+#. Clone your forked repository to your computer.
+
+#. Make your changes.
+
+#. Test your changes to ensure they are correct.
+
+#. Add (or remove) changed files using ``git add`` and ``git rm``.
+
+#. Commit your changes to the tree using the command ``git commit`` and
+ ``git push``.
+
+#. Visit your forked repository in a Web browser.
+
+#. Choose the *Create Pull Request* button.
+
+#. Review your changes to ensure they are correct, and then submit the form.
+
+
+Mailing List
+````````````
+
+#. Clone the packages repository to your computer.
+
+#. Make your changes.
+
+#. Test your changes to ensure they are correct.
+
+#. Add (or remove) changed files using ``git add`` and ``git rm``.
+
+#. Commit your changes to the tree using the command ``git commit``.
+
+#. Use the command ``git format-patch HEAD^`` to create a patch file for your
+ commit.
+
+ .. note:: If you have made multiple commits to the tree, you will need to
+ add an additional ^ for each commit you have made. For example,
+ if you have made three commits, you will use the command
+ ``git format-patch HEAD^^^``.
+
+#. Email the resulting patch to the release engineering mailing list.
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..01e5a4a
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,90 @@
+====================
+ Adélie Image Tools
+====================
+:Author:
+ A\. Wilcox
+:Version:
+ 1.0
+:Status:
+ Production
+:Copyright:
+ © 2016 Adélie Linux Team. NCSA open source licence.
+
+
+
+Introduction
+============
+
+This repository contains the Adélie Linux image tools, which are used by the
+Release Engineering team to create the official Adélie Linux ISO images.
+
+License
+```````
+The tools contained in this repository are licensed under the NCSA open source
+license. The bzImage files are created from the ``sys-kernel/easy-kernel``
+package (the ``/boot/vmlinuz`` file created for each architecture is copied
+unchanged to ``bzImage-${ARCH}``), and as such are licensed under the kernel's
+GPL2 license.
+
+Changes
+```````
+Any changes to this repository must be reviewed before being pushed to the
+master branch. There are no exceptions to this rule. For security-sensitive
+updates, contact the Security Team at sec-bugs@adelielinux.org.
+
+
+
+
+Usage
+=====
+
+This section contains usage information for the software in this repository.
+
+
+``build-cd``
+````````````
+
+This script is where the magic happens. ``build-cd`` will create the ISO for
+the architecture specified (defaulting to the currently running system
+architecture if not specified).
+
+``build-cd`` requires the following utilities to be installed on your computer:
+
+* apk-tools
+* cpio
+* squashfs-tools
+* A variant of ``mkisofs`` - releng uses the cdrtools package, but you may be
+ able to use cdrkit.
+
+``build-cd`` is run on the Z shell on official releng machines, but should be
+functional in any POSIX compliant shell; it relies on no non-POSIX shell
+constructs.
+
+The ``cdinit-${ARCH}`` file must exist in the directory that you run
+``build-cd``; it does not need to be in the same directory as the ``build-cd``
+script itself.
+
+
+``cdinit``
+``````````
+
+This functions as early init for the CD, probing for the SquashFS root and
+mounting it appropriately. Pre-compiled binaries statically linked to the
+current release's version of musl, util-linux, and eudev are provided for each
+Tier I and Tier II architecture of the current release.
+
+You may build your own ``cdinit``, for veriication purposes or for another
+architecture, and place it in the same directory as you invoke ``build-cd``.
+
+
+
+Reporting Issues
+================
+
+If you have issues installing with the official media, you should report your
+issue to `the BTS`_.
+
+If you have issues running ``build-cd`` or compiling ``cdinit``, you may file
+an issue in the GitLab repository.
+
+`the BTS`_: http://bts.adelielinux.org/
diff --git a/build-cd b/build-cd
new file mode 100755
index 0000000..0c76213
--- /dev/null
+++ b/build-cd
@@ -0,0 +1,267 @@
+#!/bin/sh
+
+def_arch=x86_64
+def_kernel=4.6
+declare -r PROGNAME=$(basename $0)
+
+
+warn() {
+ printf '>>> '
+ printf '\033[01;33mWARNING\033[00;39m '
+ printf '>>> '
+ printf '\033[01;33mWARNING\033[00;39m '
+ printf '>>> '
+ printf '\033[01;33mWARNING\033[00;39m '
+ printf '>>> '
+ printf '\033[01;33mWARNING\033[00;39m '
+ printf '>>>\n'
+}
+
+
+fatal() {
+ printf '>>> '
+ printf '\033[01;31mERROR\033[00;39m '
+ printf '>>> '
+ printf '\033[01;31mERROR\033[00;39m '
+ printf '>>> '
+ printf '\033[01;31mERROR\033[00;39m '
+ printf '>>> '
+ printf '\033[01;31mERROR\033[00;39m '
+ printf '>>>\n'
+}
+
+
+ensure_commands() {
+ if ! type apk>/dev/null; then
+ fatal
+ printf 'You must have apk installed. On Gentoo, see sys-devel/apk-tools.\n'
+ exit -1
+ fi
+
+ if ! type cpio>/dev/null; then
+ fatal
+ printf 'You must have cpio installed. On Gentoo, see app-arch/cpio.\n'
+ exit -1
+ fi
+
+ if ! type mksquashfs>/dev/null; then
+ fatal
+ printf 'You must have mksquashfs installed. On Gentoo, see sys-fs/squashfs-tools.\n'
+ exit -1
+ fi
+
+ if ! type mkisofs>/dev/null; then
+ fatal
+ printf 'You must have mkisofs installed. Try cdrtools or cdrkit.\n'
+ exit -1
+ fi
+}
+
+
+usage() {
+ printf 'usage: %s [-a ARCH] [-k KERNEL] [--help]\n\n' $PROGNAME
+ printf 'Create an Adélie Linux CD image (.ISO) using the specified parameters.\n'
+ printf 'Default ARCH: %s\nDefault kernel version: %s\n' $def_arch $def_kernel
+}
+
+
+while [ -n "$1" ]; do
+ case $1 in
+ -a | --arch)
+ shift
+ declare -r MY_ARCH=$1
+ ;;
+ -h | --help)
+ usage
+ exit
+ ;;
+ -k | --kernel)
+ shift
+ declare -r MY_KERNEL=$1
+ ;;
+ *)
+ usage >&2
+ exit -1
+ ;;
+ esac
+ shift
+done
+
+declare -r ARCH=${MY_ARCH:-$def_arch}
+declare -r KERNEL=${MY_KERNEL:-$def_kernel}
+declare -r LDARCH=${LDARCH:-$ARCH}
+
+ensure_commands
+
+warn
+printf 'This will erase all files at the directories %s/cdroot-%s\n' `pwd` $ARCH
+printf '%s/initrd-%s and %s/squashroot-%s.\n\n' `pwd` $ARCH `pwd` $ARCH
+printf 'When you are ready, press RETURN. To cancel, press Ctrl-C.\n'
+read
+
+printf '\033[01;32m * \033[37mAdélie Linux CD Creation Tool\033[00;39m\n\n'
+
+rm -rf cdroot-$ARCH
+rm -rf initrd-$ARCH
+rm -rf squashroot-$ARCH
+mkdir cdroot-$ARCH
+mkdir initrd-$ARCH
+mkdir squashroot-$ARCH
+
+printf '\033[01;32m * \033[37mInstalling base system to squash root...\033[00;39m\n'
+
+apk --arch $ARCH -X "https://distfiles.adelielinux.org/adelie/1.0-alpha/$EXTRA_MIRROR" -U --allow-untrusted --root squashroot-$ARCH --initdb add shadow libffi adelie-base bash openrc openrc-openrc hwids eudev udev-init-scripts-openrc parted lvm2-openrc easy-kernel-modules easy-kernel-firmware dhcpcd net-tools ca-certificates
+mkdir -p squashroot-$ARCH/etc/apk/keys
+mkdir -p squashroot-$ARCH/home/live
+mkdir squashroot-$ARCH/target
+mkdir -p squashroot-$ARCH/media/live
+ln -s /bin/bash squashroot-$ARCH/bin/sh
+
+echo 'hostname="adelie"' > squashroot-$ARCH/etc/conf.d/hostname
+echo 'mtab_is_file=no' > squashroot-$ARCH/etc/conf.d/mtab
+
+cp -RPp squashroot-$ARCH/usr/share/openrc/runlevels squashroot-$ARCH/etc/runlevels
+cp 'packages@adelielinux.org.pub' squashroot-$ARCH/etc/apk/keys/
+ln -s /etc/init.d/udev squashroot-$ARCH/etc/runlevels/sysinit/udev
+ln -s /etc/init.d/udev-trigger squashroot-$ARCH/etc/runlevels/sysinit/udev-trigger
+ln -s /etc/init.d/lvmetad squashroot-$ARCH/etc/runlevels/sysinit/lvmetad
+
+cat >squashroot-$ARCH/etc/fstab <<- FSTAB
+ # Welcome to Adélie Linux.
+ # This fstab(5) is for the live media only. Do not edit or use for your installation.
+
+ tmpfs /tmp tmpfs defaults 0 1
+ tmpfs /var/log tmpfs size=8m 0 1
+ tmpfs /root tmpfs size=16m 0 1
+ tmpfs /home/live tmpfs size=16m 0 1
+ proc /proc proc defaults 0 1
+FSTAB
+
+cat >squashroot-$ARCH/etc/passwd <<- PASSWD
+ root:x:0:0:Charlie Root:/root:/bin/bash
+ man:x:13:15:man-db:/usr/share/man:/sbin/nologin
+ at:x:25:25:at:/var/spool/at/atjobs:/sbin/nologin
+ fcron:x:101:206:fcron:/dev/null:/sbin/nologin
+ postfix:x:207:207:postfix:/var/spool/postfix:/sbin/nologin
+ live:x:1000:1000:Live User:/home/live:/bin/bash
+PASSWD
+
+cat >squashroot-$ARCH/etc/group <<- GROUP
+ root:x:0:
+ tty:x:5:
+ wheel:x:10:live
+ mail:x:12:postfix
+ uucp:x:14:
+ cron:x:16:
+ at:x:25:
+ fcron:x:206:
+ postfix:x:207:
+ postdrop:x:208:
+ live:x:1000:
+GROUP
+
+cat >squashroot-$ARCH/etc/shadow <<- SHADOW
+ root::::::::
+ man::::::::
+ at::::::::
+ fcron::::::::
+ postfix::::::::
+ live::::::::
+SHADOW
+
+cat >squashroot-$ARCH/etc/shells <<- SHELLS
+ /bin/bash
+ /bin/zsh
+SHELLS
+
+cat >squashroot-$ARCH/etc/resolv.conf <<- RESOLVE
+ nameserver 8.8.8.8
+RESOLVE
+
+cat >squashroot-$ARCH/etc/apk/repositories <<-REPOS
+ https://distfiles.adelielinux.org/adelie/1.0-alpha/$EXTRA_MIRROR
+REPOS
+
+cat >squashroot-$ARCH/etc/issue <<-ISSUE
+ Welcome to Adélie Linux!
+ You may log in as 'root' to install, or 'live' to play around.
+
+ Have fun.
+
+ISSUE
+
+chmod 600 squashroot-$ARCH/etc/shadow
+
+printf '\033[01;32m * \033[37mCreating compressed file system image...\033[00;39m\n'
+
+mksquashfs squashroot-$ARCH cdroot-$ARCH/adelie.squashfs
+
+printf '\033[01;32m * \033[37mCreating initrd structure...\033[00;39m\n'
+
+# mount points
+mkdir initrd-$ARCH/dev
+mkdir initrd-$ARCH/media
+mkdir initrd-$ARCH/newroot
+mkdir initrd-$ARCH/proc
+mkdir initrd-$ARCH/sys
+
+# manual /dev nodes for initial udev startup
+mknod -m 600 initrd-$ARCH/dev/console c 5 1
+mknod -m 666 initrd-$ARCH/dev/null c 1 3
+mknod -m 666 initrd-$ARCH/dev/ptmx c 5 2
+mknod -m 666 initrd-$ARCH/dev/random c 1 8
+mknod -m 666 initrd-$ARCH/dev/tty c 5 0
+mknod -m 620 initrd-$ARCH/dev/tty1 c 4 1
+mknod -m 666 initrd-$ARCH/dev/urandom c 1 9
+mknod -m 666 initrd-$ARCH/dev/zero c 1 5
+
+# base
+mkdir initrd-$ARCH/lib
+cp squashroot-$ARCH/usr/lib/libc.so initrd-$ARCH/lib/ld-musl-$LDARCH.so.1
+cp squashroot-$ARCH/lib/libblkid.so.1 initrd-$ARCH/lib/
+cp squashroot-$ARCH/lib/libuuid.so.1 initrd-$ARCH/lib/
+
+# udev
+mkdir -p initrd-$ARCH/etc/udev
+mkdir initrd-$ARCH/run
+mkdir initrd-$ARCH/sbin
+cp squashroot-$ARCH/bin/udevadm initrd-$ARCH/sbin/
+cp squashroot-$ARCH/sbin/udevd initrd-$ARCH/sbin/
+cp squashroot-$ARCH/lib/libkmod.so.2 initrd-$ARCH/lib/
+cp squashroot-$ARCH/lib/libudev.so.1 initrd-$ARCH/lib/
+cp squashroot-$ARCH/etc/udev/hwdb.bin initrd-$ARCH/etc/udev/
+
+# init
+cp cdinit-$ARCH initrd-$ARCH/init
+
+printf '\033[01;32m * \033[37mCompressing initrd...\033[00;39m\n'
+
+pushd initrd-$ARCH
+find . | cpio -H newc -o > ../cdroot-$ARCH/initrd
+popd
+gzip -9 cdroot-$ARCH/initrd
+mv cdroot-$ARCH/initrd.gz cdroot-$ARCH/initrd
+
+printf '\033[01;32m * \033[37mAdding kernel...\033[00;39m\n'
+
+cp bzImage-$ARCH cdroot-$ARCH/bzImage
+
+printf '\033[01;32m * \033[37mInstalling ISOLINUX...\033[00;39m\n'
+
+mkdir cdroot-$ARCH/isolinux
+
+cat >cdroot-$ARCH/isolinux/isolinux.cfg <<BOOTCFG
+prompt 1
+default adelie
+
+label adelie
+ kernel /bzImage
+ append initrd=/initrd
+BOOTCFG
+
+cp /usr/share/syslinux/isolinux-debug.bin cdroot-$ARCH/isolinux/isolinux.bin
+cp /usr/share/syslinux/ldlinux.c32 cdroot-$ARCH/isolinux/
+
+printf '\033[01;32m * \033[37mCreating the CD...\033[00;39m\n'
+
+mkisofs -o adelie-live-$ARCH-1.0-ALPHA-$(date +%Y%m%d).iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -joliet cdroot-$ARCH
diff --git a/bzImage-x86 b/bzImage-x86
new file mode 100644
index 0000000..962b490
--- /dev/null
+++ b/bzImage-x86
Binary files differ
diff --git a/bzImage-x86_64 b/bzImage-x86_64
new file mode 100644
index 0000000..aa649ee
--- /dev/null
+++ b/bzImage-x86_64
Binary files differ
diff --git a/cdinit-x86 b/cdinit-x86
new file mode 100755
index 0000000..e4df83e
--- /dev/null
+++ b/cdinit-x86
Binary files differ
diff --git a/cdinit-x86_64 b/cdinit-x86_64
new file mode 100755
index 0000000..741a7e5
--- /dev/null
+++ b/cdinit-x86_64
Binary files differ
diff --git a/cdinit.c b/cdinit.c
new file mode 100644
index 0000000..2990106
--- /dev/null
+++ b/cdinit.c
@@ -0,0 +1,329 @@
+/*
+ * cdinit - start up udev, find the squashfs, and get the hell out of dodge
+ * Copyright (c) 2016 Adélie Linux Team. All rights reserved.
+ * Licensed under the NCSA open source license.
+ * See LICENSE file included with this source for more information.
+ */
+
+
+#include <errno.h> /* errno */
+#include <fcntl.h> /* ioctl */
+#include <linux/loop.h> /* LOOP_SET_FD */
+#include <stdbool.h> /* bool */
+#include <stdio.h> /* stderr, fprintf */
+#include <stdlib.h> /* EXIT_FAILURE */
+#include <string.h> /* strlen */
+#include <sys/mount.h> /* mount */
+#include <sys/stat.h> /* mkdir */
+#include <sys/wait.h> /* waitpid, W* macros */
+#include <unistd.h> /* exec, fork, etc */
+
+#include <blkid/blkid.h>/* blkid_get_tag_value */
+#include <libudev.h> /* udev* */
+
+
+/*!
+ * @brief Invoke a specified command. Return if it is run successfully.
+ * @param command User-readable description of what command is to run.
+ * @param path The full on-disk path to the executable to run.
+ * @param argv The full argument list to run.
+ * @returns true if command runs successfully, false otherwise.
+ */
+bool cdi_invoke(const char *command, const char *path, char * const argv[])
+{
+ pid_t our_pid;
+
+ fprintf(stdout, " * Starting %s... ", command);
+
+ our_pid = fork();
+ if(our_pid == 0)
+ {
+ execv(path, argv);
+ fprintf(stderr, "could not start %s: %s\n", command,
+ strerror(errno));
+ return 255;
+ }
+ else if(our_pid == -1)
+ {
+ fprintf(stdout, "[ !! ] failed to fork: %s\n", strerror(errno));
+ return false;
+ }
+ else
+ {
+ int status, code;
+
+ waitpid(our_pid, &status, 0);
+ if(!WIFEXITED(status))
+ {
+ fprintf(stdout, "[ !! ] %s caught signal\n", command);
+ return false;
+ }
+
+ code = WEXITSTATUS(status);
+ if(code != 0)
+ {
+ fprintf(stdout, "[ !! ] %s exited with error code %d\n",
+ command, code);
+ return false;
+ }
+ }
+
+ fprintf(stdout, "[ ok ]\n");
+
+ return true;
+}
+
+/* We need to test each block device in the system, in case there are
+ * multiple drives that all have media present. We can narrow it down,
+ * however:
+ *
+ * - We know that our device will have 'adelie.squashfs'.
+ * - We know it will be mountable without external helpers, as ISO9660,
+ * FAT, and HFS+ are built in to the kernel.
+ */
+bool cdi_find_media(void)
+{
+ struct udev *udev;
+ struct udev_enumerate *dev_list;
+ struct udev_list_entry *first, *candidate;
+ struct udev_device *device = NULL;
+
+ udev = udev_new();
+ if(udev == NULL)
+ {
+ fprintf(stderr, "Cannot establish link to udev.\n");
+ return false;
+ }
+
+ dev_list = udev_enumerate_new(udev);
+ if(dev_list == NULL)
+ {
+ fprintf(stderr, "Cannot create enumerator (memory?)\n");
+ return false;
+ }
+
+ udev_enumerate_add_match_subsystem(dev_list, "block");
+#ifdef DISKONLY /* support booting off USB partition unless DISKONLY */
+ udev_enumerate_add_match_property(dev_list, "DEVTYPE", "disk");
+#endif
+ udev_enumerate_scan_devices(dev_list);
+
+ first = udev_enumerate_get_list_entry(dev_list);
+ if(first == NULL)
+ {
+ fprintf(stdout, "No block devices found.\n");
+ fprintf(stdout, "This system cannot boot Adélie Linux "
+ "without additional drivers.\n");
+ return false;
+ }
+
+ udev_list_entry_foreach(candidate, first)
+ {
+ const char *path = udev_list_entry_get_name(candidate);
+ char *fstype = NULL;
+
+ if(device != NULL)
+ {
+ udev_device_unref(device);
+ }
+ device = udev_device_new_from_syspath(udev, path);
+ errno = 0;
+
+ const char *dev_node = udev_device_get_devnode(device);
+ if(dev_node == NULL)
+ {
+ continue; /* worthless */
+ }
+
+#ifdef DEBUG
+ fprintf(stderr, "cdi_find_media: testing candidate %s\n",
+ dev_node);
+#endif
+
+ if((fstype = blkid_get_tag_value(NULL, "TYPE", dev_node)) == NULL)
+ {
+#ifdef DEBUG
+ fprintf(stderr, "cdi_find_media: %s has unknown FS\n",
+ dev_node);
+#endif
+ continue;
+ }
+
+ if(mount(dev_node, "/media", fstype, MS_RDONLY, NULL) != 0)
+ {
+#ifdef DEBUG
+ fprintf(stderr, "cdi_find_media: %s cannot be mounted:"
+ " %s\n", dev_node, strerror(errno));
+#endif
+ free(fstype);
+ continue;
+ }
+ free(fstype);
+
+ if(access("/media/adelie.squashfs", F_OK) != 0)
+ {
+#ifdef DEBUG
+ fprintf(stderr, "cdi_find_media: %s has no squash root:"
+ " %s\n", dev_node, strerror(errno));
+#endif
+ umount("/media");
+ continue;
+ }
+
+#ifdef DEBUG
+ fprintf(stderr, "cdi_find_media: LiveFS located at %s\n",
+ dev_node);
+#endif
+
+ int squash_fd = open("/media/adelie.squashfs", O_RDONLY);
+ if(squash_fd == -1)
+ {
+ umount("/media");
+ continue;
+ }
+
+ int dev_fd = open("/dev/loop4", O_RDWR);
+ if(dev_fd == -1)
+ {
+ close(squash_fd);
+ umount("/media");
+ continue;
+ }
+
+ ioctl(dev_fd, LOOP_SET_FD, squash_fd);
+ close(squash_fd);
+
+ if(mount("/dev/loop4", "/newroot", "squashfs", MS_RDONLY,
+ NULL) != 0)
+ {
+#ifdef DEBUG
+ fprintf(stderr, "cdi_find_media: %s contained invalid"
+ " LiveFS image: %s\n", dev_node,
+ strerror(errno));
+#endif
+ ioctl(dev_fd, LOOP_CLR_FD, 0);
+ close(dev_fd);
+ umount("/media");
+ continue;
+ }
+
+ close(dev_fd);
+ udev_device_unref(device);
+ device = NULL;
+ break;
+ }
+
+ udev_enumerate_unref(dev_list);
+ udev_unref(udev);
+
+ return (access("/newroot/sbin/init", F_OK) == 0);
+}
+
+
+
+int main(void)
+{
+ pid_t our_pid;
+
+#ifndef DEBUG
+ if(getpid() != 1)
+ {
+ fprintf(stderr, "This application can only boot live media.\n");
+ return EXIT_FAILURE;
+ }
+#endif
+
+ fprintf(stdout, " * Adélie Linux is starting up...\n\n");
+
+ if(mount("none", "/dev", "devtmpfs", 0, NULL) != 0)
+ {
+ fprintf(stdout, "FATAL: Can't mount devtmpfs at /dev: %s\n",
+ strerror(errno));
+ return EXIT_FAILURE;
+ }
+
+ if(mount("none", "/proc", "proc", 0, NULL) != 0)
+ {
+ fprintf(stdout, "FATAL: Can't mount early /proc: %s\n",
+ strerror(errno));
+ return EXIT_FAILURE;
+ }
+
+ if(mount("none", "/sys", "sysfs", 0, NULL) != 0)
+ {
+ fprintf(stdout, "FATAL: Can't mount early /sys: %s\n",
+ strerror(errno));
+ return EXIT_FAILURE;
+ }
+
+ /* Our entire goal for this system is to be small and fast, in both
+ * execution and code. This is not the place for bloat and this is not
+ * the place to do a tech demo of some shiny new API.
+ *
+ * Installers and rescue media must be very stable. The less surface
+ * this system has, the less can go wrong.
+ *
+ * As we are pid1, we first need to start up udev.
+ */
+ {
+ char * const argv[] = {"udevd", "--daemon",
+#ifdef DEBUG
+ "--debug",
+#endif
+ "--event-timeout=30",
+ "--resolve-names=never",
+ (char *)0};
+ if(!cdi_invoke("early udevd", "/sbin/udevd", argv))
+ {
+ return EXIT_FAILURE;
+ }
+ }
+
+ /* udev is started. Now we need to communicate.
+ *
+ * First, we trigger block device uevents. This will ensure that all
+ * block devices supported by the kernel have /dev entries that we can
+ * use.
+ */
+ {
+ char * const argv[] = {"udevadm", "trigger", "--action=add",
+ "--subsystem-match=blocK", 0};
+ if(!cdi_invoke("block uevents", "/sbin/udevadm", argv))
+ {
+ return EXIT_FAILURE;
+ }
+ }
+
+ /* Now we need to iterate over the available block devices, trying to
+ * find our CD media.
+ */
+ if(!cdi_find_media())
+ {
+ fprintf(stdout, "FATAL: no boot media found\n");
+ return EXIT_FAILURE;
+ }
+
+ {
+ char * const argv[] = {"udevadm", "control", "-e", 0};
+ cdi_invoke("clean up", "/sbin/udevadm", argv);
+ }
+
+ mount("/dev", "/newroot/dev", NULL, MS_MOVE, NULL);
+ mount("/media", "/newroot/media/live", NULL, MS_MOVE, NULL);
+ mount("/proc", "/newroot/proc", NULL, MS_MOVE, NULL);
+ mount("/sys", "/newroot/sys", NULL, MS_MOVE, NULL);
+
+ chdir("/newroot");
+ if(mount("/newroot", "/", NULL, MS_MOVE, NULL) != 0)
+ {
+ fprintf(stderr, "could not pivot to /newroot: %s\n",
+ strerror(errno));
+ return EXIT_FAILURE;
+ }
+
+ chroot(".");
+ execl("/sbin/init", "init", (char *)0);
+
+ fprintf(stdout, "Going nowhere without my new root's init\n");
+ return EXIT_FAILURE;
+}
diff --git a/packages@adelielinux.org.pub b/packages@adelielinux.org.pub
new file mode 100644
index 0000000..8c05e1c
--- /dev/null
+++ b/packages@adelielinux.org.pub
@@ -0,0 +1,14 @@
+-----BEGIN PUBLIC KEY-----
+MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsLRKBHGBE1L7QfwskILi
+/j1o04J6SUY+HDa6OcA96XpcBN8EA1rE3ThgUjasaTFbPkLXBt3/AnSW0uBGYDLj
+Wzg16dUYva3iV5W+Xc3oT0q2t0cCeYXgAUJyqw4SuyMypKLzvcb4mvUP8rDhJmee
+l9Rhw/0iEZF1S/ArTKZIaQ5bN3iAZG4IloiXTlwsjEGO6BWEemdTer7Z6wii8lW0
+b9dtivz0rxxb7wIrLPLB3HJz5X+FWniGs8TTNHymjhOxjq8A+kVMaElGfFhhNwBH
+W4rjlWiy16pTar49UVoJdD2L9WFNKD3JOARHjPUt5VPd0arbV5yztw8OjpbToF4W
+lNrT60sAvCIzW99U7QpKgWJX8F05zKcdJWSnyxLw0F8lN3vZ80dblKPYe3A/rj5E
+KNf4Lmach81YPNohL2hc9OgV8a474j7brA1gQlhVN0j55AQuTv/RrQpSlPcqCE4p
+e7l1Aa+daq8yH8sqAzfug1IqGgqztk/YoEcchprm+pEkWRI2N7qCU+3WKDF5Oa5M
+XQfPaOw7Mp6Udxl7Opwol4icNXYi3o4QX1I29ZmtcHsCPpunR8jwvEwauehbuH5i
+VL1rN77TOMMX+zXj02FP2wwURDo8D9YF0jUC8APt+ZVM4HFHUTzyEO+NvHa/24xK
++QqStXcDCnLf1XN9+ORL3iUCAwEAAQ==
+-----END PUBLIC KEY-----