maint(linux): create temporary worktree for packaging#14598
maint(linux): create temporary worktree for packaging#14598ermshiperete merged 6 commits intomasterfrom
Conversation
This change creates a temporary worktree for creating Debian packages. This will allow us to work from a clean state of the source repo. Also exclude any generated patch directories (`.pc`). Build-bot: skip Test-bot: skip
User Test ResultsTest specification and instructions User tests are not required |
This change creates a temporary worktree for creating Debian packages. This will allow us to work from a clean state of the source repo. Also exclude any generated patch directories (`.pc`). Cherry-pick-of: #14598 Build-bot: skip Test-bot: skip
Copy the generated files before removing the worktree so that they are still available for reference.
linux/scripts/upload-to-debian.sh
Outdated
| cp -r linux/debianpackage "${KEYMAN_ROOT}/linux" | ||
| fi | ||
|
|
||
| cd "${PREV_DIR:-}" || true |
There was a problem hiding this comment.
This is a little worrying, why ignore failure? If it fails and we have a PWD inside the WORKTREE_DIR, will this cause a flow-on failure?
linux/scripts/upload-to-debian.sh
Outdated
| git worktree remove -f "${WORKTREE_DIR}" || true | ||
| git branch -f -D "${WORKTREE_BRANCH}" || true |
There was a problem hiding this comment.
What are the circumstances of failure here?
linux/scripts/upload-to-debian.sh
Outdated
| if [[ -d "linux/debianpackage" ]]; then | ||
| cp -r linux/debianpackage "${KEYMAN_ROOT}/linux" | ||
| fi |
There was a problem hiding this comment.
It seems like this could start in an arbitrary folder if a trap is thrown
ermshiperete
left a comment
There was a problem hiding this comment.
Replied to comments
linux/scripts/upload-to-debian.sh
Outdated
| if [[ -d "linux/debianpackage" ]]; then | ||
| cp -r linux/debianpackage "${KEYMAN_ROOT}/linux" | ||
| fi |
linux/scripts/upload-to-debian.sh
Outdated
| cp -r linux/debianpackage "${KEYMAN_ROOT}/linux" | ||
| fi | ||
|
|
||
| cd "${PREV_DIR:-}" || true |
linux/scripts/upload-to-debian.sh
Outdated
| git worktree remove -f "${WORKTREE_DIR}" || true | ||
| git branch -f -D "${WORKTREE_BRANCH}" || true |
linux/scripts/upload-to-debian.sh
Outdated
| WORKTREE_BRANCH="maint/linux/tmp-packaging-${DEPLOY_BRANCH#origin/}" | ||
| PREV_DIR="$PWD" | ||
|
|
||
| WORKTREE_DIR="$(git worktree list | grep "${WORKTREE_BRANCH}" | cut -d' ' -f1)" |
linux/scripts/upload-to-debian.sh
Outdated
| if [[ -n "${WORKTREE_DIR}" ]] && [[ -d "${WORKTREE_DIR}" ]]; then | ||
| builder_heading "Reusing existing worktree at ${WORKTREE_DIR}" | ||
| git checkout -B "${WORKTREE_BRANCH}" "${DEPLOY_BRANCH#origin/}" |
There was a problem hiding this comment.
When would the worktree already exist?
Are we in the right folder to do this checkout? Shouldn't this be done from the worktree folder?
There was a problem hiding this comment.
I had it happen that for whatever reason the worktree directory didn't get deleted. Probably not happening if the script works right, but...
There was a problem hiding this comment.
I guess in that situation I would be more comfortable with deleting the folder and cleanly recreating the worktree?
linux/scripts/upload-to-debian.sh
Outdated
| WORKTREE_DIR="$(mktemp -d)" | ||
| builder_heading "Creating temporary worktree at ${WORKTREE_DIR}" | ||
| if git branch | grep -q "${WORKTREE_BRANCH}"; then | ||
| git branch -f -D "${WORKTREE_BRANCH}" |
There was a problem hiding this comment.
| git branch -f -D "${WORKTREE_BRANCH}" | |
| git branch -D "${WORKTREE_BRANCH}" |
-D is equivalent to --delete --force
linux/scripts/upload-to-debian.sh
Outdated
| if git branch | grep -q "${WORKTREE_BRANCH}"; then | ||
| git branch -f -D "${WORKTREE_BRANCH}" | ||
| fi | ||
| git worktree add -f -b "${WORKTREE_BRANCH}" "${WORKTREE_DIR}" "${DEPLOY_BRANCH#origin/}" |
There was a problem hiding this comment.
I would hope we wouldn't need -f here?
linux/scripts/upload-to-debian.sh
Outdated
| # target branch (stable/beta). Checkout stable/beta branch so that | ||
| # scripts/debian.sh picks up correct version | ||
|
|
||
| WORKTREE_BRANCH="maint/linux/tmp-packaging-${DEPLOY_BRANCH#origin/}" |
There was a problem hiding this comment.
${DEPLOY_BRANCH#origin/} seems to be used repeatedly. May be worth putting into a variable.
Co-authored-by: Marc Durdin <marc@durdin.net>
|
Changes in this pull request will be available for download in Keyman version 19.0.110-alpha |
This change creates a temporary worktree for creating Debian packages. This will allow us to work from a clean state of the source repo. Also exclude any generated patch directories (
.pc).Build-bot: skip
Test-bot: skip