Skip to content

Commit d7e22f2

Browse files
mvo5supakeen
authored andcommitted
data: install tmpfiles.d/image-builder.conf to auto-clean cache
Our osbuild/image-builder cache is located in /var/cache/image-builder and it can grow quite big. To avoid it growing out of bounds too much add a tmpfile.d snippet to ensure that we clean content older than 14d. The 14d is a bit arbitrary, happy to change to longer or shorter cache timeouts (side-note: we have a cache limit in osbuild and an LRU there too but sources are currently not part of the cache limits in osbuild).
1 parent dc16ea1 commit d7e22f2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

data/tmpfiles.d/image-builder.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Type Path Mode UID GID Age
2+
d /var/cache/image-builder 0755 root root 14d

image-builder.spec

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ BuildRequires: libvirt-devel
4242
%if 0%{?fedora}
4343
# Build requirements of 'github.com/containers/storage' package
4444
BuildRequires: btrfs-progs-devel
45+
# for _tmpfilesdir macro
46+
BuildRequires: systemd-rpm-macros
4547
# DO NOT REMOVE the BUNDLE_START and BUNDLE_END markers as they are used by 'tools/rpm_spec_add_provides_bundle.sh' to generate the Provides: bundled list
4648
# BUNDLE_START
4749
# BUNDLE_END
@@ -93,7 +95,9 @@ export LDFLAGS="${LDFLAGS} -X 'main.version=%{version}'"
9395
%install
9496
install -m 0755 -vd %{buildroot}%{_bindir}
9597
install -m 0755 -vp %{gobuilddir}/bin/image-builder %{buildroot}%{_bindir}/
96-
98+
# tmpfiles.d snippet
99+
install -m 0755 -vd %{buildroot}%{_tmpfilesdir}
100+
install -m 0644 -vp data/tmpfiles.d/image-builder.conf %{buildroot}%{_tmpfilesdir}/image-builder.conf
97101
%check
98102
export GOFLAGS="-buildmode=pie"
99103
%if 0%{?rhel}
@@ -110,6 +114,8 @@ cd $PWD/_build/src/%{goipath}
110114
%license LICENSE
111115
%doc README.md
112116
%{_bindir}/image-builder
117+
%{_tmpfilesdir}/image-builder.conf
118+
%ghost %dir /var/cache/image-builder
113119

114120
%changelog
115121
# the changelog is distribution-specific, therefore there's just one entry

0 commit comments

Comments
 (0)