Skip to content

Commit

Permalink
Fixed live/Makefile (#1182)
Browse files Browse the repository at this point in the history
## Problem

- The tarballs are not updated after touching any source file:
``` console
> touch root/tmp/README.md
> make
make: Nothing to be done for 'all'.
```

## Solution

- Add dependencies to all source files
- Additionally the process is less verbose now

## Testing

- Tested manually

```console
> touch root/tmp/README.md
> make
dist/root.tar.xz updated
```
  • Loading branch information
lslezak authored May 7, 2024
2 parents 119a7a1 + 0bd685e commit 6bdd94d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions live/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,31 @@ $(DESTDIR):

# copy the files from src/ to dist/
$(DESTDIR)/%: $(SRCDIR)/%
cp -f $< $@
@if [ -e "$@" ]; then MSG="updated"; else MSG="created"; fi; \
cp -f $< $@ ;\
echo "$@ $${MSG}"

# make a tarball from a directory
# the tarball is reproducible, i.e. the same sources should result in the very
# same tarball (bitwise) for the file time stamps use the date of the last
# commit in the respective directory, use the UTC date to avoid possible time
# zone and DST differences
$(DESTDIR)/%.tar.xz: %
#
# we need the second expansion here to depend on all files in the source
# directory, the first expansion expands `%` and reduces the escaped $$
# to a single $, the second expansion runs $(shell find ...)
# https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html
.SECONDEXPANSION:
$(DESTDIR)/%.tar.xz: % $$(shell find % -type f,l)
@if [ -e "$@" ]; then MSG="updated"; else MSG="created"; fi; \
MTIME=$$(date --date="$$(git log -n 1 --pretty=format:%ci $<)" --utc +"%Y-%m-%d %H:%M:%S"); \
(cd $< && find . -xtype f -not -name README.md | LC_ALL=C sort | tar -c -v -f - --format=gnu --owner=0 --group=0 --files-from - --mtime="$$MTIME") | xz -c -9 -e > $@
(cd $< && find . -type f,l -not -name README.md | LC_ALL=C sort | tar -c -f - --format=gnu --owner=0 --group=0 --files-from - --mtime="$$MTIME") | xz -c -9 -e > $@; \
echo "$@ $${MSG}"

# build the ISO locally
build: $(DESTDIR)
if [ ! -e $(DESTDIR)/.osc ]; then make clean; osc co -o $(DESTDIR) systemsmanagement:Agama:Staging agama-live; fi
$(MAKE) all
(cd $(DESTDIR) && osc build -M $(FLAVOR) images)

.PHONY: build all clean

0 comments on commit 6bdd94d

Please sign in to comment.