Skip to content

Conversation

@ottok
Copy link
Contributor

@ottok ottok commented Sep 10, 2025

What problem does this PR solve?

Have a debian/ subdirectory upstream with native Debian packaging, so .deb packages can be created directly from master branch or the purposes of testing that new changes upstream do not regress Debian packaging, and/or can be used to publish .deb packages directly by PingCAP.

The contents of this debian/ is similar, but not identical to the non-native official packaging (if) in Debian.

Related to: #2508

What is changed and how it works?

Given the proper build environment with extra PPA enabled, running dpkg-buildpackage -us -uc can produce .deb packages out of this.

Additional changes are needed for a full end-to-end build automation solution. For example the debian/changelog entry and version are now static.

Check List

Tests

  • Integration test
  • Manual test (add detailed scripts or steps below)

Code changes

Branch includes commits from

Side effects #2538 and #2601 which should be reviewed and merged separately, and this PR later rebased and merged as the last thing.

  • Increased code complexity
NONE
This native packaging is nearly identical to the non-native packaging
that will in the future enter Debian. The native packaging can be used
to do test builds or distribute .deb packages of TiUP directly by PingCAP.
As the golang-github-shirou-gopsutil-dev package v4.25.2 in Debian is
newer than the v3.21.11 in go.mod of TiUP, the Debian build failed on:

    src/github.com/pingcap/tiup/pkg/insight/process.go:165:24: cannot use proc.Status() (value of type []string) as string value in assignment
    src/github.com/pingcap/tiup/pkg/insight/process_linux.go:24:38: undefined: process.ClockTicks

Apply these changes on TiUP to make it compatible:

- The `proc.Status()` method now returns a slice of strings (`[]string`)
  instead of a single string. Update the assignment to take the first
  element of the slice, assuming it contains the primary status
  information. Add a check for an empty slice to prevent panics.

- The `process.ClockTicks` constant and the related logic for parsing
  `/proc/[pid]/stat` are no longer supported. Replace this with a call
  to `proc.CreateTime()`, which provides the process creation time in
  milliseconds since the Unix epoch. Convert this value to seconds for
  the `StartTime` field.

Additionally, remove unused import statements to avoid failures on:

    src/github.com/pingcap/tiup/pkg/insight/process_linux.go:8:2: "os" imported and not used
    src/github.com/pingcap/tiup/pkg/insight/process_linux.go:9:2: "strconv" imported and not used
    src/github.com/pingcap/tiup/pkg/insight/process_linux.go:10:2: "strings" imported and not used
As the  golang-github-xo-usql-dev package v0.19.19 in Debian is
newer than the v0.9.5 in go.mod of TiUP, the Debian build failed on:

    src/github.com/pingcap/tiup/components/client/main.go:98:33: not enough arguments in call to rline.New
    	have (bool, string, string)
    	want (bool, bool, bool, string, string)
    src/github.com/pingcap/tiup/components/client/main.go:102:70: not enough arguments in call to handler.New
    	have (rline.IO, *user.User, string, bool)
    	want (rline.IO, *user.User, string, billy.Filesystem, bool)

Apply these changes on TiUP to make it compatible:

- `rline.New` now requires two additional boolean arguments. These are
  set to `false` as safe defaults.

- `handler.New` now requires a `billy.Filesystem` argument. This is
  provided by importing `osfs` and creating a new `osfs.New` instance
  using the instance data directory.
Enable TiUP to operate correctly and robustly when installed via an
external package manager (e.g., Debian, RPM, Homebrew). Allow TiUP to
run without requiring network access to its online repository for
initial setup or updates, which is crucial for production systems and
environments with restricted connectivity.

Achieve this by introducing the boolean flag `IsPackagedBuild`, which is
intended to be hard-coded to `true` in binaries produced by package
maintainers.

When `IsPackagedBuild` is true:

- The initial environment setup skips connecting to the online
  repository, relying instead on local files.

- The automatic update check before running a component is skipped.

- A message is printed to stderr indicating that online interaction is
  skipped, informing the user of the different behavior.

- Functions related to *forced* self-updating TiUP return an error,
  explicitly disabling these operations in packaged builds. Users should
  still be able to install/update when explicitly running those
  commands.

- Use the system-wide location `/usr/share/tiup/root.json` for initial
  trust setup and assume this file came with the package. This aligns
  with typical system package practices.
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Sep 10, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign xhebox for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot requested review from breezewish and nexustar September 10, 2025 21:04
@ottok ottok marked this pull request as draft September 10, 2025 21:04
@ti-chi-bot ti-chi-bot bot added contribution do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

1 participant