Skip to content

Commit 7642d17

Browse files
committed
Merge branch 'tkldev-setup-refactor'
2 parents f39fb9f + 542e203 commit 7642d17

2 files changed

Lines changed: 85 additions & 28 deletions

File tree

changelog

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,44 @@ turnkey-tkldev-16.0 (1) turnkey; urgency=low
44
script has been tweaked and some config setup has been moved to package
55
postinst scripts.
66

7+
NOTE: more work is still required to make it possible for users to easily
8+
build packages.
9+
710
* fab:
811

912
- major changes to way that the bootstrap is built. Now leverage Debian's
1013
debootstrap directly (bootstrap components removed from fab, remaining
1114
changes in turnkey/bootstrap repo).
1215

16+
* buildtasks:
17+
18+
- significant refactoring, including inclusion of bt-bootstrap script to
19+
build bootstrap if relevant bootstrap not currently available.
20+
- updates to most bt- scripts for Buster.
21+
- refactoring of bin/signiture-verify to support forcing check of hashfile
22+
GPG signing via '--force-gpg' switch (default behaviour remains unsigned
23+
files just giving warning).
24+
25+
* tkldev-setup:
26+
27+
- refactor to give more meaningful output.
28+
- change order of repo cloning (now 1st) & bootstrap download (now 2nd).
29+
- leverage buildtasks/config/common.cfg (fallback to config.example if not
30+
setup) to set relevant GPG key ID (BT_GPGKEY).
31+
- leverage buildtasks/bin/signiture-verify script to check downloaded
32+
bootstrap file.
33+
34+
* Docs:
35+
36+
- additional development docs now included in build code repo (none
37+
included in built appliance by default; yet).
38+
- many docs rewritten and/or improved.
39+
- many docs still outdated and/or in need of improvement. :(
40+
1341
* Note: Please refer to turnkey-core's changelog for changes common to all
1442
appliances. Here we only describe changes specific to this appliance.
1543

16-
-- Jeremy Davis <jeremy@turnkeylinux.org> Wed, 27 Feb 2020 15:15:43 +1100
44+
-- Jeremy Davis <jeremy@turnkeylinux.org> Fri, 13 Mar 2020 17:05:15 +1100
1745

1846
turnkey-tkldev-15.0 (1) turnkey; urgency=low
1947

overlay/usr/local/sbin/tkldev-setup

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,79 @@
22
# setup/update system ready for building appliances
33

44
fatal() { echo "FATAL [$(basename $0)]: $@" 1>&2; exit 1; }
5+
warning() { echo "WARNING [$(basename $0)]: $@"; }
56
info() { echo "INFO [$(basename $0)]: $@"; }
67

8+
[[ -z "$DEBUG" ]] || set -x
9+
10+
GIT_DEPTH=1
11+
712
RELEASE="${RELEASE:-debian/$(lsb_release -s -c)}"
813
CODENAME="$(basename $RELEASE)"
914
ARCH="${ARCH:-$(dpkg --print-architecture)}"
1015

11-
GPGKEY="A16EB94D"
1216
IMAGES="http://mirror.turnkeylinux.org/turnkeylinux/images"
1317
FAB_PATH="/turnkey/fab"
1418
BOOTSTRAP_NAME="bootstrap-${CODENAME}-${ARCH}"
1519
BOOTSTRAP_PATH="$FAB_PATH/bootstraps/${CODENAME}"
20+
BT_PATH="/turnkey/buildtasks"
21+
BT_VERIFY="$BT_PATH/bin/signature-verify"
1622

17-
if [ ! -d $BOOTSTRAP_PATH ]; then
18-
info "downloading $BOOTSTRAP_NAME"
19-
mkdir -p $(dirname $BOOTSTRAP_PATH)
20-
cd $(dirname $BOOTSTRAP_PATH)
21-
wget -nc $IMAGES/bootstrap/$BOOTSTRAP_NAME.tar.gz
22-
wget -nc $IMAGES/bootstrap/$BOOTSTRAP_NAME.tar.gz.hash
23-
24-
info "verifying $BOOTSTRAP_NAME"
25-
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 0x$GPGKEY
26-
gpg --verify $BOOTSTRAP_NAME.tar.gz.hash
23+
[[ $(id -u) -eq 0 ]] || fatal "Root user required. Please rerun with sudo."
2724

28-
info "unpacking $BOOTSTRAP_NAME"
29-
mkdir $BOOTSTRAP_PATH
30-
tar -zxf $BOOTSTRAP_NAME.tar.gz -C $BOOTSTRAP_PATH
31-
fi
32-
33-
g() {
25+
clone_or_update() {
3426
src=https://github.com/$1
3527
dst=$2
3628
mkdir -p $(dirname $dst)
37-
if [ -d $dst ]; then
38-
info "updating $dst"
39-
GIT_DIR=$dst/.git git pull
29+
if [[ -d "$dst" ]]; then
30+
info "$dst exists, attempting update."
31+
git_dir=$dst/.git
32+
if [[ -d "$git_dir" ]]; then
33+
GIT_DIR=$git_dir git pull || warning "Updating $dst failed, skipping."
34+
else
35+
warning "$dst exists, but is not a git repo - skipping."
36+
return
37+
fi
4038
else
41-
info "cloning $src"
42-
git clone $src $dst
39+
info "Cloning $src into $dst."
40+
git clone --depth $GIT_DEPTH $src $dst || warning "Cloning $dst failed, skipping."
4341
fi
4442
}
4543

46-
g turnkeylinux/buildtasks /turnkey/buildtasks
47-
g turnkeylinux/tklbam-profiles /turnkey/tklbam-profiles
48-
g turnkeylinux/cdroots $FAB_PATH/cdroots
49-
g turnkeylinux/common $FAB_PATH/common
50-
g turnkeylinux-apps/core $FAB_PATH/products/core
44+
clone_or_update turnkeylinux/buildtasks $BT_PATH
45+
clone_or_update turnkeylinux/tklbam-profiles /turnkey/tklbam-profiles
46+
clone_or_update turnkeylinux/cdroots $FAB_PATH/cdroots
47+
clone_or_update turnkeylinux/common $FAB_PATH/common
48+
clone_or_update turnkeylinux-apps/core $FAB_PATH/products/core
5149

50+
if [[ -f "$BT_PATH/config/common.cfg" ]]; then
51+
. $BT_PATH/config/common.cfg
52+
elif [[ -f "$BT_PATH/config.example/common.cfg" ]]; then
53+
. $BT_PATH/config.example/common.cfg
54+
else
55+
fatal "$BT_PATH config not found, unable to determine GPG key ID (BT_GPGKEY)."
56+
fi
57+
58+
if [[ -d "$BOOTSTRAP_PATH" ]]; then
59+
info "$BOOTSTRAP_PATH exists, skipping download."
60+
else
61+
info "Downloading $BOOTSTRAP_NAME"
62+
mkdir -p $(dirname $BOOTSTRAP_PATH)
63+
cd $(dirname $BOOTSTRAP_PATH)
64+
bootstrap_file=$BOOTSTRAP_PATH
65+
wget -nc $IMAGES/bootstrap/$BOOTSTRAP_NAME.tar.gz \
66+
|| fatal "Downloading $BOOTSTRAP_NAME failed."
67+
wget -nc $IMAGES/bootstrap/$BOOTSTRAP_NAME.tar.gz.hash \
68+
|| fatal "Downloading $BOOTSTRAP_NAME hash file failed."
69+
70+
if [[ -f "$BT_VERIFY" ]]; then
71+
bootstrap_file=$(dirname $BOOTSTRAP_PATH)/$BOOTSTRAP_NAME.tar.gz
72+
BT_DEBUG=$DEBUG $BT_VERIFY --force-gpg $bootstrap_file $bootstrap_file.hash
73+
else
74+
fatal "$BT_VERIFY script not found, unable to verfiy downloaded files."
75+
fi
76+
info "Unpacking $BOOTSTRAP_NAME"
77+
mkdir $BOOTSTRAP_PATH
78+
tar -zxf $BOOTSTRAP_NAME.tar.gz -C $BOOTSTRAP_PATH
79+
fi
80+
info "$(basename $0) complete."

0 commit comments

Comments
 (0)