From 022d93ee822e71245af52c4cf8f8a8e82f599af3 Mon Sep 17 00:00:00 2001 From: Andreas Florath Date: Sat, 14 Jan 2017 09:35:24 +0000 Subject: [PATCH] Unify tidy up logs in lib/img-functions Cleaning logs was split, some was done in the img-functions.finalise_base, some was done in the base element. The version unifies tidy up logs in the lib/img-functions. Especially when building docker container images the base element cannot be used. This patch removes about some hundreds KB of useless logs in cases when the base element is not used. Change-Id: I165bafb73daf9144c2f3a83930e85e8d8cf5fae3 Signed-off-by: Andreas Florath --- elements/base/cleanup.d/99-tidy-logs | 30 ------------------- lib/img-functions | 4 +++ ...ve_tidy_logs_to_main-a8c03427fe1a445c.yaml | 8 +++++ 3 files changed, 12 insertions(+), 30 deletions(-) delete mode 100755 elements/base/cleanup.d/99-tidy-logs create mode 100644 releasenotes/notes/move_tidy_logs_to_main-a8c03427fe1a445c.yaml diff --git a/elements/base/cleanup.d/99-tidy-logs b/elements/base/cleanup.d/99-tidy-logs deleted file mode 100755 index 9274a7b0b..000000000 --- a/elements/base/cleanup.d/99-tidy-logs +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -# -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then - set -x -fi -set -eu -set -o pipefail - -# Truncate /var/log files in preparation for first boot -sudo find $TARGET_ROOT/var/log -type f -exec cp /dev/null '{}' \; - -# also /root logs -sudo find $TARGET_ROOT/root -name \*.log -type f -delete - diff --git a/lib/img-functions b/lib/img-functions index d803cc81c..bb74321aa 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -110,6 +110,10 @@ function finalise_base () { unmount_dir $TMP_MOUNT_PATH/tmp fi find $TMP_MOUNT_PATH/tmp -maxdepth 1 -mindepth 1 | xargs sudo rm -rf --one-file-system + # Truncate /var/log files in preparation for first boot + sudo find ${TMP_MOUNT_PATH}/var/log -type f -exec cp /dev/null '{}' \; + # also /root logs + sudo find ${TMP_MOUNT_PATH}/root -name \*.log -type f -delete } function compress_and_save_image () { diff --git a/releasenotes/notes/move_tidy_logs_to_main-a8c03427fe1a445c.yaml b/releasenotes/notes/move_tidy_logs_to_main-a8c03427fe1a445c.yaml new file mode 100644 index 000000000..fbd729561 --- /dev/null +++ b/releasenotes/notes/move_tidy_logs_to_main-a8c03427fe1a445c.yaml @@ -0,0 +1,8 @@ +--- +features: + - Cleaning logs was split, some was done in the + img-functions.finalise_base, some was done in the base element. + The version unifies tidy up logs in the lib/img-functions. + Especially when building docker container images the base element + cannot be used. This patch removes about some hundreds KB of + useless logs in cases when the base element is not used. \ No newline at end of file