Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions overlay/usr/local/sbin/tkldev-setup
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ Env vars:
CDROOTS_REFS Candidate refs for turnkeylinux/cdroots
GIT_DEPTH Depth to clone (default: $GIT_DEPTH) - setting to 'full'
gives same behavior as -n|--full-clone
GIT_REMOTE_URL Remote URL to clone/update from
GIT_REMOTE_URL Remote URL to clone/update from. On the keel-linux
organization appliance APP is cloned from keel-APP
(core from keel-core) into $FAB_PATH/products/APP
(default: 'https://github.com/turnkeylinux')
GIT_REMOTE_NAME Remote name (default: 'origin')
DEBUG Verbose output (useful for debugging)
Expand Down Expand Up @@ -159,6 +161,19 @@ update_repo() {
fi
}

# app_repo_name APP REMOTE_URL: name of the repository holding appliance APP
# on REMOTE_URL. On the keel-linux organization appliances carry the keel-
# prefix (core is keel-core); anywhere else the name is used as is.
app_repo_name() {
local app=$1
local remote=$2
if [[ "$remote" =~ [:/][Kk]eel-[Ll]inux(/|$) ]] && [[ "$app" != keel-* ]]; then
echo "keel-$app"
else
echo "$app"
fi
}

clone_or_update() {
local remote_url
remote_url="$GIT_REMOTE_URL"
Expand Down Expand Up @@ -333,7 +348,8 @@ clone_or_update buildtasks "$BT_PATH" "${BT_REFS[@]}"
clone_or_update tklbam-profiles "$TKLBAM_PATH" "${TKLBAM_REFS[@]}"
clone_or_update common "$FAB_PATH/common" "${COMMON_REFS[@]}"
for app in "${APPS[@]}"; do
clone_or_update _APP_ "$app" "$FAB_PATH/products/$app" "${APP_REFS[@]}"
clone_or_update _APP_ "$(app_repo_name "$app" "$APP_GIT_REMOTE_URL")" \
"$FAB_PATH/products/$app" "${APP_REFS[@]}"
done

if [[ "${FAB_ARCH}" == "amd64" ]]; then
Expand Down
29 changes: 29 additions & 0 deletions tests/tkldev-setup.bats
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,35 @@ output_has() {
not_logged "mirror-apps"
}

@test "on the keel-linux organization an appliance is cloned from keel-APP" {
export GIT_REMOTE_URL="https://github.com/keel-linux"
run_setup
[ "$status" -eq 0 ]
logged "https://github.com/keel-linux/keel-core.git $FAB_PATH/products/core"
logged "https://github.com/keel-linux/common.git $FAB_PATH/common"
not_logged "keel-linux-apps"
not_logged "keel-common"
not_logged "products/keel-core"
}

@test "an SSH remote of the organization maps the appliance names too" {
export GIT_REMOTE_URL="[email protected]:Keel-Linux/"
run_setup wordpress keel-lamp
[ "$status" -eq 0 ]
logged "[email protected]:Keel-Linux/keel-wordpress.git $FAB_PATH/products/wordpress"
logged "[email protected]:Keel-Linux/keel-lamp.git $FAB_PATH/products/keel-lamp"
not_logged "keel-keel-lamp"
}

@test "app_repo_name keeps the name on any other remote" {
call app_repo_name core "https://github.com/turnkeylinux-apps"
[ "$output" = core ]
call app_repo_name core "https://[2001:db8::1]/mirror"
[ "$output" = core ]
call app_repo_name core "https://[2001:db8::1]/keel-linux"
[ "$output" = keel-core ]
}

@test "apt is updated and fab installed" {
run_setup
[ "$status" -eq 0 ]
Expand Down
Loading