Skip to content

Conversation

@nblock
Copy link
Collaborator

@nblock nblock commented May 19, 2025

Please see commit messages for details.

NOTE: If this is merged, it needs to be part of 0.27.0 as the migration in the package checks for that version. The script output of various scenarios is attached. The only difference is that maintainer scripts are executed with set -ex instead of set -e to allow introspection.

See: #2278
See: #2133
Fixes: #2311

  • have read the CONTRIBUTING.md file
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

ubuntu2204-scenario-install-purge-install.txt
lintian.txt
debian12-scenario-reinstall-same.txt
debian12-scenario-oldest-to-dev.txt
debian12-scenario-new-install.txt
debian12-scenario-latest-to-dev.txt
debian12-scenario-install-remove-install.txt
debian12-scenario-install-purge-install.txt
debian11-scenario-reinstall-same.txt
debian11-scenario-oldest-to-dev.txt
debian11-scenario-new-install.txt
debian11-scenario-latest-to-dev.txt
debian11-scenario-install-remove-install.txt
ubuntu2404-scenario-reinstall-same.txt
ubuntu2404-scenario-oldest-to-dev.txt
ubuntu2404-scenario-new-install.txt
ubuntu2404-scenario-latest-to-dev.txt
ubuntu2404-scenario-install-remove-install.txt
ubuntu2404-scenario-install-purge-install.txt
ubuntu2204-scenario-reinstall-same.txt
ubuntu2204-scenario-oldest-to-dev.txt
ubuntu2204-scenario-new-install.txt
ubuntu2204-scenario-latest-to-dev.txt
ubuntu2204-scenario-install-remove-install.txt
debian11-scenario-install-purge-install.txt
piparts.txt

@ghost
Copy link

ghost commented May 19, 2025

Pull Request Revisions

RevisionDescription
r3
Refactored Debian packaging and configurationsRestructured Debian/Ubuntu packaging, updated systemd service, and modified installation scripts with improved system integration
r2
Debian packaging refactored, Ubuntu 20.04 droppedUpdates to Debian/Ubuntu packaging scripts, including modifications to user home directory handling and systemd configuration
r1
Refactored packaging and systemd configurationUpdated package management scripts, moved systemd service file, and improved Debian package installation and removal scripts

✅ AI review completed for r3
Help React with emojis to give feedback on AI-generated reviews:
  • 👍 means the feedback was helpful and actionable
  • 👎 means the feedback was incorrect or unhelpful
💬 Replying to feedback with a comment helps us improve the system. Your input also contributes to shaping future interactions with the AI reviewer.

We'd love to hear from you—reach out anytime at [email protected].

@nblock nblock added this to the v0.27.0 milestone May 19, 2025
@nblock nblock marked this pull request as ready for review May 20, 2025 06:46
Copy link
Collaborator

@kradalby kradalby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, otherwise looks great, thanks for such thorough work!

nblock added 3 commits May 21, 2025 14:57
Move files for packaging outside the docs directory into its own
packaging directory. Replace the existing postinstall and postremove
scripts with Debian maintainerscripts to behave more like a typical
Debian package:

* Start and enable the headscale systemd service by default
* Does not print informational messages
* No longer stop and disable the service on updates

This package also performs migrations for all changes done in previous
package versions on upgrade:

* Set login shell to /usr/sbin/nologin
* Set home directory to /var/lib/headscale
* Migrate to system UID/GID

The package is lintian-clean with a few exceptions that are documented
as excludes and it passes puipars (both tested on Debian 12).

The following scenarious were tested on Ubuntu 22.04, Ubuntu 24.04,
Debian 11, Debian 12:

* Install
* Install same version again
* Install -> Remove -> Install
* Install -> Purge -> Install
* Purge
* Update from 0.22.0
* Update from 0.26.0

See: juanfont#2278
See: juanfont#2133
Fixes: juanfont#2311
The systemd target "syslog.target" and not required because syslog is
socket activated.

The directory /var/run is usually a symlink to /run and its created by
systemd via the RuntimeDirectory=headscale option. System creates and
handles permissions, no need to manually mark it as a read-write path.
Its old and our service file logs warning about unsupported options.
@nblock nblock enabled auto-merge (rebase) May 21, 2025 12:59
Comment on lines +33 to +41
if dpkg --compare-versions "$2" lt-nl "0.27"; then
# < 0.24.0-beta.1 used /home/headscale as home and /bin/sh as shell.
# The directory /home/headscale was not created by the package or
# useradd but the service always used /var/lib/headscale which was
# always shipped by the package as empty directory. Previous versions
# of the package did not update the user account properties.
usermod --home "$HEADSCALE_HOME_DIR" --shell "$HEADSCALE_SHELL" \
"$HEADSCALE_USER" >/dev/null
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In packaging/deb/postinst, the version check on line 33 compares against '0.27'. Is this the correct version for checking homes and shells? The comment on line 34 mentions 0.24.0-beta.1. Are you sure the version threshold is accurate?

;;

purge)
userdel headscale
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In packaging/deb/postrm, the userdel command on line 28 doesn't have the same error handling pattern as other commands. Consider adding || true to handle the case where the user might have been manually removed.

@nblock nblock merged commit cd70457 into juanfont:main May 21, 2025
149 of 150 checks passed
@nblock nblock deleted the pkg branch October 27, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Headscale service is disabled after upgrading the deb package

2 participants