3084 Commits

Author SHA1 Message Date
Benjamin Drung
29914382cf ubuntu-build: introduce parse_args helper function
Move the argument parsing code into a separate `parse_args` function to
make the `main` function a little bit smaller.

The `IndexError` on accessing `args.packages` cannot happen.
2025-12-03 15:21:27 +01:00
Benjamin Drung
addeb4f7fb sponsor-patch: stop checking for bzr being present 2025-12-03 15:10:17 +01:00
Benjamin Drung
ee87f312bf run mypy during package build 2025-12-03 14:54:54 +01:00
Benjamin Drung
32530e356d run-linters: avoid searching scripts in build/
During package build the Python code is copied to the `build` directory.
Ignore this directory when searching for Python scripts.
2025-12-03 14:51:51 +01:00
Benjamin Drung
38ef3c506e Run wrap-and-sort -ast 2025-12-03 14:40:47 +01:00
Benjamin Drung
5fc7e15f96 Fix type annotation for resource_type
mypy complains:

```
ubuntutools/lp/lpapicache.py:143: error: Incompatible types in assignment (expression has type "None", variable has type "str")  [assignment]
ubuntutools/lp/lpapicache.py:1328: error: Incompatible types in assignment (expression has type "tuple[str, str]", base class "BaseWrapper" defined the type as "str")  [assignment]
```
2025-12-03 14:37:33 +01:00
Benjamin Drung
f0326592bd add type annotation for mypy
mypy comlains:

```
ubuntutools/config.py:53: error: Need type annotation for "config" (hint: "config: dict[<type>, <type>] = ...")  [var-annotated]
ubuntutools/lp/lpapicache.py:1504: error: Need type annotation for "_source_sets" (hint: "_source_sets: dict[<type>, <type>] = ...")  [var-annotated]
```
2025-12-03 14:36:49 +01:00
Benjamin Drung
aa439fec02 add missing return type annotation 2025-12-03 14:35:04 +01:00
Benjamin Drung
4bcfa0dd5a .pylintrc: ignore too-many-positional-arguments for now 2025-12-03 14:17:06 +01:00
Benjamin Drung
63b3d54264 Drop obsolete Rules-Requires-Root: no 2025-12-03 14:15:06 +01:00
Benjamin Drung
654af1a613 Drop Lintian overrides related to .pyc files
.pyc files should not be included in the source tarball.
2025-12-03 14:14:20 +01:00
Benjamin Drung
524f590af2 Run linters that can detect real errors on package build 2025-12-03 14:11:36 +01:00
Benjamin Drung
4a2f194860 run-linters: add --errors-only mode
Add `--errors-only` that runs only linters that can detect real errors
and all other ignoring the result.
2025-12-03 14:10:11 +01:00
Benjamin Drung
7b9aee4c0c run-linters: introduce helper functions 2025-12-03 14:07:56 +01:00
Benjamin Drung
45d317cc87 mark non-returning functions with typing.NoReturn
To help pylint, mark non-returning functions with `typing.NoReturn`.
2025-12-03 14:01:18 +01:00
Benjamin Drung
2e041ac1ff syncpackage: replace global by LRU cache
pylint complains:

```
syncpackage:459:4: W0603: Using the global statement (global-statement)
```

Replace the `global` statement by `functools.lru_cache`.
2025-12-03 13:59:06 +01:00
Benjamin Drung
c8fe724560 Fix pylint in ubuntutools/test/test_requestsync.py
pylint complains:

```
ubuntutools/test/test_requestsync.py:31:12: C0415: Import outside toplevel (keyring) (import-outside-toplevel)
ubuntutools/test/test_requestsync.py:33:12: W0707: Consider explicitly re-raising using 'except ModuleNotFoundError as exc' and 'raise ModuleNotFoundError('package python3-keyring is not installed') from exc' (raise-missing-from)
ubuntutools/test/test_requestsync.py:31:12: W0611: Unused import keyring (unused-import)
```
2025-12-03 13:51:50 +01:00
Benjamin Drung
768a517370 ubuntutools/archive.py: use 'yield from'
pylint complains:

