2017-05-26 20:26:25 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
source_deviceinfo()
|
|
|
|
{
|
|
|
|
if [ ! -e "/etc/deviceinfo" ]; then
|
2018-02-26 23:57:56 +00:00
|
|
|
echo "NOTE: deviceinfo (from device package) not installed yet," \
|
|
|
|
"not building the initramfs now (it should get built later" \
|
|
|
|
"automatically.)"
|
|
|
|
exit 0
|
2017-05-26 20:26:25 +00:00
|
|
|
fi
|
|
|
|
. /etc/deviceinfo
|
|
|
|
}
|
|
|
|
|
|
|
|
parse_commandline()
|
|
|
|
{
|
|
|
|
if [ "$1" != "-o" ]; then
|
|
|
|
echo "postmarketos-mkinitfs"
|
2017-07-28 18:51:21 +00:00
|
|
|
echo "usage: $(basename "$0") -o OUTFILE KERNELVERSION"
|
2017-05-26 20:26:25 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
outfile=$2
|
2017-07-28 18:51:21 +00:00
|
|
|
outfile_extra=$2-extra
|
2017-05-26 20:26:25 +00:00
|
|
|
kernel=$3
|
|
|
|
modules_path="/lib/modules/${kernel}"
|
|
|
|
}
|
|
|
|
|
2018-03-26 18:12:58 +00:00
|
|
|
# Verify that each file required by the installed hooks exists and exit with an
|
|
|
|
# error if they don't.
|
|
|
|
check_hook_files()
|
|
|
|
{
|
|
|
|
for file in "/etc/postmarketos-mkinitfs/files"/*.files; do
|
|
|
|
[ -f "$file" ] || continue
|
|
|
|
while IFS= read -r line; do
|
|
|
|
if ! [ -f "$line" ]; then
|
|
|
|
echo "ERROR: File ${line} specified in ${file} does not exist!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done < "$file"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-05-26 20:26:25 +00:00
|
|
|
create_folders()
|
|
|
|
{
|
|
|
|
for dir in /bin /sbin /usr/bin /usr/sbin /proc /sys /dev /tmp /lib \
|
2017-08-09 21:54:01 +00:00
|
|
|
/boot /sysroot /etc; do
|
2017-05-26 20:26:25 +00:00
|
|
|
mkdir -p "$tmpdir$dir"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
get_modules_by_globs()
|
|
|
|
{
|
|
|
|
globs="
|
|
|
|
# base.modules
|
|
|
|
kernel/drivers/block/loop.ko
|
|
|
|
kernel/fs/overlayfs
|
|
|
|
|
|
|
|
# cryptsetup.modules
|
|
|
|
kernel/crypto/*
|
|
|
|
kernel/arch/*/crypto/*
|
|
|
|
kernel/drivers/md/dm-crypt.ko
|
|
|
|
|
|
|
|
# required for modprobe
|
|
|
|
modules.*
|
|
|
|
"
|
|
|
|
|
|
|
|
for glob in $globs; do
|
|
|
|
for file in /lib/modules/$kernel/$glob; do
|
|
|
|
if [ -d "$file" ]; then
|
2017-07-28 18:51:21 +00:00
|
|
|
find "$file" -type f
|
2017-05-26 20:26:25 +00:00
|
|
|
elif [ -e "$file" ]; then
|
2017-07-28 18:51:21 +00:00
|
|
|
echo "$file"
|
2017-05-26 20:26:25 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# NOTE: This does not work with busybox' modprobe
|
|
|
|
# That's why postmarketos-mkinitfs depends on kmod
|
|
|
|
get_modules_by_name()
|
|
|
|
{
|
2018-01-31 19:39:09 +00:00
|
|
|
{
|
|
|
|
echo "Scanning kernel module dependencies..."
|
|
|
|
echo "NOTE: ** modprobe warnings below can be ignored ** if your device does not run the"
|
|
|
|
echo "mainline kernel yet (most devices!) or if the related kernel options are enabled"
|
|
|
|
echo "with 'y' instead of 'm' (module)."
|
|
|
|
} >&2
|
|
|
|
|
|
|
|
MODULES="drm_kms_helper drm dm_crypt \
|
2017-05-26 20:26:25 +00:00
|
|
|
${deviceinfo_modules_initfs}"
|
|
|
|
modprobe \
|
|
|
|
-a \
|
|
|
|
--dry-run \
|
|
|
|
--show-depends \
|
|
|
|
--set-version="$kernel" \
|
|
|
|
$MODULES \
|
|
|
|
| sort -u \
|
|
|
|
| cut -d ' ' -f 2
|
|
|
|
}
|
|
|
|
|
|
|
|
get_modules()
|
|
|
|
{
|
|
|
|
get_modules_by_globs
|
|
|
|
get_modules_by_name
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get the paths to all binaries and their dependencies
|
2017-10-22 21:00:39 +00:00
|
|
|
BINARIES="/bin/busybox /bin/busybox-extras /usr/sbin/telnetd /sbin/kpartx"
|
|
|
|
BINARIES_EXTRA="
|
2018-03-05 22:59:23 +00:00
|
|
|
$(find /usr/lib/directfb-* -name '*.so')
|
|
|
|
/lib/libz.so.1
|
2017-10-22 21:00:39 +00:00
|
|
|
/sbin/cryptsetup
|
|
|
|
/sbin/dmsetup
|
|
|
|
/sbin/e2fsck
|
2018-03-05 22:59:23 +00:00
|
|
|
/usr/bin/charging-sdl
|
2017-10-22 21:00:39 +00:00
|
|
|
/usr/bin/osk-sdl
|
|
|
|
/usr/lib/libGL.so.1
|
|
|
|
/usr/lib/libts*
|
2018-03-05 22:59:23 +00:00
|
|
|
/usr/lib/ts/*
|
|
|
|
/usr/sbin/parted
|
|
|
|
/usr/sbin/resize2fs
|
|
|
|
/usr/sbin/thd
|
2017-10-22 21:00:39 +00:00
|
|
|
"
|
2017-05-26 20:26:25 +00:00
|
|
|
get_binaries()
|
|
|
|
{
|
2018-03-26 18:12:58 +00:00
|
|
|
for file in "/etc/postmarketos-mkinitfs/files"/*.files; do
|
|
|
|
[ -f "$file" ] || continue
|
|
|
|
while IFS= read -r line; do
|
|
|
|
BINARIES="${BINARIES} ${line}"
|
|
|
|
done < "$file"
|
|
|
|
done
|
2017-05-26 20:26:25 +00:00
|
|
|
lddtree -l $BINARIES | sort -u
|
|
|
|
}
|
|
|
|
|
2017-10-14 18:10:12 +00:00
|
|
|
# Collect non-binary files for osk-sdl and its dependencies
|
|
|
|
# This gets called as $(get_osk_config), so the exit code can be checked/handled.
|
|
|
|
get_osk_config()
|
|
|
|
{
|
|
|
|
fontpath=$(awk '/^keyboard-font/{print $3}' /etc/osk.conf)
|
|
|
|
if [ ! -f $fontpath ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
ret="
|
|
|
|
/etc/osk.conf
|
|
|
|
/etc/ts.conf
|
|
|
|
/etc/pointercal
|
|
|
|
/etc/fb.modes
|
|
|
|
$fontpath
|
|
|
|
"
|
|
|
|
echo "${ret}"
|
|
|
|
}
|
|
|
|
|
2017-07-28 18:51:21 +00:00
|
|
|
get_binaries_extra()
|
|
|
|
{
|
|
|
|
tmp1=$(mktemp /tmp/mkinitfs.XXXXXX)
|
|
|
|
get_binaries > "$tmp1"
|
|
|
|
tmp2=$(mktemp /tmp/mkinitfs.XXXXXX)
|
|
|
|
lddtree -l $BINARIES_EXTRA | sort -u > "$tmp2"
|
|
|
|
ret=$(comm -13 "$tmp1" "$tmp2")
|
|
|
|
rm "$tmp1" "$tmp2"
|
|
|
|
echo "${ret}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Copy files to the destination specified
|
2017-05-26 20:26:25 +00:00
|
|
|
# FIXME: this is a performance bottleneck
|
|
|
|
# $1: files
|
2017-07-28 18:51:21 +00:00
|
|
|
# $2: destination
|
2017-05-26 20:26:25 +00:00
|
|
|
copy_files()
|
|
|
|
{
|
|
|
|
for file in $1; do
|
2017-08-06 13:12:43 +00:00
|
|
|
[ -e "$file" ] || continue
|
2017-09-20 18:36:22 +00:00
|
|
|
cp -a --parents "$file" "$2"
|
2017-05-26 20:26:25 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
create_device_nodes()
|
|
|
|
{
|
2017-07-28 18:51:21 +00:00
|
|
|
mknod -m 666 "$tmpdir/dev/null" c 1 3
|
|
|
|
mknod -m 644 "$tmpdir/dev/random" c 1 8
|
|
|
|
mknod -m 644 "$tmpdir/dev/urandom" c 1 9
|
2017-05-26 20:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
replace_init_variables()
|
|
|
|
{
|
2017-07-28 18:51:21 +00:00
|
|
|
sed -i "s:@INITRAMFS_EXTRA@:${outfile_extra}:g" "$tmpdir/init"
|
2017-05-26 20:26:25 +00:00
|
|
|
}
|
|
|
|
|
2017-07-28 18:51:21 +00:00
|
|
|
# Create a cpio image of the specified folder
|
|
|
|
# $1: folder
|
|
|
|
# $2: outfile
|
2017-05-26 20:26:25 +00:00
|
|
|
create_cpio_image()
|
|
|
|
{
|
2017-07-28 18:51:21 +00:00
|
|
|
cd "$1"
|
2017-05-26 20:26:25 +00:00
|
|
|
find . -print0 \
|
|
|
|
| cpio --quiet -o -H newc \
|
2017-07-28 18:51:21 +00:00
|
|
|
| gzip -1 > "$2"
|
2017-05-26 20:26:25 +00:00
|
|
|
}
|
|
|
|
|
2018-01-31 19:39:09 +00:00
|
|
|
# Required command check with useful error message
|
|
|
|
# $1: command (e.g. "mkimage")
|
|
|
|
# $2: package (e.g. "uboot-tools")
|
|
|
|
# $3: related deviceinfo variable (e.g. "generate_bootimg")
|
|
|
|
require_package()
|
|
|
|
{
|
|
|
|
[ "$(command -v "$1")" == "" ] || return
|
|
|
|
echo "ERROR: 'deviceinfo_$3' is set, but the package '$2' was not"
|
|
|
|
echo "installed! Please add '$2' to the depends= line of your device's"
|
|
|
|
echo "APKBUILD. See also: <https://postmarketos.org/deviceinfo>"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2017-06-29 17:51:17 +00:00
|
|
|
# Legacy u-boot images
|
2017-07-25 20:08:35 +00:00
|
|
|
create_uboot_files()
|
2017-06-29 17:51:17 +00:00
|
|
|
{
|
|
|
|
[ "${deviceinfo_generate_legacy_uboot_initfs}" == "true" ] || return
|
2018-01-31 19:39:09 +00:00
|
|
|
require_package "mkimage" "uboot-tools" "generate_legacy_uboot_initfs"
|
|
|
|
|
2017-06-29 17:51:17 +00:00
|
|
|
echo "==> initramfs: creating uInitrd"
|
2018-01-31 19:39:09 +00:00
|
|
|
mkimage -A arm -T ramdisk -C none -n uInitrd -d "$outfile" \
|
|
|
|
"${outfile/initramfs-/uInitrd-}" || exit 1
|
2017-07-25 20:08:35 +00:00
|
|
|
|
|
|
|
echo "==> kernel: creating uImage"
|
|
|
|
kernelfile="${outfile/initramfs-/vmlinuz-}"
|
|
|
|
if [ -n "${deviceinfo_dtb}" ]; then
|
|
|
|
kernelfile="${kernelfile}-dtb"
|
|
|
|
fi
|
2018-01-31 19:39:09 +00:00
|
|
|
mkimage -A arm -O linux -T kernel -C none -a 80008000 -e 80008000 \
|
|
|
|
-n postmarketos -d $kernelfile "${outfile/initramfs-/uImage-}" || exit 1
|
2017-06-29 17:51:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Android devices
|
|
|
|
create_bootimg()
|
|
|
|
{
|
|
|
|
[ "${deviceinfo_generate_bootimg}" == "true" ] || return
|
2018-06-17 21:26:34 +00:00
|
|
|
require_package "mkbootimg-osm0sis" "mkbootimg" "generate_bootimg"
|
2018-01-31 19:39:09 +00:00
|
|
|
|
2017-06-29 17:51:17 +00:00
|
|
|
echo "==> initramfs: creating boot.img"
|
2017-07-19 20:44:12 +00:00
|
|
|
_base="${deviceinfo_flash_offset_base}"
|
|
|
|
[ -z "$_base" ] && _base="0x10000000"
|
2017-07-25 20:08:35 +00:00
|
|
|
|
|
|
|
kernelfile="${outfile/initramfs-/vmlinuz-}"
|
|
|
|
if [ -n "${deviceinfo_dtb}" ]; then
|
|
|
|
kernelfile="${kernelfile}-dtb"
|
|
|
|
fi
|
2017-11-19 14:25:10 +00:00
|
|
|
_dt=""
|
|
|
|
if [ "${deviceinfo_bootimg_qcdt}" == "true" ]; then
|
|
|
|
_dt="--dt /boot/dt.img"
|
2018-01-31 19:39:09 +00:00
|
|
|
if ! [ -e "/boot/dt.img" ]; then
|
|
|
|
echo "ERROR: File not found: /boot/dt.img, but"
|
|
|
|
echo "'deviceinfo_bootimg_qcdt' is set. Please verify that your"
|
|
|
|
echo "device is a QCDT device by analyzing the boot.img file"
|
|
|
|
echo "(e.g. 'pmbootstrap bootimg_analyze path/to/twrp.img')"
|
|
|
|
echo "and based on that, set the deviceinfo variable to false or"
|
|
|
|
echo "adjust your linux APKBUILD to properly generate the dt.img"
|
|
|
|
echo "file. See also: <https://postmarketos.org/deviceinfo>"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-11-19 14:25:10 +00:00
|
|
|
fi
|
2018-06-17 21:26:34 +00:00
|
|
|
mkbootimg-osm0sis \
|
2017-07-25 20:08:35 +00:00
|
|
|
--kernel "${kernelfile}" \
|
2017-06-29 17:51:17 +00:00
|
|
|
--ramdisk "$outfile" \
|
2017-07-19 20:44:12 +00:00
|
|
|
--base "${_base}" \
|
2017-06-29 17:51:17 +00:00
|
|
|
--second_offset "${deviceinfo_flash_offset_second}" \
|
|
|
|
--cmdline "${deviceinfo_kernel_cmdline}" \
|
|
|
|
--kernel_offset "${deviceinfo_flash_offset_kernel}" \
|
|
|
|
--ramdisk_offset "${deviceinfo_flash_offset_ramdisk}" \
|
|
|
|
--tags_offset "${deviceinfo_flash_offset_tags}" \
|
|
|
|
--pagesize "${deviceinfo_flash_pagesize}" \
|
2017-11-19 14:25:10 +00:00
|
|
|
${_dt} \
|
2018-01-31 19:39:09 +00:00
|
|
|
-o "${outfile/initramfs-/boot.img-}" || exit 1
|
2018-01-13 20:38:29 +00:00
|
|
|
if [ "${deviceinfo_bootimg_blobpack}" == "true" ]; then
|
|
|
|
echo "==> initramfs: creating blob"
|
2018-01-31 19:39:09 +00:00
|
|
|
blobpack "${outfile/initramfs-/blob-}" LNX \
|
|
|
|
"${outfile/initramfs-/boot.img-}" || exit 1
|
2018-01-13 20:38:29 +00:00
|
|
|
fi
|
2017-06-29 17:51:17 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 12:50:40 +00:00
|
|
|
# Create splash screens
|
2017-09-24 14:24:56 +00:00
|
|
|
# $1: "false" to skip clearing the cache if one image is missing
|
2017-07-23 12:50:40 +00:00
|
|
|
generate_splash_screens()
|
|
|
|
{
|
2017-09-24 14:24:56 +00:00
|
|
|
[ "$1" != "false" ] && clean="true" || clean="false"
|
|
|
|
|
|
|
|
splash_version=$(apk info -v | grep postmarketos-splash)
|
2017-10-02 22:39:09 +00:00
|
|
|
if [ -z "$splash_version" ]; then
|
|
|
|
# If package is not installed yet, use latest version from repository
|
|
|
|
splash_version=$(apk search -x postmarketos-splash)
|
|
|
|
fi
|
2017-09-24 14:24:56 +00:00
|
|
|
splash_config="/etc/postmarketos/splash.ini"
|
|
|
|
splash_config_hash=$(md5sum "$splash_config")
|
|
|
|
splash_width=${deviceinfo_screen_width:-720}
|
|
|
|
splash_height=${deviceinfo_screen_height:-1280}
|
|
|
|
splash_cache_dir="/var/cache/postmarketos-splashes"
|
|
|
|
|
|
|
|
# Overwrite $@ to easily iterate over the splash screens. Format:
|
|
|
|
# $1: splash_name
|
|
|
|
# $2: text
|
|
|
|
# $3: arguments
|
2017-10-14 18:10:12 +00:00
|
|
|
set -- "splash-loading" "Loading..." "--center" \
|
2017-09-24 14:24:56 +00:00
|
|
|
"splash-noboot" "boot partition not found\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
|
|
|
"splash-noinitramfsextra" "initramfs-extra not found\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
2018-07-15 21:41:31 +00:00
|
|
|
"splash-norootfs" "rootfs not found\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
2017-12-23 19:22:28 +00:00
|
|
|
"splash-mounterror" "unable to mount root partition\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
|
|
|
"splash-debug-shell" "WARNING\\ndebug-shell is active\\nhttps://postmarketos.org/debug-shell" "--center"
|
2017-09-24 14:24:56 +00:00
|
|
|
|
|
|
|
# Ensure cache folder exists
|
|
|
|
mkdir -p "${splash_cache_dir}"
|
|
|
|
|
|
|
|
# Loop through the splash screens definitions
|
|
|
|
while [ $# -gt 2 ]
|
|
|
|
do
|
|
|
|
splash_name=$1
|
|
|
|
splash_text=$2
|
|
|
|
splash_args=$3
|
2017-10-14 18:10:12 +00:00
|
|
|
|
2017-09-24 14:24:56 +00:00
|
|
|
# Compute hash using the following values concatenated:
|
|
|
|
# - postmarketos-splash package version
|
|
|
|
# - splash config file
|
|
|
|
# - device resolution
|
|
|
|
# - text to be displayed
|
|
|
|
splash_hash_string="${splash_version}#${splash_config_hash}#${splash_width}#${splash_height}#${splash_text}"
|
|
|
|
splash_hash="$(echo "${splash_hash_string}" | md5sum | awk '{ print $1 }')"
|
|
|
|
|
|
|
|
if ! [ -e "${splash_cache_dir}/${splash_name}_${splash_hash}.ppm.gz" ]; then
|
|
|
|
|
|
|
|
# If a cached file is missing, clear the whole cache and start again skipping this step
|
|
|
|
if [ "$clean" = "true" ]; then
|
|
|
|
rm -f ${splash_cache_dir}/*
|
|
|
|
generate_splash_screens false
|
|
|
|
return
|
|
|
|
fi
|
2017-07-28 18:51:21 +00:00
|
|
|
|
2017-09-24 14:24:56 +00:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
pmos-make-splash --text="${splash_text}" $splash_args --config "${splash_config}" \
|
|
|
|
"$splash_width" "$splash_height" "${splash_cache_dir}/${splash_name}_${splash_hash}.ppm"
|
|
|
|
gzip "${splash_cache_dir}/${splash_name}_${splash_hash}.ppm"
|
|
|
|
fi
|
2017-07-23 12:50:40 +00:00
|
|
|
|
2017-09-24 14:24:56 +00:00
|
|
|
cp "${splash_cache_dir}/${splash_name}_${splash_hash}.ppm.gz" "${tmpdir}/${splash_name}.ppm.gz"
|
2017-08-03 16:01:00 +00:00
|
|
|
|
2017-09-24 14:24:56 +00:00
|
|
|
shift 3 # move to the next 3 arguments
|
|
|
|
done
|
2017-07-23 12:50:40 +00:00
|
|
|
}
|
2017-06-29 17:51:17 +00:00
|
|
|
|
2017-07-25 20:08:35 +00:00
|
|
|
# Append the correct device tree to the linux image file
|
|
|
|
append_device_tree()
|
|
|
|
{
|
|
|
|
[ -n "${deviceinfo_dtb}" ] || return
|
|
|
|
dtb="/usr/share/dtb/${deviceinfo_dtb}.dtb"
|
|
|
|
kernel="${outfile/initramfs-/vmlinuz-}"
|
|
|
|
echo "==> kernel: appending device-tree ${deviceinfo_dtb}"
|
pmbootstrap init: kernel selection / remove linux-pmos-lts (#1363)
* As discussed in IRC/matrix, we're removing `linux-postmarketos-lts`
for now. The kernel isn't used right now, and we save lots of
maintenance effort with not updating it every week or so.
* new config option `"kernel"` with possible values:
`"downstream", "mainline", "stable"` (downstream is always
`linux-$devicename`)
* ask for the kernel during `pmbootstrap init` if the device package
has kernel subpackages and install it in `_install.py`
* postmarketos-mkinitfs: display note instead of exit with error when
the `deviceinfo_dtb` file is missing (because we expect it to be
missing for downstream kernels)
* device-sony-amami:
* add kernel subpackages for downstream, mainline
* set `deviceinfo_dtb`
* device-qemu-amd64: add kernel subpackages for stable, lts, mainline
* test cases and test data for new functions
* test case that checks all aports for right usage of the feature:
* don't mix specifying kernels in depends *and* subpackages
* 1 kernel in depends is maximum
* kernel subpackages must have a valid name
* Test if devices packages reference at least one kernel
* Remove `_build_device_depends_note()` which informs the user that
`--ignore-depends` can be used with device packages to avoid building
the kernel. The idea was to make the transition easier after a change
we did months ago, and now the kernel doesn't always get built before
building the device package so it's not relevant anymore.
* pmb/chroot/other.py:
* Add autoinstall=True to kernel_flavors_installed(). When the flag
is set, the function makes sure that at least one kernel for the
device is installed.
* Remove kernel_flavor_autodetect() function, wherever it was used,
it has been replaced with kernel_flavors_installed()[0].
* pmb.helpers.frontend.py: remove code to install at least one kernel,
kernel_flavors_installed() takes care of that now.
2018-04-03 23:50:09 +00:00
|
|
|
if [ -e "$dtb" ]; then
|
|
|
|
cat "$kernel" "$dtb" > "${kernel}-dtb"
|
|
|
|
else
|
|
|
|
echo "NOTE: device tree does not exist, not appending it to the kernel."
|
|
|
|
echo "This is expected for downstream kernels."
|
|
|
|
cp "$kernel" "${kernel}-dtb"
|
2018-01-31 19:39:09 +00:00
|
|
|
fi
|
2017-07-25 20:08:35 +00:00
|
|
|
}
|
|
|
|
|
2017-10-22 21:00:39 +00:00
|
|
|
# Create the initramfs-extra archive
|
|
|
|
# $1: outfile
|
|
|
|
generate_initramfs_extra()
|
|
|
|
{
|
|
|
|
echo "==> initramfs: creating $1"
|
|
|
|
|
|
|
|
osk_conf="$(get_osk_config)"
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
echo "ERROR: Font specified in /etc/osk.conf does not exist!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure cache folder exists
|
|
|
|
mkinitfs_cache_dir="/var/cache/postmarketos-mkinitfs"
|
|
|
|
mkdir -p "$mkinitfs_cache_dir"
|
|
|
|
|
|
|
|
# Generate cache output filename (initfs_extra_cache) by hashing all input files
|
|
|
|
initfs_extra_files=$(echo "$BINARIES_EXTRA$osk_conf" | xargs -0 -I{} sh -c 'ls $1 2>/dev/null' -- {} | sort -u)
|
|
|
|
initfs_extra_files_hashes="$(md5sum $initfs_extra_files)"
|
|
|
|
initfs_extra_hash="$(echo "$initfs_extra_files_hashes" | md5sum | awk '{ print $1 }')"
|
|
|
|
initfs_extra_cache="$mkinitfs_cache_dir/$(basename $1)_${initfs_extra_hash}"
|
|
|
|
|
|
|
|
if ! [ -e "$initfs_extra_cache" ]; then
|
|
|
|
# If a cached file is missing, clear the whole cache and create it
|
|
|
|
rm -f ${mkinitfs_cache_dir}/*
|
|
|
|
|
|
|
|
# Set up initramfs-extra in temp folder
|
|
|
|
tmpdir_extra=$(mktemp -d /tmp/mkinitfs.XXXXXX)
|
|
|
|
mkdir -p "$tmpdir_extra"
|
|
|
|
copy_files "$(get_binaries_extra)" "$tmpdir_extra"
|
|
|
|
copy_files "$osk_conf" "$tmpdir_extra"
|
|
|
|
create_cpio_image "$tmpdir_extra" "$initfs_extra_cache"
|
|
|
|
rm -rf "$tmpdir_extra"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp "$initfs_extra_cache" "$1"
|
|
|
|
}
|
|
|
|
|
2017-05-26 20:26:25 +00:00
|
|
|
# initialize
|
|
|
|
source_deviceinfo
|
2017-07-28 18:51:21 +00:00
|
|
|
parse_commandline "$1" "$2" "$3"
|
2018-03-26 18:12:58 +00:00
|
|
|
check_hook_files
|
2017-05-26 20:26:25 +00:00
|
|
|
echo "==> initramfs: creating $outfile"
|
|
|
|
tmpdir=$(mktemp -d /tmp/mkinitfs.XXXXXX)
|
|
|
|
|
|
|
|
# set up initfs in temp folder
|
|
|
|
create_folders
|
2017-07-28 18:51:21 +00:00
|
|
|
copy_files "$(get_modules)" "$tmpdir"
|
|
|
|
copy_files "$(get_binaries)" "$tmpdir"
|
2017-09-20 18:36:22 +00:00
|
|
|
copy_files "/etc/deviceinfo" "$tmpdir"
|
2017-07-28 18:51:21 +00:00
|
|
|
copy_files "/etc/postmarketos-mkinitfs/hooks/*.sh" "$tmpdir"
|
2017-05-26 20:26:25 +00:00
|
|
|
create_device_nodes
|
|
|
|
ln -s "/bin/busybox" "$tmpdir/bin/sh"
|
|
|
|
install -Dm755 "/usr/share/postmarketos-mkinitfs/init.sh.in" \
|
|
|
|
"$tmpdir/init"
|
|
|
|
install -Dm755 "/usr/share/postmarketos-mkinitfs/init_functions.sh" \
|
|
|
|
"$tmpdir/init_functions.sh"
|
|
|
|
|
|
|
|
# finish up
|
2017-07-23 12:50:40 +00:00
|
|
|
generate_splash_screens
|
2017-05-26 20:26:25 +00:00
|
|
|
replace_init_variables
|
2017-07-28 18:51:21 +00:00
|
|
|
create_cpio_image "$tmpdir" "$outfile"
|
2017-07-25 20:08:35 +00:00
|
|
|
append_device_tree
|
|
|
|
create_uboot_files
|
2017-06-29 17:51:17 +00:00
|
|
|
create_bootimg
|
2017-06-09 23:41:01 +00:00
|
|
|
|
2017-05-26 20:26:25 +00:00
|
|
|
rm -rf "$tmpdir"
|
2017-07-28 18:51:21 +00:00
|
|
|
|
2017-10-22 21:00:39 +00:00
|
|
|
generate_initramfs_extra "$outfile_extra"
|
2017-07-28 18:51:21 +00:00
|
|
|
|
2017-05-26 20:26:25 +00:00
|
|
|
exit 0
|