summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2018-08-29 10:40:21 +0200
committerKarel Kočí <karel.koci@nic.cz>2018-08-29 10:40:21 +0200
commit8c9636f9a64d803b8224e4f808598eccf901ea47 (patch)
tree585e8ef7134cdb279db5bba68ba1ed02241db5fa
parent7f64f19870c7df471e5373db77bedb2046f14324 (diff)
downloadlaminar-cnf-8c9636f9a64d803b8224e4f808598eccf901ea47.tar.gz
laminar-cnf-8c9636f9a64d803b8224e4f808598eccf901ea47.tar.bz2
laminar-cnf-8c9636f9a64d803b8224e4f808598eccf901ea47.zip
Replace git_fetch with git_clone that does one-depth clone
-rw-r--r--scripts/utils20
-rwxr-xr-xtemplates/turris3x.run2
-rwxr-xr-xtemplates/turris4x.run4
3 files changed, 22 insertions, 4 deletions
diff --git a/scripts/utils b/scripts/utils
index 1c364a0..4f8fbec 100644
--- a/scripts/utils
+++ b/scripts/utils
@@ -58,7 +58,25 @@ git_fetch() {
git_fetch_bare "$1" "$2"
local BRANCH="$3"
[ -n "$BRANCH" ] || BRANCH=master
- git --git-dir="$WORKSPACE/$2" --bare worktree add --detach $2 $BRANCH
+ git --git-dir="$WORKSPACE/$2" --bare worktree add --detach "$2" "$BRANCH"
+}
+
+# Clones one depth given repository with given branch/tag/hash
+# First agument has to be a source URL
+# Second argument is name of directory to which will be directory cloned in.
+# Second argument is optional and should be branch name (master is used if not
+# provided).
+git_clone() {
+ local BRANCH="$3"
+ [ -n "$BRANCH" ] || BRANCH=master
+ (
+ mkdir "$2"
+ cd "$2"
+ git init
+ git remote add origin "$1"
+ git fetch --depth 1 origin "$BRANCH"
+ git checkout FETCH_HEAD
+ )
}
# Lock special lock for this job
diff --git a/templates/turris3x.run b/templates/turris3x.run
index 1d4b100..c99342d 100755
--- a/templates/turris3x.run
+++ b/templates/turris3x.run
@@ -4,7 +4,7 @@ set -e
. utils
echo_stage "Get packages"
-git_fetch "https://git.cynerd.cz/openwrt-personal-pkgs" pkgs turris3x
+git_clone "https://git.cynerd.cz/openwrt-personal-pkgs" pkgs turris3x
SDK="$WORKSPACE/sdk.tar.bz2"
if [ ! -e "$SDK" ] || [ $(expr $(date -u +%s) - $(stat -c %Z "$SDK")) -gt 86400 ]; then
diff --git a/templates/turris4x.run b/templates/turris4x.run
index a7b3c5c..4465d66 100755
--- a/templates/turris4x.run
+++ b/templates/turris4x.run
@@ -6,7 +6,7 @@ set -e
MAKE="make -j4 IS_TTY=1 BUILD_LOG=1"
echo_stage "Get packages"
-git_fetch "https://git.cynerd.cz/openwrt-personal-pkgs" pkgs
+git_clone "https://git.cynerd.cz/openwrt-personal-pkgs" pkgs
curl "https://repo.turris.cz/$BOARD-$BRANCH/git-hash" > git-hash
laminar_self_lock sdk
@@ -21,7 +21,7 @@ else
echo_stage "Get turris-build"
HASH="$(awk '/ \* turris-build\: /{print $3}' git-hash)"
HASH="9544f32cf06c29aedf8c3d88b9ff8745179dfa69" # TODO remove this when repo_checkout is integrated
- git_fetch "https://gitlab.labs.nic.cz/turris/turris-build.git" turris-build "$HASH"
+ git_clone "https://gitlab.labs.nic.cz/turris/turris-build.git" turris-build "$HASH"
echo_stage "Prepare SDK"
mkdir openwrt