```
ubuntutools/archive.py:343:8: R1737: Use 'yield from' directly instead of yielding each element one by one (use-yield-from)
ubuntutools/archive.py:346:8: R1737: Use 'yield from' directly instead of yielding each element one by one (use-yield-from)
ubuntutools/archive.py:638:8: R1737: Use 'yield from' directly instead of yielding each element one by one (use-yield-from)
```
2025-12-03 13:47:54 +01:00
Benjamin Drung
3d2ee5a1b7 ubuntutools/archive.py: do not raise general exception
pylint complains:

```
ubuntutools/archive.py:935:8: W0719: Raising too general exception: Exception (broad-exception-raised)
```
2025-12-03 13:45:46 +01:00
Benjamin Drung
1c81f0872d Use lazy % formatting in logging functions
pylint complains:

```
W1201: Use lazy % formatting in logging functions
```
2025-12-03 13:36:48 +01:00
Benjamin Drung
ef5e3d8066 requestsync: silence possibly-used-before-assignment
pylint complains:

```
requestsync:156:34: E0606: Possibly using variable 'bug_mail_domain' before assignment (possibly-used-before-assignment)
requestsync:217:27: E0606: Possibly using variable 'Distribution' before assignment (possibly-used-before-assignment)
requestsync:380:8: E0606: Possibly using variable 'post_bug' before assignment (possibly-used-before-assignment)
```

These errors are false positives. So silence them. The perfect solution
would be to restructure the code.
2025-12-03 13:32:33 +01:00
Benjamin Drung
816323ea5c sponsor_patch: make pylint happy
pylint complains:

```
ubuntutools/sponsor_patch/sponsor_patch.py:243:45: E0606: Possibly using variable 'task' before assignment (possibly-used-before-assignment)
```

Drop the `len(ubuntu_tasks) > 1` check and rely on being the else case.
2025-12-03 13:21:19 +01:00
Benjamin Drung
41e7d2d714 ubuntutools/pullpkg.py: initialize vcscmd
Fixes: 2f396fe54956
2025-12-03 13:11:47 +01:00
Sebastien Bacher
7e82344d57 ubuntu-build: fix non batch mode errors
The current version is not working

```
$ ubuntu-build librsync resolute retry

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 354, in __getattr__
    return self.lp_get_parameter(attr)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 249, in lp_get_parameter
    raise KeyError("No such parameter: %s" % param_name)
KeyError: 'No such parameter: getComponent'
```

The way launchpadlib is used was changed in 010af53 but non batch mode
was not correctly updated.

Also tweak the way the release is computed for distroseries to be able
to retry a package in e.g "resolute-proposed".
2025-12-03 13:07:25 +01:00
Benjamin Drung
cf88f4b92f syncpackage: do not use bare except for urlopen()
flake8 complains:

```
./syncpackage:465:9: E722 do not use bare 'except'
```

The function `urllib.request.urlopen` might throw
`urllib.error.URLError`, `urllib.error.HTTPError`, `socket.gaierror`,
`ssl.SSLError` which are all subclasses of `OSError`.
2025-12-03 12:24:47 +01:00
Benjamin Drung
c6a4c10da2 Format code with black and isort
```
isort .
black -C . $(grep -l -r '^#! */usr/bin/python3$' .)
```
2025-12-03 12:01:23 +01:00
Gianfranco Costamagna
dff0b269d2 ubuntu-build: consider amd64v3 as valid architecture 2025-10-19 09:29:46 +02:00
Colin Watson
3f880bea90 releasing package ubuntu-dev-tools version 0.207 debian/0.207 0.207 2025-09-15 15:59:36 +01:00
Colin Watson
8bb85c6a94 Optimize Launchpad collection handling
Various methods in `ubuntutools.lp.lpapicache` iterated over collections
in a pessimal way: they fetched the collection and then fetched each
individual entry in it, when the same information was already available
in the collection response.  Use more idiomatic launchpadlib code for
this instead, which is also much faster.
2025-09-15 11:29:14 +01:00
Dan Streetman
7dd913fe16 Add a new changelog entry 2025-05-06 13:29:29 -04:00
Dan Streetman
bcf3e153f7 Fix pulling from upload queue
Commit 4a4c4e0a27cfd159ac0bbc135d4eff06be8bde1c completely broke
pull-lp-source --upload-queue, which now fails with:

