Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 68307c86a0
Fetching contributors…

Cannot retrieve contributors at this time

executable file 108 lines (88 sloc) 2.729 kb
#!/bin/bash
scriptpath="$(readlink -f $0)"
workdir="${scriptpath%/*}"
bootstrap="${workdir}/../bootstrap"
sourceroot="${workdir}/../sourceroot"
die() {
echo -e "\033[1;30m>\033[0;31m>\033[1;31m> ERROR:\033[0m ${@}" && exit 1
}
einfo() {
echo -ne "\033[1;30m>\033[0;36m>\033[1;36m> \033[0m${@}\n"
}
ewarn() {
echo -ne "\033[1;30m>\033[0;33m>\033[1;33m> \033[0m${@}\n"
}
# Get version.
git_tag="$(git describe --tags --exact-match HEAD 2> /dev/null)"
git_branch="$(git symbolic-ref HEAD 2>/dev/null)"
if [ -z "${git_branch}" ]; then die "Not under git?"; fi
git_branch="${git_branch##*/}"
if [ "${git_branch}" = 'master' ] && [ -n "${git_tag}" ]; then
version="${git_tag}"
else
git_latestcommit="$(git log -1 --date='short' --format='%h-%ad')"
version="${git_branch}-${git_latestcommit}"
fi
echo "${version}" > "${sourceroot}/VERSION"
einfo "better-initramfs ${version}"
prepare() {
einfo "Deploying bootstraped binaries into source root ..."
cd "${bootstrap}/output" || die "Failed to cd into bootstrap/output/"
if test -f busybox; then
cp busybox "${sourceroot}/bin/busybox"
( cd "${sourceroot}/bin/" && rm -f sh && ln -s busybox sh )
else
die "No busybox binary found."
fi
if test -f cryptsetup.static; then
cp cryptsetup.static "${sourceroot}/bin/cryptsetup"
else
ewarn "No cryptsetup binary found, DMCrypt LUKS support will be disabled."
fi
if test -f lvm.static; then
cp lvm.static "${sourceroot}/bin/lvm"
else
ewarn "No lvm binary found, LVM support will be disabled."
fi
if test -f mdadm.static; then
cp mdadm.static "${sourceroot}/bin/mdadm"
else
ewarn "No mdadm binary found, Software Raid support will be disabled."
fi
if test -f dropbearmulti; then
cp dropbearmulti "${sourceroot}/bin/dropbearmulti"
( cd "${sourceroot}/bin/" && rm -f dropbear dropbearkey && ln -s dropbearmulti dropbear && ln -s dropbearmulti dropbearkey )
else
ewarn "No dropbearmulti binary found, Remote rescue shell support will be disabled."
fi
if test -f resume; then
cp resume "${sourceroot}/bin/resume"
else
ewarn "No resume binary found, Swsusp will be disabled."
fi
}
image() {
if ! [ -f "${sourceroot}/bin/busybox" ]; then die "Initramfs will not work without busybox."; fi
einfo 'Building image...'
( cd "${sourceroot}" && find . | cpio --quiet -H newc -o | gzip -9 > ../output/initramfs.cpio.gz)
if [ -f "${sourceroot}/../output/initramfs.cpio.gz" ]; then
einfo "output/initramfs.cpio.gz is ready."
else
die "There is no initramfs.cpio.gz, something goes wrong."
fi
}
case $1 in
prepare|image|clean)
$1
;;
all)
echo
einfo "Quickstart:"
echo
echo " bootstrap/bootstrap-all"
echo " make prepare"
echo " make image"
echo
exit 1
;;
esac
Jump to Line
Something went wrong with that request. Please try again.