diff options
author | Ting-Wei Lan <lantw@src.gnome.org> | 2016-02-28 17:52:38 +0800 |
---|---|---|
committer | Ting-Wei Lan <lantw@src.gnome.org> | 2016-02-28 19:58:55 +0800 |
commit | 0cfbd3cd19eacd0f269c66234887b20a792f12b9 (patch) | |
tree | 6d0c74f27a1b1daddccc324f1a090e55215c143b | |
parent | 5cc2436c9ed09f239b973463238de7c4f23f2fb8 (diff) | |
download | freebsd-gnome-livecd-0cfbd3cd19eacd0f269c66234887b20a792f12b9.tar.gz freebsd-gnome-livecd-0cfbd3cd19eacd0f269c66234887b20a792f12b9.tar.zst freebsd-gnome-livecd-0cfbd3cd19eacd0f269c66234887b20a792f12b9.zip |
Move configuration out of build.sh and drop most hard-coded paths
To make the script more portable, most /home/lantw44/livecd is replaced
by `pwd`, which provides the absolute path of the current directory.
Add -release suffix to names used by release configuration to make them
more consistent with debug configuration.
-rwxr-xr-x | build-debug.sh | 15 | ||||
-rwxr-xr-x | build-release.sh | 21 | ||||
-rw-r--r--[-rwxr-xr-x] | build.sh | 52 | ||||
-rw-r--r-- | gnome3-release-pkgs (renamed from gnome3-pkgs) | 0 |
4 files changed, 66 insertions, 22 deletions
diff --git a/build-debug.sh b/build-debug.sh index 58c9b4e..00f9f8b 100755 --- a/build-debug.sh +++ b/build-debug.sh @@ -1,13 +1,20 @@ #!/bin/sh +freebsd_version="10.1" +gnome_version="3.15.92" +gnome_underscore="3_15_92" +date="`date '+%Y%m%d'`" + # == Configurations ========================================================= -root="/home/lantw44/livecd/root-debug" -cdroot="/home/lantw44/livecd/cdroot-debug" -image="/home/lantw44/livecd/out/FreeBSD-10.1-GNOME-3.15-`date '+%Y%m%d'`-debug.iso" +src="`pwd`/src" +root="`pwd`/root-debug" +cdroot="`pwd`/cdroot-debug" +image="`pwd`/out/FreeBSD-${freebsd_version}-GNOME-${gnome_version}-${date}-debug.iso" repo="/usr/local/poudriere/data/packages/freebsd10-ports-gnome-gnome3-debug" -pkgs="`cat /home/lantw44/livecd/gnome3-debug-pkgs`" +pkgs="`cat gnome3-debug-pkgs`" +vol="FREEBSD_GNOME_${gnome_underscore}_DEBUG" # =========================================================================== diff --git a/build-release.sh b/build-release.sh new file mode 100755 index 0000000..d6a0804 --- /dev/null +++ b/build-release.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +freebsd_version="10.1" +gnome_version="3.15.92" +gnome_underscore="3_15_92" +date="`date '+%Y%m%d'`" + +# == Configurations ========================================================= + +src="`pwd`/src" +root="`pwd`/root-release" +cdroot="`pwd`/cdroot-release" +image="`pwd`/out/FreeBSD-${freebsd_version}-GNOME-${gnome_version}-${date}.iso" + +repo="/usr/local/poudriere/data/packages/freebsd10-ports-gnome-gnome3-release" +pkgs="`cat gnome3-release-pkgs`" +vol="FREEBSD_GNOME_${gnome_underscore}_DEBUG" + +# =========================================================================== + +. "`dirname "$0"`/build.sh" @@ -1,22 +1,5 @@ -#!/bin/sh - -# == Configurations ========================================================= - -: ${src:="/home/lantw44/livecd/src"} -: ${root:="/home/lantw44/livecd/root"} -: ${cdroot:="/home/lantw44/livecd/cdroot"} -: ${image:="/home/lantw44/livecd/out/FreeBSD-10.1-GNOME-3.15-`date '+%Y%m%d'`.iso"} - -: ${repo="/usr/local/poudriere/data/packages/freebsd10-ports-gnome-gnome3"} -: ${pkgs="`cat /home/lantw44/livecd/gnome3-pkgs`"} - -# =========================================================================== - -vol="FREEBSD_LIVE_10_1_GNOME_3_15_92" steps="system packages user config uzip ramdisk boot image" -pwdir="`dirname "$0"`" -cd "${pwdir}" -pwdir="`pwd`" +pwdir="$(realpath $(dirname "$0"))" system () { install -o root -g wheel -m 755 -d "${root}" @@ -119,6 +102,39 @@ if [ "`id -u`" '!=' "0" ]; then exit 1 fi +# This check cannot be done reliably, but it should be able to catch the +# most common mistake. +if [ "$(basename "$0")" = "build.sh" ] && [ "${pwdir}" = "$(realpath $(pwd))" ]; then + echo "This script cannot be run directly." + echo "Please create a wrapper script that sources this file instead." + echo "You can use build-release.sh and build-debug.sh as examples." + exit 1 +fi + +# Check whether required variables are defined. +assert_dir_or_file () { + if [ -z "$2" ] || [ "$(realpath "$2" 2>/dev/null)" = "/" ]; then + echo "Variable '$1' is unset or set to the root directory." + exit 1 + fi +} +assert_empty () { + if [ -z "$2" ]; then + echo "Variable '$1' is empty." + echo "If no package have to be installed, set it to 'pkg'." + exit 1 + fi +} +assert_dir_or_file src "${src}" +assert_dir_or_file root "${root}" +assert_dir_or_file cdroot "${cdroot}" +assert_dir_or_file image "${image}" +assert_dir_or_file repo "${repo}" +assert_empty pkgs "${pkgs}" +assert_empty vol "${vol}" +unset assert_dir_or_file +unset assert_empty + printf "All steps: \033[1;33m%s\033[m\n" "${steps}" printf "(E)dit or (R)un? " read edit_or_run diff --git a/gnome3-pkgs b/gnome3-release-pkgs index 89e7dab..89e7dab 100644 --- a/gnome3-pkgs +++ b/gnome3-release-pkgs |