Skip to content

Commit 825265e

Browse files
Merge branch 'upstream' into master
2 parents c79eb86 + e8b23af commit 825265e

28 files changed

+559
-138
lines changed

.github/workflows/test.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: run tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
tests:
7+
runs-on: ubuntu-latest
8+
9+
# Use the base-devel image of Arch Linux for building pyalpm
10+
container: archlinux:base-devel
11+
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version:
16+
- "3.11"
17+
- "3.12"
18+
exclude: []
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Install Python deps
30+
run: python -m pip install -U pytest pytest-asyncio nvchecker requests lxml PyYAML pyalpm structlog python_prctl
31+
32+
- name: workaround pycurl wheel
33+
run: |
34+
sudo mkdir -p /etc/pki/tls/certs
35+
sudo ln -s /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt
36+
37+
- name: Run pytest
38+
run: pytest

.typos.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[default.extend-identifiers]
22
update_ons = "update_ons"
3+
O_WRONLY = "O_WRONLY"

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ Docs
2121
* [lilac.py API](https://lilac.readthedocs.io/en/latest/api.html)
2222
* [Setup and run your own](https://lilac.readthedocs.io/en/latest/)
2323

24+
Update
25+
----
26+
27+
### 2024-06-28
28+
29+
if database is in use, run the following SQL to update:
30+
31+
```sql
32+
33+
alter table lilac.pkglog add column maintainers jsonb;
34+
```
35+
36+
2437
License
2538
-------
2639

config.toml.sample

+3
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,7 @@ tmpfs = [
8484
"/build/.cache/bazel"
8585
]
8686

87+
# pacman.conf to use for repository databases
88+
pacman_conf = "/etc/pacman.conf"
89+
8790
# vim: se ft=toml:

docs/setup.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It's recommended to run lilac on full-fledged Arch Linux (or derived) system, no
1010

1111
An easy way to install lilac and its dependencies is to install the ``lilac-git`` package from the `[archlinuxcn] repository <https://wiki.archlinux.org/title/Unofficial_user_repositories#archlinuxcn>`_ or AUR.
1212

13-
As a workaround, instead of ``devtools``, ``devtools-archlinuxcn`` from ``[archlinuxcn]`` should be used until `FS#64265 <https://bugs.archlinux.org/task/64265>`_ and `FS#64698 <https://gitlab.archlinux.org/archlinux/devtools/-/merge_requests/90>`_ are resolved.
13+
As a workaround, instead of ``devtools``, ``devtools-archlinuxcn`` from ``[archlinuxcn]`` should be used until `this --keep-unit issue <https://gitlab.archlinux.org/archlinux/devtools/-/merge_requests/197>`_ is resolved.
1414

1515
.. code-block:: sh
1616
@@ -183,7 +183,7 @@ Setup the database tables (run as lilac):
183183
184184
Edit ``/etc/sudoers`` like::
185185

186-
Defaults env_keep += "PACKAGER MAKEFLAGS GNUPGHOME BUILDTOOL"
186+
Defaults env_keep += "PACKAGER MAKEFLAGS GNUPGHOME BUILDTOOL LOGDEST"
187187

188188
%pkg ALL= NOPASSWD: /usr/bin/build-cleaner, /usr/bin/extra-x86_64-build, /usr/bin/multilib-build
189189

lilac

+64-41
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ from typing import List, Any, DefaultDict, Tuple
1212
from collections.abc import Set
1313
from pathlib import Path
1414
import graphlib
15-
import json
1615
import datetime
1716
import threading
1817
from concurrent.futures import (
@@ -70,6 +69,7 @@ MYNAME = config['lilac']['name']
7069

7170
nvdata: dict[str, NvResults] = {}
7271
DEPMAP: dict[str, set[Dependency]] = {}
72+
BUILD_DEPMAP: dict[str, set[Dependency]] = {}
7373
build_reasons: DefaultDict[str, list[BuildReason]] = defaultdict(list)
7474

7575
logger = logging.getLogger(__name__)
@@ -163,7 +163,7 @@ def packages_with_depends(
163163
pkgbase = pkg,
164164
index = idx,
165165
status = 'pending',
166-
build_reasons = json.dumps(rs),
166+
build_reasons = rs,
167167
)
168168
s.add(p)
169169
db.build_updated(s)
@@ -263,12 +263,18 @@ def start_build(
263263
limit = max_concurrency - len(futures),
264264
)
265265
for pkg in pkgs:
266+
if pkg not in nvdata:
267+
# this can happen when cmdline packages are specified and
268+
# a package is pulled in by OnBuild
269+
logger.warning('%s not in nvdata, skipping', pkg)
270+
buildsorter.done(pkg)
271+
continue
266272
fu = executor.submit(
267273
build_it, pkg, repo, buildsorter, built, failed)
268274
futures[fu] = pkg
269275

270-
if not futures:
271-
# no task is running: we're done
276+
if not pkgs and not futures:
277+
# no more packages and no task is running: we're done
272278
break
273279

274280
done, pending = futures_wait(futures, return_when=FIRST_COMPLETED)
@@ -312,7 +318,7 @@ def try_pick_some(
312318

313319
if rs := build_reasons.get(pkg):
314320
if len(rs) == 1 and isinstance(rs[0], BuildReason.FailedByDeps):
315-
ds = DEPMAP[pkg]
321+
ds = BUILD_DEPMAP[pkg]
316322
if not all(d.resolve() for d in ds):
317323
buildsorter.done(pkg)
318324
if db.USE:
@@ -370,7 +376,7 @@ def build_it(
370376
update_info = nvdata[pkg],
371377
bindmounts = repo.bindmounts,
372378
tmpfs = repo.tmpfs,
373-
depends = DEPMAP.get(pkg, ()),
379+
depends = BUILD_DEPMAP.get(pkg, ()),
374380
repo = REPO,
375381
myname = MYNAME,
376382
destdir = DESTDIR,
@@ -454,6 +460,7 @@ def build_it(
454460
cputime = memory = None
455461
rs = [r.to_dict() for r in build_reasons[pkg]]
456462
with db.get_session() as s:
463+
maintainers = repo.lilacinfos[pkg].maintainers
457464
p = db.PkgLog(
458465
pkgbase = pkg,
459466
nv_version = newver,
@@ -463,7 +470,8 @@ def build_it(
463470
cputime = cputime,
464471
memory = memory,
465472
msg = msg,
466-
build_reasons = json.dumps(rs),
473+
build_reasons = rs,
474+
maintainers = maintainers,
467475
)
468476
s.add(p)
469477
db.mark_pkg_as(s, pkg, 'done')
@@ -489,12 +497,13 @@ def setup_thread():
489497
def main_may_raise(
490498
D: dict[str, Any], pkgs_from_args: List[str], logdir: Path,
491499
) -> None:
492-
global DEPMAP
500+
global DEPMAP, BUILD_DEPMAP
493501

494502
if get_git_branch() not in ['master', 'main']:
495503
raise Exception('repo not on master or main, aborting.')
496504

497-
pkgbuild.update_data(PACMAN_DB_DIR)
505+
pacman_conf = config['misc'].get('pacman_conf')
506+
pkgbuild.update_data(PACMAN_DB_DIR, pacman_conf)
498507

499508
if dburl := config['lilac'].get('dburl'):
500509
import sqlalchemy
@@ -510,34 +519,42 @@ def main_may_raise(
510519
failed = REPO.load_managed_lilac_and_report()
511520

512521
depman = DependencyManager(REPO.repodir)
513-
DEPMAP = get_dependency_map(depman, REPO.lilacinfos)
522+
DEPMAP, BUILD_DEPMAP = get_dependency_map(depman, REPO.lilacinfos)
523+
524+
failed_info = D.get('failed', {})
525+
526+
U = set(REPO.lilacinfos)
527+
last_commit = D.get('last_commit', EMPTY_COMMIT)
528+
changed = get_changed_packages(last_commit, 'HEAD') & U
529+
530+
failed_prev = set(failed_info.keys())
531+
# no update from upstream, but build instructions have changed; rebuild
532+
# failed ones
533+
need_rebuild_failed = failed_prev & changed
534+
# if pkgrel is updated, build a new release
535+
need_rebuild_pkgrel = {x for x in changed
536+
if pkgrel_changed(last_commit, 'HEAD', x)}
514537

515538
# packages we care about
516539
care_pkgs: set[str] = set()
517-
for pkg_to_build in pkgs_from_args:
518-
care_pkgs.update(dep.pkgname for dep in DEPMAP[pkg_to_build])
519-
care_pkgs.add(pkg_to_build)
540+
for p in pkgs_from_args:
541+
if ':' in p:
542+
pkg = p.split(':', 1)[0]
543+
else:
544+
pkg = p
545+
care_pkgs.update(dep.pkgname for dep in DEPMAP[pkg])
546+
care_pkgs.add(pkg)
547+
# make sure they have nvdata
548+
care_pkgs.update(need_rebuild_failed)
549+
care_pkgs.update(need_rebuild_pkgrel)
520550

521551
proxy = config['nvchecker'].get('proxy')
522552
_nvdata, unknown, rebuild = packages_need_update(
523553
REPO, proxy, care_pkgs,
524554
)
525555
nvdata.update(_nvdata) # update to the global object
526556

527-
failed_info = D.get('failed', {})
528-
529-
if not pkgs_from_args:
530-
U = set(REPO.lilacinfos)
531-
last_commit = D.get('last_commit', EMPTY_COMMIT)
532-
changed = get_changed_packages(last_commit, 'HEAD') & U
533-
534-
failed_prev = set(failed_info.keys())
535-
# no update from upstream, but build instructions have changed; rebuild
536-
# failed ones
537-
need_rebuild_failed = failed_prev & changed
538-
# if pkgrel is updated, build a new release
539-
need_rebuild_pkgrel = {x for x in changed
540-
if pkgrel_changed(last_commit, 'HEAD', x)} - unknown
557+
need_rebuild_pkgrel -= unknown
541558

542559
nv_changed = {}
543560
for p, vers in nvdata.items():
@@ -569,14 +586,19 @@ def main_may_raise(
569586

570587
if pkgs_from_args:
571588
for p in pkgs_from_args:
572-
build_reasons[p].append(BuildReason.Cmdline())
573-
else:
574-
for p in need_rebuild_pkgrel:
575-
build_reasons[p].append(BuildReason.UpdatedPkgrel())
589+
if ':' in p:
590+
p, runner = p.split(':', 1)
591+
else:
592+
runner = None
593+
build_reasons[p].append(BuildReason.Cmdline(runner))
576594

577-
for p in need_rebuild_failed:
578-
build_reasons[p].append(BuildReason.UpdatedFailed())
595+
for p in need_rebuild_pkgrel:
596+
build_reasons[p].append(BuildReason.UpdatedPkgrel())
579597

598+
for p in need_rebuild_failed:
599+
build_reasons[p].append(BuildReason.UpdatedFailed())
600+
601+
if not pkgs_from_args:
580602
for p, i in failed_info.items():
581603
# p might have been removed
582604
if p in REPO.lilacinfos and (deps := i['missing']):
@@ -587,15 +609,17 @@ def main_may_raise(
587609
for i in info.update_on_build:
588610
if_this_then_those[i.pkgbase].add(p)
589611
more_pkgs = set()
590-
count = 0
591612
for p in build_reasons:
592613
if pkgs := if_this_then_those.get(p):
593614
more_pkgs.update(pkgs)
594-
while len(more_pkgs) != count: # has new
595-
count = len(more_pkgs)
615+
while True:
616+
add_to_more_pkgs = set()
596617
for p in more_pkgs:
597618
if pkgs := if_this_then_those.get(p):
598-
more_pkgs.update(pkgs)
619+
add_to_more_pkgs.update(pkgs)
620+
if add_to_more_pkgs.issubset(more_pkgs):
621+
break
622+
more_pkgs.update(add_to_more_pkgs)
599623
for p in more_pkgs:
600624
update_on_build = REPO.lilacinfos[p].update_on_build
601625
build_reasons[p].append(BuildReason.OnBuild(update_on_build))
@@ -626,10 +650,9 @@ def main_may_raise(
626650
if x in failed_info:
627651
del failed_info[x]
628652
# cleanup removed package failed_info
629-
if not pkgs_from_args:
630-
for x in tuple(failed_info.keys()):
631-
if x not in REPO.lilacinfos:
632-
del failed_info[x]
653+
for x in tuple(failed_info.keys()):
654+
if x not in REPO.lilacinfos:
655+
del failed_info[x]
633656
D['failed'] = failed_info
634657

635658
if config['lilac']['rebuild_failed_pkgs']:

0 commit comments

Comments
 (0)