Skip to content

Commit

Permalink
move dependency cache to /var/cache/openrc
Browse files Browse the repository at this point in the history
  • Loading branch information
timkenhan committed Sep 1, 2023
1 parent e740913 commit b6bcb6f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
18 changes: 9 additions & 9 deletions init.d/savecache.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ start()
return 1
fi
fi
if [ ! -d "$RC_LIBEXECDIR"/cache ]; then
if ! checkpath -W "$RC_LIBEXECDIR"; then
eerror "${RC_LIBEXECDIR} is not writable!"
if [ ! -d "$RC_CACHEDIR" ]; then
if ! checkpath -W "$RC_CACHEDIR"; then
eerror "${RC_CACHEDIR} is not writable!"
eerror "Unable to save dependency cache"
if yesno "${RC_GOINGDOWN}"; then
return 0
fi
return 1
fi
rm -rf "$RC_LIBEXECDIR"/cache
if ! mkdir -p "$RC_LIBEXECDIR"/cache; then
eerror "Unable to create $RC_LIBEXECDIR/cache"
rm -rf "$RC_CACHEDIR"
if ! mkdir -p "$RC_CACHEDIR"; then
eerror "Unable to create $RC_CACHEDIR"
eerror "Unable to save dependency cache"
if yesno "${RC_GOINGDOWN}"; then
return 0
fi
return 1
fi
fi
if ! checkpath -W "$RC_LIBEXECDIR"/cache; then
eerror "${RC_LIBEXECDIR}/cache is not writable!"
if ! checkpath -W "$RC_CACHEDIR"; then
eerror "${RC_CACHEDIR} is not writable!"
eerror "Unable to save dependency cache"
if yesno "${RC_GOINGDOWN}"; then
return 0
Expand All @@ -53,7 +53,7 @@ start()
[ -e "$RC_SVCDIR/$x" ] && save="$save $RC_SVCDIR/$x"
done
if [ -n "$save" ]; then
cp -p $save "$RC_LIBEXECDIR"/cache
cp -p $save "$RC_CACHEDIR"
rc=$?
fi
if yesno "${RC_GOINGDOWN}"; then
Expand Down
4 changes: 2 additions & 2 deletions sh/init.sh.BSD.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ case "$(openrc --sys)" in
esac
retval=$?

if [ -e "$RC_LIBEXECDIR"/cache/softlevel ]; then
cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null
if [ -e "$RC_CACHEDIR"/softlevel ]; then
cp -p "$RC_CACHEDIR"/* "$RC_SVCDIR" 2>/dev/null
fi

echo sysinit >"$RC_SVCDIR"/softlevel
Expand Down
4 changes: 2 additions & 2 deletions sh/init.sh.GNU-kFreeBSD.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ ebegin "Creating $RC_SVCDIR"
mkdir -p $RC_SVCDIR
eend $?

if [ -e "$RC_LIBEXECDIR"/cache/softlevel ]; then
cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null
if [ -e "$RC_CACHEDIR"/softlevel ]; then
cp -p "$RC_CACHEDIR"/* "$RC_SVCDIR" 2>/dev/null
fi

echo sysinit >"$RC_SVCDIR"/softlevel
Expand Down
4 changes: 2 additions & 2 deletions sh/init.sh.GNU.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ ebegin "Creating $RC_SVCDIR"
mkdir -p $RC_SVCDIR
eend $?

if [ -e "$RC_LIBEXECDIR"/cache/softlevel ]; then
cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null
if [ -e "$RC_CACHEDIR"/softlevel ]; then
cp -p "$RC_CACHEDIR"/* "$RC_SVCDIR" 2>/dev/null
fi

echo sysinit >"$RC_SVCDIR"/softlevel
Expand Down
4 changes: 2 additions & 2 deletions sh/init.sh.Linux.in
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ if grep -Eq "[[:space:]]+xenfs$" /proc/filesystems; then
eend $?
fi

if [ -e "$RC_LIBEXECDIR"/cache/softlevel ]; then
cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null
if [ -e "$RC_CACHEDIR"/softlevel ]; then
cp -p "$RC_CACHEDIR"/* "$RC_SVCDIR" 2>/dev/null
fi

echo sysinit >"$RC_SVCDIR"/softlevel
Expand Down
3 changes: 3 additions & 0 deletions src/librc/rc.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ extern "C" {
#define RC_LIBEXECDIR "@LIBEXECDIR@"
#if defined(PREFIX)
#define RC_SVCDIR RC_LIBEXECDIR "/init.d"
#define RC_CACHEDIR RC_LIBEXECDIR "/cache"
#elif defined(__linux__) || (defined(__FreeBSD_kernel__) && \
defined(__GLIBC__)) || defined(__GNU__)
#define RC_SVCDIR "/run/openrc"
#define RC_CACHEDIR "/var/cache/openrc"
#else
#define RC_SVCDIR RC_LIBEXECDIR "/init.d"
#define RC_CACHEDIR RC_LIBEXECDIR "/cache"
#endif
#define RC_RUNLEVELDIR RC_SYSCONFDIR "/runlevels"
#define RC_INITDIR RC_SYSCONFDIR "/init.d"
Expand Down
1 change: 1 addition & 0 deletions src/shared/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ env_config(void)
setenv("RC_VERSION", VERSION, 1);
setenv("RC_LIBEXECDIR", RC_LIBEXECDIR, 1);
setenv("RC_SVCDIR", RC_SVCDIR, 1);
setenv("RC_CACHEDIR", RC_CACHEDIR, 1);
setenv("RC_TMPDIR", RC_SVCDIR "/tmp", 1);
setenv("RC_BOOTLEVEL", RC_LEVEL_BOOT, 1);
e = rc_runlevel_get();
Expand Down
2 changes: 1 addition & 1 deletion user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ happen automatically when the service is stopped.
# Caching

For performance reasons OpenRC keeps a cache of pre-parsed service metadata
(e.g. `depend`). The default location for this is `/${RC_SVCDIR}/cache`.
(e.g. `depend`). The default location for this is `${RC_CACHEDIR}`.

The cache uses `mtime` to check for file staleness. Should any service script
change it'll re-source the relevant files and update the cache
Expand Down

0 comments on commit b6bcb6f

Please sign in to comment.