diff options
| author | Samuli Piippo <samuli.piippo@qt.io> | 2017-03-07 12:31:59 +0200 |
|---|---|---|
| committer | Samuli Piippo <samuli.piippo@qt.io> | 2017-03-08 07:52:16 +0000 |
| commit | 749c97121ce484bcd9313e7be6cb717cc382575e (patch) | |
| tree | 884338ac1292fe95361fa71bc80e8df22d7eb686 /scripts | |
| parent | db9bde6b6f21d111cee30c9cad3930bd111a6146 (diff) | |
| download | meta-boot2qt-749c97121ce484bcd9313e7be6cb717cc382575e.tar.gz | |
Add script to do sstate-cache cleanup
The script defaults to removing all files that are 7 days older
than the most recent file.
Task-number: QTBUG-53762
Change-Id: Icb05ba08ce32611ae55b9a7d4e7f8ce939fdb72d
Reviewed-by: Risto Avila <risto.avila@qt.io>
Reviewed-by: Mikko Gronoff <mikko.gronoff@qt.io>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/sstate-cache-cleanup.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/sstate-cache-cleanup.sh b/scripts/sstate-cache-cleanup.sh new file mode 100755 index 0000000..4eb6aff --- /dev/null +++ b/scripts/sstate-cache-cleanup.sh | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | ############################################################################ | ||
| 3 | ## | ||
| 4 | ## Copyright (C) 2017 The Qt Company Ltd. | ||
| 5 | ## Contact: https://www.qt.io/licensing/ | ||
| 6 | ## | ||
| 7 | ## This file is part of the Boot to Qt meta layer. | ||
| 8 | ## | ||
| 9 | ## $QT_BEGIN_LICENSE:GPL$ | ||
| 10 | ## Commercial License Usage | ||
| 11 | ## Licensees holding valid commercial Qt licenses may use this file in | ||
| 12 | ## accordance with the commercial license agreement provided with the | ||
| 13 | ## Software or, alternatively, in accordance with the terms contained in | ||
| 14 | ## a written agreement between you and The Qt Company. For licensing terms | ||
| 15 | ## and conditions see https://www.qt.io/terms-conditions. For further | ||
| 16 | ## information use the contact form at https://www.qt.io/contact-us. | ||
| 17 | ## | ||
| 18 | ## GNU General Public License Usage | ||
| 19 | ## Alternatively, this file may be used under the terms of the GNU | ||
| 20 | ## General Public License version 3 or (at your option) any later version | ||
| 21 | ## approved by the KDE Free Qt Foundation. The licenses are as published by | ||
| 22 | ## the Free Software Foundation and appearing in the file LICENSE.GPL3 | ||
| 23 | ## included in the packaging of this file. Please review the following | ||
| 24 | ## information to ensure the GNU General Public License requirements will | ||
| 25 | ## be met: https://www.gnu.org/licenses/gpl-3.0.html. | ||
| 26 | ## | ||
| 27 | ## $QT_END_LICENSE$ | ||
| 28 | ## | ||
| 29 | ############################################################################ | ||
| 30 | |||
| 31 | set -e | ||
| 32 | |||
| 33 | if [ $# -lt 1 ]; then | ||
| 34 | echo "Usage: $0 <sstate-cache-dir(s)>" | ||
| 35 | echo "Remove all old files from <sstate-cache-dir(s)>" | ||
| 36 | exit 1 | ||
| 37 | fi | ||
| 38 | |||
| 39 | DAYS_TO_KEEP=7 | ||
| 40 | NOW=$(date +%s) | ||
| 41 | |||
| 42 | for cachedir in $@; do | ||
| 43 | |||
| 44 | if [ ! -d $cachedir ]; then | ||
| 45 | echo "$cachedir: No such directory" | ||
| 46 | continue | ||
| 47 | fi | ||
| 48 | |||
| 49 | # find the most recently modified file's timestamp | ||
| 50 | LATEST=$(find $cachedir -type f -printf '%T@\n' | sort -n | tail -1 | cut -f 1 -d'.') | ||
| 51 | # calculate days | ||
| 52 | TIMEOUT=$(( ($NOW - $LATEST) / 3600 / 24 + $DAYS_TO_KEEP )) | ||
| 53 | # delete all files older | ||
| 54 | find ${cachedir} -type f -atime +${TIMEOUT} -delete | ||
| 55 | |||
| 56 | done | ||
