1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
raspberrypi-build/build.sh

106 lines
2 KiB
Bash
Raw Normal View History

2016-04-11 02:21:07 -04:00
#!/bin/bash -e
2017-07-02 20:52:41 -04:00
export IMG_NAME='BarnacleOS'
export HOSTNAME='barnacleos'
export USERNAME='user'
export PASSWORD='password'
2017-07-02 07:07:37 -04:00
export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2017-07-02 07:08:24 -04:00
export SCRIPT_DIR="$BASE_DIR/scripts"
2017-07-02 07:37:33 -04:00
export FUNCTIONS_DIR="$BASE_DIR/functions"
2017-07-02 07:08:24 -04:00
export DEPLOY_DIR="$BASE_DIR/deploy"
2017-07-02 20:17:20 -04:00
export ROOTFS_DIR="$BASE_DIR/rootfs"
2017-07-02 20:24:50 -04:00
export MOUNT_DIR="$BASE_DIR/mnt"
2017-07-02 07:07:37 -04:00
2017-07-02 20:55:48 -04:00
export IMG_DATE="$(date +%Y-%m-%d)"
2017-07-02 09:18:10 -04:00
2017-07-02 20:55:48 -04:00
export IMG_FILE="$DEPLOY_DIR/$IMG_DATE-${IMG_NAME}.img"
export ZIP_FILE="$DEPLOY_DIR/$IMG_DATE-${IMG_NAME}.zip"
2017-07-02 14:01:01 -04:00
2017-07-02 07:07:37 -04:00
export QUILT_NO_DIFF_INDEX=1
export QUILT_NO_DIFF_TIMESTAMPS=1
2017-07-02 07:10:54 -04:00
export QUILT_REFRESH_ARGS='-p ab'
2017-07-02 07:07:37 -04:00
2017-07-02 21:04:47 -04:00
source "$FUNCTIONS_DIR/logging.sh"
source "$FUNCTIONS_DIR/dependencies_check.sh"
source "$SCRIPT_DIR/common.sh"
2017-07-02 20:58:19 -04:00
main() {
if [ "$(id -u)" != '0' ]; then
echo 'Please run as root' 1>&2
exit 1
fi
2017-07-02 20:56:30 -04:00
2017-07-02 20:58:19 -04:00
dependencies_check "$BASE_DIR/depends"
mkdir -p "$DEPLOY_DIR"
2017-07-02 21:37:36 -04:00
mkdir -p "$MOUNT_DIR"
2017-07-02 07:07:37 -04:00
2017-07-02 21:42:49 -04:00
local SUB_STAGE_DIR="$BASE_DIR/stage0/00-substage"
2017-07-02 07:30:26 -04:00
2017-07-02 21:02:33 -04:00
pushd "$SUB_STAGE_DIR" > /dev/null
2017-07-02 15:11:15 -04:00
for i in {00..99}; do
2017-07-02 21:02:33 -04:00
task_patches "$SUB_STAGE_DIR/$i-patches"
task_run "$SUB_STAGE_DIR/$i-run.sh"
2017-07-02 15:11:15 -04:00
done
popd > /dev/null
2017-07-02 14:53:17 -04:00
}
2017-07-02 07:30:26 -04:00
2017-07-02 15:24:25 -04:00
task_patches() {
2017-07-02 16:05:56 -04:00
if [ -d "$1" ]; then
log_begin "$1"
2017-07-02 22:39:01 -04:00
pushd "$ROOTFS_DIR" > /dev/null
2017-07-02 15:24:25 -04:00
2017-07-02 16:05:56 -04:00
export QUILT_PATCHES="$1"
2017-07-02 15:24:25 -04:00
2017-07-02 22:39:01 -04:00
rm -rf .pc
mkdir -p .pc
2017-07-02 15:24:25 -04:00
2017-07-02 16:05:56 -04:00
if [ -e "$1/EDIT" ]; then
2017-07-02 15:24:25 -04:00
tput setaf 3 # Yellow color
echo 'Dropping into bash to edit patches...'
echo 'Tutorial: https://raphaelhertzog.com/2012/08/08/how-to-use-quilt-to-manage-patches-in-debian-packages/'
echo 'Example:'
echo ' quilt new XX-name-of-the-patch.diff'
echo ' quilt edit rootfs/path/to/file'
echo ' quilt diff'
echo ' quilt refresh'
tput sgr0 # No color
bash
fi
quilt upgrade
RC=0
quilt push -a || RC=$?
2017-07-02 22:39:01 -04:00
rm -rf .pc
2017-07-02 15:24:25 -04:00
case "$RC" in
0|2)
;;
*)
false
;;
esac
popd > /dev/null
2017-07-02 16:05:56 -04:00
log_end "$1"
2017-07-02 15:24:25 -04:00
fi
}
2017-07-02 00:05:20 -04:00
task_run() {
if [ -x "$1" ]; then
log_begin "$1"
"$1"
log_end "$1"
fi
}
main