[initramfs] Enhanced output format to run `ldconfig` if etc/ld.so.conf is present
[opensde-nopast.git] / bin / sde-cleanup-download
blob44b22da9fa44f170ac8eddfbe5ef529ebbb286b1
1 #!/bin/sh
2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: bin/sde-cleanup-download
6 # Copyright (C) 2007 The OpenSDE Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- SDE-COPYRIGHT-NOTE-END ---
16 [ -n "$SDEROOT" ] ||
17 export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
19 . $SDEROOT/lib/libsde.in
21 cleanup_usage() {
22 local progname=${0##*/}
23 cat <<EOT
24 Usage: $progname [--dry-run]
25 EOT
28 shortopts='d'
29 longopts='dry-run'
30 options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
32 if [ $? -ne 0 ]; then
33 cleanup_usage
34 exit -1
37 # load new arguments list
38 eval set -- "$options"
40 dryrun=
42 while [ $# -gt 0 ]; do
43 case "$1" in
44 --) shift; break ;;
45 -d|--dry-run)
46 dryrun=yes ;;
47 esac
48 shift
49 done
51 set -e
52 trap '' INT
54 mkdir -p "$SDEROOT/tmp"
55 tmpfile="$SDEROOT/tmp/down.$$"
57 # get list of accepted files
58 cat <<EOT > "$tmpfile"
59 download/mirror
60 download/local
61 EOT
62 . $SDEROOT/bin/sde-list-download >> "$tmpfile"
64 # and check those I have against that list
65 ( cd "$SDEROOT"; find download/ -type f ) | while read file; do
66 [ -f "$SDEROOT/$file" ] || continue
68 if ! grep -q "^$file\$" "$tmpfile"; then
69 if [ -n "$dryrun" ]; then
70 echo rm -vf -- "$SDEROOT/$file"
71 else
72 rm -vf -- "$SDEROOT/$file"
75 done
77 rm -f "$tmpfile"
79 trap - INT