commit: 046b5c0b55e092e658ec0d3fd7971c326df7afa0
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 20 21:17:53 2019 +0000
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sun Jul 21 15:47:51 2019 +0000
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=046b5c0b
genkernel: Move $LOGFILE initialization to determine_real_args()
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
gen_determineargs.sh | 24 ++++++++++++++++++++++++
gen_funcs.sh | 9 ---------
genkernel | 3 ---
3 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index d39412c..72741fc 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -188,6 +188,30 @@ determine_real_args() {
set_config_with_override BOOL INSTALL CMD_INSTALL
"yes"
set_config_with_override BOOL CLEANUP CMD_CLEANUP
"yes"
+ local can_write_log=no
+ if [ -w "${LOGFILE}" ]
+ then
+ can_write_log=yes
+ elif [ -w "$(dirname "${LOGFILE}")" ]
+ then
+ can_write_log=yes
+ fi
+
+ if ! isTrue "${can_write_log}"
+ then
+ small_die "Cannot write to '${LOGFILE}'!"
+ fi
+
+ if [ -f "${LOGFILE}" ]
+ then
+ # Truncate existing logfile
+ echo > "${LOGFILE}" 2>/dev/null || small_die "Could not write
to '${LOGFILE}'!"
+ else
+ touch "${LOGFILE}" || small_die "Failed to create '${LOGFILE}'!"
+ fi
+
+ dump_debugcache
+
if [ ! -d "${TMPDIR}" ]
then
mkdir -p "${TMPDIR}" || gen_die "Failed to create '${TMPDIR}'!"
diff --git a/gen_funcs.sh b/gen_funcs.sh
index 5681d0d..de8cd7f 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -264,15 +264,6 @@ cache_replace() {
var_replace "CACHE" "${GK_V_CACHEDIR}" "${1}"
}
-start_log() {
- if [ -f "${LOGFILE}" ]
- then
- (echo > "${LOGFILE}") 2>/dev/null || small_die "Genkernel:
Could not write to '${LOGFILE}'."
- fi
-
- dump_debugcache
-}
-
gen_die() {
set +x
diff --git a/genkernel b/genkernel
index 8991e69..50de3f7 100755
--- a/genkernel
+++ b/genkernel
@@ -95,7 +95,6 @@ then
exit 1
fi
-start_log
NORMAL=${GOOD} print_info 1 "Gentoo Linux Genkernel; Version ${GK_V}${NORMAL}"
print_info 1 "Using genkernel configuration from '${_GENKERNEL_CONF}' ..."
unset _GENKERNEL_CONF
@@ -161,8 +160,6 @@ setup_cache_dir
check_distfiles
-dump_debugcache
-
KERNCACHE_IS_VALID="no"
if [ -n "${KERNCACHE}" ]
then