Skip to content

Commit 28f33f9

Browse files
committed
Better detect last run script in mock chroot
Before when running one of the following targets it could be that there were multiple run files in `/var/lib/mock/$(MOCK_CHROOT)/root/var/tmp`. ``` edit-last-failing-script - Opens the last failing or running script from mock in your editor of choice for you to edit it and later re-run it in mock with: "make mockbuild-rerun-last-script-...". mockbuild-rerun-last-script - Re-runs the last failing or running script of your release/mock mockbuild. ``` The function to edit the last one that was run sometimes picked the wrong file. Now we sort the files in there aforementioned directory before editing or running it again.
1 parent 1acc1f3 commit 28f33f9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,26 @@ mockbuild-snapshot: srpm-snapshot get-srpm-snapshot
7272

7373
######### Edit-last-failing-script
7474

75+
.PHONY: get-last-run-script
76+
## Get the file that was last modified in /var/tmp/ within the chroot.
77+
get-last-run-script:
78+
$(eval last_run_script:=/var/tmp/$(shell ls -t1 /var/lib/mock/$(MOCK_CHROOT)/root/var/tmp | head -n1))
79+
$(info last_run_script=$(last_run_script))
80+
@echo > /dev/null
81+
7582
.PHONY: edit-last-failing-script
7683
## Opens the last failing or running script from mock in your editor
7784
## of choice for you to edit it and later re-run it in mock with:
78-
## "make mockbuild-rerun-last-script-...".
79-
edit-last-failing-script:
80-
$$EDITOR /var/lib/mock/$(MOCK_CHROOT)/root/var/tmp/rpm-tmp.*
85+
## "make mockbuild-rerun-last-script".
86+
edit-last-failing-script: get-last-run-script
87+
$$EDITOR /var/lib/mock/$(MOCK_CHROOT)/root$(last_run_script)
8188

8289
######### Re-run the last failing script from mock
8390

8491
.PHONY: mockbuild-rerun-last-script
8592
## Re-runs the last failing or running script of your release/mock mockbuild.
86-
mockbuild-rerun-last-script:
87-
mock --root=$(MOCK_CHROOT) --shell 'sh -e /var/tmp/rpm-tmp.*'
93+
mockbuild-rerun-last-script: get-last-run-script
94+
mock --root=$(MOCK_CHROOT) --shell 'sh -e $(last_run_script)'
8895

8996
.PHONY: help
9097
# Based on https://gist.github.com/rcmachado/af3db315e31383502660

0 commit comments

Comments
 (0)