aboutsummaryrefslogtreecommitdiff
path: root/qlop.c
Commit message (Collapse)AuthorAgeFilesLines
* qlop: Do not leak avgs array in predict modeBoris Staletic2024-03-291-0/+1
| | | | | | | | | | Previously, `values_set(merge_averages, avgs)` would allocate `avgs`, then it would be used in `array_for_each(atoms, i, atom)`, but a call to `xarrayfree_int(avgs)` was missing after the loop. Hopefully, this, along with #26, will solve the issues from #19. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: Properly handle atom_compar_cb when called from qsortBoris Staletic2024-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | `qsort` passes pointers to elements ("iterators" in C++ lingo) to the callback, not elements directly. Hence `l` and `r` in `atom_compar_cb` actually receives `depend_atom**`, but only when called from `qsort`. The other two call sites (`tree_pkg_compar` and `pkg_sort_cb`) actually apssed `depend_atom*`. This leads to type casting confusion and undefined behaviour for any invocation of `qlop -p`. First discovered by SEGFAULT-ing with the following invocation: qlop -p `cat /var/lib/portage/world` Valgrind and ASAN made triggering the SEGFAULT easier - any invocation with two or more atoms triggered a NULL dereference. This commit addresses the above problem: 1. Expect that `atom_compar_cb` is actually called with two `depend_atom**`. 2. Make `tree_pkg_compar` and `pkg_sort_cb` comply with the above change, by passing `&al` and `&ar`, instead of `al` and `ar`. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* set: ensure NULL is empty behaviour is retained throughoutFabian Groffen2023-02-071-4/+8
| | | | | | | | Not all set functions respected NULL is empty behaviour, changed add_set_value signature to return a set instead so it can conform. Bug: https://bugs.gentoo.org/893424 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix date parsing of epochs on muslFabian Groffen2022-02-231-6/+6
| | | | | | | | %s isn't a valid modifier in POSIX for strptime, so parse the number manually and produce a time out of that. Bug: https://bugs.gentoo.org/833942 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix Coverity condition always true CID 248869Fabian Groffen2022-02-121-2/+2
| | | | | | | | | | | atom->pfx_op cannot be 2 values at the same time so, pfx_op != X || pfx_op != Y has to be always true fix it to turn into and condition, which makes more sense in the code flow Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: Fixed --running --verbose returning unknown ETAJaak Ristioja2022-02-121-2/+6
| | | | | | | | | | | It seems that this was broken during the introduction of --predict in commit 13402fbd8c51f7feedcc85f2f0815768ec45ee7a which caused keys of the merge_averages and unmerge_averages sets to include version information, whereas --running expects these not to include version information. Bug: https://bugs.gentoo.org/807975 Signed-off-by: Jaak Ristioja <jaak@ristioja.ee> Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix default mode of operation (-l)Fabian Groffen2021-12-311-1/+1
| | | | | | | start_time was changed to default to -1 at some point, which broke qlop's default to list the last merge. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix garbage when using -EvFabian Groffen2021-12-251-13/+17
| | | | | | Regression since v0.92. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* libq/atom: introduce atom_compare_flgFabian Groffen2021-08-161-10/+9
| | | | | | | | | | | | | atom_compare_flg allows to give match behaviour flags, such that often used exceptions can now be handled without having to modify the input atoms. atom_compare is now a macro calling atom_compare_flg with flags=ATOM_COMP_DEFAULT. Updated all callers that can use this feature. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: add predict (-p) modeFabian Groffen2021-05-151-17/+210
| | | | | | | Predict should be a better estimator than average, and become the new source for estimating remaining times (with -r). Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: support -d 0 (or @0)Fabian Groffen2021-01-301-8/+17
| | | | | | | | Allow setting the zero date, to basically have a quick way to list everything, useful with -E, e.g. -Evd 0 to show the entire emerge history. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: adapt terminating/exiting logic somewhatv0.90Fabian Groffen2020-10-041-1/+1
| | | | | | | | It seems that exiting doesn't always come immediately (= the same second) after terminating, so allow a small window (4s) for these to come in sequence to treat them as a single termination. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: slightly increase the average when computing ETAFabian Groffen2020-10-041-0/+3
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: drop accidential debug print from probe_procFabian Groffen2020-10-041-1/+0
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix fix for #731122, also make it work without packages specifiedFabian Groffen2020-10-041-6/+7
| | | | | | Bug: https://bugs.gentoo.org/745798 Bug: https://bugs.gentoo.org/731122 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: treat either terminating or exiting or both as a termination of PortageFabian Groffen2020-10-041-22/+27
| | | | | | | It seems Portage is very inconsistent sometimes terminating, sometimes exiting, most of the time exiting and terminating. Deal with it. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: return sandbox piggybacking method of finding running mergesFabian Groffen2020-10-041-0/+29
| | | | | | | | Because sandbox doesn't seem as dead as it was pronounced a while ago, bring back support in qlop, since it is the easiest way to detect running merges without any special privileges necessary. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: deal with optionally compressed buildlogs in probe_procFabian Groffen2020-10-041-0/+14
| | | | | Bug: https://bugs.gentoo.org/745798 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: ensure running merges are calculated of off package names #731122Fabian Groffen2020-10-041-0/+6
| | | | | Bug: https://bugs.gentoo.org/731122 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: work around Coverity complaintsv0.89Fabian Groffen2020-08-171-10/+9
| | | | | | | Check/search once for colons, it is a bit brittle to assume a colon was found, even though in this case it should have always succeeded. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: recognise logfile naming when PORTAGE_LOGDIR is set, bug #711896Fabian Groffen2020-08-171-10/+30
| | | | | Bug: https://bugs.gentoo.org/711896 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix crash when encountering a long option with -E -vFabian Groffen2020-07-081-4/+11
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix inversed logicFabian Groffen2020-05-211-1/+1
| | | | | | | introduced in 20844dc943700cca72bbb6896f42adcd30de41e3, the intention was to suppress the warning, not raise it. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: add -v mode to -E that displays emerge invocationv0.87Fabian Groffen2020-05-021-5/+79
| | | | | | | | | | | | Really complete the --emerge option with --verbose to get: % qlop -Ev emerge -uaD @world U sys-kernel/linux-firmware-20200421 [20200316] N www-servers/nginx-1.18.0 D www-servers/nginx-1.17.10 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: show unmerged packages also in pseudo emerge format with -EFabian Groffen2020-05-021-0/+16
| | | | | | | | | | | | | Packages unmerged (e.g. emerge -c) or unmerged in a blocker situation showed up in -E mode in the normal way, e.g.: 2020-04-30T20:03:51 <<< www-servers/nginx-1.17.10 Make it show like in pseudo emerge output: D www-servers/nginx-1.17.10 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: silently drop -l when -d is used with -EFabian Groffen2020-05-021-2/+3
| | | | | | While -E defaults to -l (last merge), silently drop it when -d is used. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix Coverity 125912 Out-of-bounds accessFabian Groffen2020-01-221-1/+1
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix Coverity 206547 Out-of-bounds writeFabian Groffen2020-01-191-1/+1
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* *: use new PF in places were it was simulatedFabian Groffen2020-01-011-9/+5
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: report running over estimated timeFabian Groffen2019-12-271-13/+23
| | | | | | | basically try saying something useful, instead of unknown Bug: https://bugs.gentoo.org/701386 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: some changes to -r (running) modeFabian Groffen2019-12-271-7/+43
| | | | | | | | | | | - warn when qlop needs to defer to log heuristics (#701968) - print running packages most recent first - suppress identical running packages (#701392) - ignore batches in emerge.log that appear to be backwards in time Bug: https://bugs.gentoo.org/701968 Bug: https://bugs.gentoo.org/701392 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix signedness warningFabian Groffen2019-12-141-1/+1
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* misc fixes for valgrindFabian Groffen2019-11-301-1/+38
| | | | | | | mainly memory and socket leaks, sometimes using invalid data, this is related to bug #701402 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: avoid reporting bogus dates in fmt_elapsedtimeFabian Groffen2019-11-131-1/+1
| | | | | | | | when the calculated seconds are negative, we probably had a corrupt log, so just garbage in/garbage out without trying to interpret it or something Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: check return from localtime in fmt_dateFabian Groffen2019-11-131-2/+3
| | | | | | | | bogus input can result in NULL, crashing strftime Thanks Agostino Sarubbo Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix crash due to unwanted side-effect in conditionalFabian Groffen2019-11-131-2/+2
| | | | | | Thanks Agostino Sarubbo for reporting Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: allow forcing non-proc running mode using -rr for testingFabian Groffen2019-10-271-11/+14
| | | | | | | | Adapt test to use -rr to force falling back to scanning emerge.log, and give -d to the data range in which things happen, such that the 10-day cutoff can be calculated based on that for deterministic output. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: take two at implementing currently running mergesFabian Groffen2019-10-271-6/+169
| | | | | | | | | Probe /proc filesystem for running merges, and use the atoms found there to select the packages to list. In addition, prune any operations that started > 10 days ago so there will be some sort of convergence. Bug: https://bugs.gentoo.org/698196 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: don't "forget" merges when a parallel merge finishesFabian Groffen2019-10-201-2/+1
| | | | | | | | Stop seeing finishing emerge processes double, thereby wrongly calculating the current parallel merges. Bug: https://bugs.gentoo.org/697068 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: sort average output before displayFabian Groffen2019-09-261-8/+21
| | | | | | | sort the package lists using atom order for some consistency after set usage Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: make -v consider revisions as significant too (for -a)Fabian Groffen2019-09-261-8/+18
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix last merge timeframe detectionFabian Groffen2019-09-211-3/+4
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: improve performance for -a (and thus -r), bug #694972Fabian Groffen2019-09-211-95/+96
| | | | | | | Bring down runtime for -a or -f (without atoms) from ~4s to ~0.6s. Bug: https://bugs.gentoo.org/694972 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: add mode to print last run in a similar way like emerge(1) doesFabian Groffen2019-09-101-1/+48
| | | | | | | | | | | | | | | | | | | | | | For example, the output could be like this, showing upgrade information: % ./qlop -E -t U app-shells/bash-5.0_p11 [5.0_p9-r0]: 2′38″ U app-admin/eselect-1.4.15 [1.4.14-r0]: 19s U sys-libs/talloc-2.3.0 [2.2.0-r0]: 1′56″ U app-portage/prefix-toolkit-5 [4-r0]: 10s U dev-python/cryptography-2.7 [2.6.1-r0]: 1′59″ U net-dns/bind-tools-9.14.5 [9.14.4-r0]: 4′17″ R dev-python/sphinxcontrib-applehelp-1.0.1: 28s R dev-python/sphinxcontrib-devhelp-1.0.1: 27s R dev-python/sphinxcontrib-jsmath-1.0.1: 25s R dev-python/sphinxcontrib-htmlhelp-1.0.2: 28s R dev-python/sphinxcontrib-serializinghtml-1.1.3: 28s R dev-python/sphinxcontrib-qthelp-1.0.2: 28s U dev-python/sphinx-2.0.1 [1.7.5-r1]: 1′13″ U net-mail/notmuch-0.29.1-r1 [0.28.4-r0]: 1′00″ Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: ignore empty runs for -l (lastrun)Fabian Groffen2019-09-101-6/+13
| | | | | | | doing something like emerge -pv blah will generate a run where nothing is merged or unmerged, so ignore it. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: add ROOT support, bug #692224Fabian Groffen2019-08-171-1/+8
| | | | | | | | Respect ROOT when set, to ease scripting of qlop interaction with chroots. Bug: https://bugs.gentoo.org/692224 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: enhance running time indicatorFabian Groffen2019-07-181-20/+27
| | | | | | | | | | Fix elapsed time mode (-t) when using -r displaying the elapsed time also as the ETA. When using -v, display what ETA is being used (average or longest run). Also, better document which flags can be combined with -r. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: add -F argumentFabian Groffen2019-07-141-17/+26
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* libq/atom: make atom_format smarter to unbreak PuppetFabian Groffen2019-06-131-12/+12
| | | | | | | | | The default portage provider in Puppet uses qatom in a rather clumpsy way. The newer formatting broke it because they don't use explicit formatting. Make atom_format somewhat smarter to unbreak Puppet's usage. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* qlop: fix whitespaceFabian Groffen2019-06-061-1/+1
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>