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 <andreas@florath.net>
This commit is contained in:
Andreas Florath 2017-01-14 09:35:24 +00:00
parent 1f75aea634
commit 022d93ee82
3 changed files with 12 additions and 30 deletions

View File

@ -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

View File

@ -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 () {

View File

@ -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.