@@ -10,7 +10,25 @@ make_git_package() {
1010 # All remaining arguments are artifact mappings in src:dest format
1111
1212 mkdir -p " $DESTDIR /usr/bin"
13- local cache_dir=" $BUILDDIR /${package} -${version} "
13+
14+ # Clone the repository
15+ local build_dir=" $BUILDROOT /build/$package "
16+ set +x
17+ echo " Cloning ${git_url} "
18+ if [ -f " $BUILDDIR /.ghtoken" ]; then
19+ git_url=" ${git_url/# https: \/\/ github.com/ https: \/\/ x-access-token: $( cat $BUILDDIR / .ghtoken )@ github.com} "
20+ fi
21+ git clone --depth 1 --branch " $version " " $git_url " " $build_dir " || (
22+ echo " Could not clone branch/tag, attempting to checkout the commit by sha"
23+ git clone -" $git_url " " $build_dir " &&
24+ git -C " $build_dir " checkout " $version "
25+ )
26+ set -x
27+
28+ # Get the git reference
29+ local git_describe=$( git -C " $build_dir " describe --tags --always )
30+
31+ local cache_dir=" $BUILDDIR /${package} -${git_describe# ${package} / } "
1432
1533 # Use cached artifacts if available
1634 if [ -n " $cache_dir " ] && [ -d " $cache_dir " ] && [ " $( ls -A " $cache_dir " 2> /dev/null) " ]; then
@@ -30,14 +48,6 @@ make_git_package() {
3048 fi
3149
3250 # Build from source
33- local build_dir=" $BUILDROOT /build/$package "
34- if [ -f " $cache_dir /.ghtoken" ]; then
35- set +x
36- git clone --depth 1 --branch " $version " " ${git_url/# https: \/\/ github.com/ https: \/\/ x-access-token: $( cat $cache_dir / .ghtoken )@ github.com} " " $build_dir "
37- set -x
38- else
39- git clone --depth 1 --branch " $version " " $git_url " " $build_dir "
40- fi
4151 mkosi-chroot bash -c " cd '/build/$package ' && $build_cmd "
4252
4353 # Copy artifacts to image and cache
0 commit comments