Page MenuHomeVyOS Platform

Can not build VyOS if repository it not cloned to a branch
Closed, ResolvedPublicBUG

Description

This was discussed in slack, where a user was missing the Git commit ID in his custom build

Reason is/was git clone --single-branch -b 1.4.0-epa1 https://github.com/vyos/vyos-build checks out the 1.4.0-epa1 tag as HEAD and does not clone any branch information.
This results in:

>>> import git
>>> repo = git.Repo('.')
>>> repo.head.object.hexsha[:14]
'bcac2eb1f9b49c'
>>> git_branch = repo.active_branch.name
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/git/repo/base.py", line 881, in active_branch
    return self.head.reference
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/git/refs/symbolic.py", line 311, in _get_reference
    raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
TypeError: HEAD is a detached symbolic reference as it points to 'bcac2eb1f9b49cc15ebda65838e5465543dbb9c6'

during the build. The exception handler resets the branch and commit name to an empty string: https://github.com/vyos/vyos-build/blob/a3e60a00b400a1bad8609d5ce1abb0bb7abed7bc/scripts/build-vyos-image#L281-L296

This now adds a proper error message during build so it fails early:

(07:46) vyos_bld 08278c5a1172:/vyos/vyos-build # isobuild -test
Building custom VyOS version: 1.5-test-202402250746
I: Checking if packages required for VyOS image build are installed
build/config
Could not retrieve information from git: HEAD is a detached symbolic reference as it points to '39612f541e55bea19868f50f16d7a6c6e0034ed2'

Details

Difficulty level
Easy (less than an hour)
Version
1.4.0-epa1
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Stricter validation
Issue type
Bug (incorrect behavior)

Event Timeline

c-po changed the task status from Open to In progress.Feb 25 2024, 7:47 AM
c-po claimed this task.
c-po triaged this task as Normal priority.
c-po created this task.
c-po updated the task description. (Show Details)
c-po updated the task description. (Show Details)
c-po moved this task from In Progress to Finished on the VyOS 1.4 Sagitta (1.4.0-epa1) board.