Traceback (most recent call last):
  File "/usr/bin/pull-lp-source", line 14, in <module>
    PullPkg.main(distro="ubuntu", pull="source")
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/ubuntutools/pullpkg.py", line 111, in main
    cls(*args, **kwargs).pull()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/ubuntutools/pullpkg.py", line 438, in pull
    self.pull_upload_queue(  # pylint: disable=missing-kwoa
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        pull, arch=options["arch"], download_only=options["download_only"], **params
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )

Fixes LP: #2110061
2025-05-06 13:21:52 -04:00
Simon Quigley
466e2784de Upload to Unstable 0.206 2025-03-04 13:43:32 -06:00
Simon Quigley
ba3f0511f9 syncpackage: Catch exceptions cleanly, simply skipping to the next package (erring on the side of caution) if there is an error doing the download (LP: #1943286). 2025-03-04 13:42:50 -06:00
Simon Quigley
2e550ceff2 syncpackage: Cache the sync blocklist in-memory, so it's not fetched multiple times when syncing more than one package. 2025-03-04 13:39:07 -06:00
Simon Quigley
6c8a5d74bd syncpackage: s/syncblacklist/syncblocklist/g 2025-03-04 13:29:02 -06:00
Simon Quigley
3d11516599 mk-sbuild: default to using UTC for schroots (LP: #2097159). 2025-03-04 13:22:40 -06:00
Simon Quigley
5a20308ab1 Read ~/.devscripts in a more robust way, to ideally pick up multi-line variables (Closes: #725418). 2025-03-04 13:17:30 -06:00
Simon Quigley
b551877651 Add a changelog entry 2025-03-04 13:10:04 -06:00
ferbraher
4a4c4e0a27 Parsing arch parameter to getBinaryPackage() 2025-03-04 13:08:59 -06:00
Simon Quigley
865c1c97bc Add a changelog entry 2025-03-04 13:07:42 -06:00
Shengjing Zhu
d09718e976 import-bug-from-debian: package option is overridden and not used 2025-03-04 13:07:11 -06:00
Simon Quigley
bff7baecc9 Add a changelog entry 2025-03-04 13:06:38 -06:00
Dan Bungert
45fbbb5bd1 mk-sbuild: enable pkgmaintainermangler
mk-sbuild installs pkgbinarymangler into the schroot.  Of of the
provided tools in pkgbinarymangler is pkgmaintainermangler.
pkgmaintainermangler is disabled by default, and enabled with
configuration.

A difference between launchpad builds of a synced package and an sbuild
is that the maintainer information will be different.

Enable pkgmaintainermangler to close this difference.
2025-03-04 13:05:57 -06:00
Simon Quigley
ca217c035e Add a new changelog entry 2025-03-04 13:04:49 -06:00
Simon Quigley
b5e117788b Upload to Unstable 0.205 2025-03-01 11:30:18 -06:00
Simon Quigley
ddba2d1e98 Update Standards-Version to 4.7.2, no changes needed. 2025-03-01 11:29:53 -06:00
Simon Quigley
02d65a5804 [syncpackage] Do not use exit(1) on an error or exception unless it applies to all packages, instead return None so we can continue to the next package. 2025-03-01 11:26:59 -06:00
Simon Quigley
bda85fa6a8 [syncpackage] Add support for -y or --yes, noted that it should be used with care. 2025-03-01 11:22:52 -06:00
Simon Quigley
86a83bf74d [syncpackage] Within fetch_source_pkg, do not exit(1) on an error or exception, simply return None so we can continue to the next package. 2025-03-01 11:17:02 -06:00
Simon Quigley
162e758671 [syncpackage] When syncing multiple packages, if one of the packages is in the sync blocklist, do not exit, simply continue. 2025-03-01 11:12:49 -06:00