Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openrc: Don't use libexec for data cache. #755

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions init.d/consolefont.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ start()
eend $retval

# Store the font so we can use it ASAP on boot
if [ $retval -eq 0 ] && checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console
setfont -O "$RC_LIBEXECDIR"/console/font
if [ $retval -eq 0 ] && checkpath -m 0755 -d "$RC_CACHEDIR"; then
mkdir -p "$RC_CACHEDIR"/console
setfont -O "$RC_CACHEDIR"/console/font
fi

return $retval
Expand Down
8 changes: 4 additions & 4 deletions init.d/save-termencoding.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ start()
{
ebegin "Saving terminal encoding"
# Save the encoding for use immediately at boot
if checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console
if checkpath -m 0755 -d "$RC_CACHEDIR"; then
mkdir -p "$RC_CACHEDIR"/console
if yesno ${unicode:-yes}; then
echo "" > "$RC_LIBEXECDIR"/console/unicode
echo "" > "$RC_CACHEDIR"/console/unicode
else
rm -f "$RC_LIBEXECDIR"/console/unicode
rm -f "$RC_CACHEDIR"/console/unicode
fi
fi
eend 0
Expand Down
36 changes: 8 additions & 28 deletions init.d/savecache.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +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!"
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"
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 -m 0755 -d "$RC_CACHEDIR"; then
eerror "Unable to save dependency cache"
if yesno "${RC_GOINGDOWN}"; then
return 0
fi
return 1
fi

ebegin "Saving dependency cache"
local rc=0 save=
for x in depconfig deptree rc.log shutdowntime softlevel; do
for x in depconfig deptree rc.log shutdowntime; do
[ -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
eend $rc "Unable to save dependency cache"

if yesno "${RC_GOINGDOWN}"; then
if [ $rc -ne 0 ]; then
eerror "Unable to save dependency cache"
fi
eend 0
return 0
fi
eend $rc "Unable to save dependency cache"
}
8 changes: 4 additions & 4 deletions init.d/termencoding.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ start()
done

# Save the encoding for use immediately at boot
if checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console
if checkpath -m 0755 -d "$RC_CACHEDIR"; then
mkdir -p "$RC_CACHEDIR"/console
if yesno ${unicode:-yes}; then
echo "" > "$RC_LIBEXECDIR"/console/unicode
echo "" > "$RC_CACHEDIR"/console/unicode
else
rm -f "$RC_LIBEXECDIR"/console/unicode
rm -f "$RC_CACHEDIR"/console/unicode
fi
fi

Expand Down
11 changes: 6 additions & 5 deletions sh/init-early.sh.Linux.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

: ${CONSOLE:=/dev/console}
: ${RC_LIBEXECDIR:=@LIBEXECDIR@}
: ${RC_CACHEDIR:=/var/cache/openrc}

service_present()
{
Expand All @@ -25,7 +26,7 @@ service_present()
return 0
}

if [ -e "$RC_LIBEXECDIR"/console/unicode ]; then
if [ -e "$RC_CACHEDIR"/console/unicode ]; then
termencoding="%G"
kmode="-u"
else
Expand All @@ -40,19 +41,19 @@ fi
if service_present "$RC_DEFAULTLEVEL" consolefont ||
service_present "$RC_BOOTLEVEL" consolefont; then
printf "\033%s" "$termencoding" >"$CONSOLE" 2>/dev/null
if [ -r "$RC_LIBEXECDIR"/console/font ] && \
if [ -r "$RC_CACHEDIR"/console/font ] && \
command -v setfont > /dev/null 2>&1; then
[ -c "$CONSOLE" ] && cons="-C $CONSOLE"
setfont $cons "$RC_LIBEXECDIR"/console/font 2>/dev/null
setfont $cons "$RC_CACHEDIR"/console/font 2>/dev/null
fi
fi

# Try and set a keyboard map as early as possible
if service_present "$RC_DEFAULTLEVEL" keymaps ||
service_present "$RC_BOOTLEVEL" keymaps; then
kbd_mode $kmode -C "$CONSOLE" 2>/dev/null
if [ -r "$RC_LIBEXECDIR"/console/keymap ]; then
loadkeys -q "$RC_LIBEXECDIR"/console/keymap 2>/dev/null
if [ -r "$RC_CACHEDIR"/console/keymap ]; then
loadkeys -q "$RC_CACHEDIR"/console/keymap 2>/dev/null
fi
fi

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 [ -d "$RC_CACHEDIR" ]; then
cp -p "$RC_CACHEDIR"/* "$RC_SVCDIR" 2>/dev/null
fi

echo sysinit >"$RC_SVCDIR"/softlevel
Expand Down
3 changes: 1 addition & 2 deletions src/openrc/rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,7 @@ do_sysinit(void)
* sys */
if ((sys = rc_sys()))
setenv("RC_SYS", sys, 1);
/* force an update of the dependency tree */
if ((main_deptree = _rc_deptree_load(1, NULL)) == NULL)
if ((main_deptree = _rc_deptree_load(false, NULL)) == NULL)
eerrorx("failed to load deptree");
}

Expand Down
1 change: 1 addition & 0 deletions src/shared/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ env_config(void)
setenv("RC_LIBEXECDIR", RC_LIBEXECDIR, 1);
setenv("RC_SVCDIR", RC_SVCDIR, 1);
setenv("RC_TMPDIR", RC_SVCDIR "/tmp", 1);
setenv("RC_CACHEDIR", "/var/cache/openrc", 1);
setenv("RC_BOOTLEVEL", RC_LEVEL_BOOT, 1);
e = rc_runlevel_get();
setenv("RC_RUNLEVEL", e, 1);
Expand Down
Loading