mirror of
git://soft.sys114.com/odroid-stamper
synced 2025-12-18 13:48:41 +09:00
Signed-off-by: Dongjin Kim <tobetter@gmail.com> Change-Id: I5d84f0cde2123c25f3cbd30c6f500cabaaeac2a9
147 lines
3.9 KiB
Bash
Executable File
147 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#set -x
|
|
|
|
ODROID_STAMPER_DIR="/usr/share/odroid-stamper"
|
|
|
|
TOPDIR=${ODROID_STAMPER_CHECKOUT:-${ODROID_STAMPER_DIR}}
|
|
WORKDIR=$PWD
|
|
RUN_MENU=true
|
|
INTERNAL=${INTERNAL:-false}
|
|
|
|
DEFAULT_CONFIG=${WORKDIR}/.config
|
|
|
|
usage() {
|
|
echo "Usage: $(basename $0) [--help] [--output=<path>] [--live]"
|
|
echo
|
|
echo " --help: this help message"
|
|
echo " --output=<path>: output directory for image files."
|
|
echo " --iso: build target OS image as ISO format."
|
|
echo " --live: enforce to build live boot system image."
|
|
echo " --compress: compress the final OS image using 'xz'."
|
|
echo " --keep-builddir: prevent removing temporary directory"
|
|
echo " after building an image."
|
|
echo " --kernel: kernel package name to use"
|
|
echo " --linuxfactory: alternative server IP address of 'ppa.linuxfactory.or.kr'"
|
|
exit 1
|
|
}
|
|
|
|
for opt in "$@"; do
|
|
case $opt in
|
|
--help)
|
|
usage
|
|
;;
|
|
--output=*)
|
|
out_dir="${opt#*=}"
|
|
;;
|
|
|
|
--board=*) opt_board="${opt#*=}";;
|
|
--distro=*) opt_distro="${opt#*=}";;
|
|
--flavour=*) opt_flavour="${opt#*=}";;
|
|
--username=*) opt_username="${opt#*=}";;
|
|
--password=*) opt_password="${opt#*=}";;
|
|
--no-live) opt_livesystem=false;;
|
|
--live) opt_livesystem=true;;
|
|
--iso) opt_isoimage=true;;
|
|
--compress) opt_compress=true;;
|
|
--internal) opt_internal=true;;
|
|
--keep-builddir)
|
|
opt_keep_builddir=true;;
|
|
--kernel=*) opt_kernel_package="${opt#*=}";;
|
|
--linuxfactory=*)
|
|
opt_linuxfactory="${opt#*=}";;
|
|
--custom=*)
|
|
opt_custom="${opt#*=}";;
|
|
--addon-wifi) opt_wifi=true;;
|
|
esac
|
|
done
|
|
|
|
[ "x${out_dir}" = "x" ] && out_dir=${WORKDIR}
|
|
build_dir="${out_dir}/BUILD"
|
|
download_dir="/var/cache/odroid-stamper/downloads"
|
|
|
|
. ${TOPDIR}/menu
|
|
. ${TOPDIR}/default
|
|
. ${TOPDIR}/functions
|
|
|
|
[ -z ${opt_custom} ] || CUSTOMOS=${opt_custom}
|
|
|
|
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/config ]; then
|
|
cp -f ${TOPDIR}/custom/${CUSTOMOS}/config ${DEFAULT_CONFIG} || exit 1
|
|
RUN_MENU=false
|
|
fi
|
|
|
|
if [ ! -f ${DEFAULT_CONFIG} ]; then
|
|
default_config ${DEFAULT_CONFIG}
|
|
fi
|
|
|
|
. ${DEFAULT_CONFIG}
|
|
|
|
if [ ! -z ${opt_board} ]; then
|
|
BOARD=${opt_board}
|
|
ARCH=$(get_arch ${BOARD})
|
|
fi
|
|
[ -z ${opt_distro} ] || DISTRO=${opt_distro}
|
|
[ -z ${opt_flavour} ] || FLAVOUR=${opt_flavour}
|
|
[ -z ${opt_username} ] || DEFAULT_USER=${opt_username}
|
|
[ -z ${opt_password} ] || DEFAULT_PASSWD=${opt_password}
|
|
|
|
# Not to run menu when mandatory options are all given in command.
|
|
if [[ ! -z ${opt_board} ]] && [[ ! -z ${opt_distro} ]] && [[ ! -z ${opt_flavour} ]] \
|
|
&& [[ ! -z ${opt_username} ]] && [[ ! -z ${opt_password} ]]; then
|
|
TARGET_DEVICE=$PWD/binary.img
|
|
ALLOW_ROOT_LOGIN=false
|
|
RUN_MENU="false"
|
|
fi
|
|
|
|
[ "x${opt_livesystem}" = "xtrue" ] && LIVESYSTEM=true
|
|
[ "x${opt_isoimage}" = "xtrue" ] && ISOIMAGE=true
|
|
[ "x${opt_compress}" = "xtrue" ] && COMPRESS=true
|
|
[ "x${opt_internal}" = "xtrue" ] && INTERNAL=true
|
|
[ "x${opt_wifi}" = "xtrue" ] && WIFI=true
|
|
|
|
[ "${RUN_MENU}" = "true" ] && do_menu
|
|
[ "x${ISOIMAGE}" = "xtrue" ] && LIVESYSTEM=true
|
|
[ "x${WIFI}" = "xtrue" ] && BUILD_DKMS=true
|
|
|
|
if [ "x${IMAGE_FILE}" = "x" ]; then
|
|
if [ "x${CUSTOMOS}" = "x" ]; then
|
|
MIDNAME=${FLAVOUR}
|
|
else
|
|
MIDNAME=${CUSTOMOS}
|
|
fi
|
|
IMAGE_FILE=$(image_file ${DISTRO} ${MIDNAME} ${BOARD})
|
|
fi
|
|
|
|
if [ "x${LIVESYSTEM}" = "xtrue" ]; then
|
|
IMAGE_FILE=${IMAGE_FILE}-live
|
|
fi
|
|
|
|
IMAGE_FILE=$(echo ${IMAGE_FILE} | tr '/' '-')
|
|
OUTFILE=${out_dir}/${IMAGE_FILE}
|
|
|
|
if [ ! -d ${TOPDIR}/distro/${DISTRO}/${FLAVOUR} ]; then
|
|
echo "No build target for ${DISTRO}/${FLAVOUR}"
|
|
usage
|
|
exit 0
|
|
fi
|
|
|
|
[ -f ${TOPDIR}/distro/${DISTRO}/common/functions ] && \
|
|
. ${TOPDIR}/distro/${DISTRO}/common/functions
|
|
[ -f ${TOPDIR}/distro/${DISTRO}/${FLAVOUR}/functions ] && \
|
|
. ${TOPDIR}/distro/${DISTRO}/${FLAVOUR}/functions
|
|
. ${TOPDIR}/boards/${BOARD}/functions
|
|
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/functions ]; then
|
|
. ${TOPDIR}/custom/${CUSTOMOS}/functions
|
|
fi
|
|
|
|
trap "trap_ctrlc" 2
|
|
trap "cleanup" 0
|
|
trap "panic" 1 3 15
|
|
|
|
[ "x${TARGET_DEVCIE}" = "x" ] && TARGET_DEVICE=${out_dir}/binary.img
|
|
|
|
do_custom_installer ${download_dir} ${out_dir}
|
|
|
|
# vim: set ft=sh ts=4 sw=4 expandtab
|