librecovery: Set UBOOT_PARTITION and UBOOT_SIZE
[recovery.git] / apt-diff
1 #!/bin/sh
2 #
3 # Copyright (C) 2017 Dream Property GmbH, Germany
4 #                    https://dreambox.de/
5 #
6
7 . librecovery
8
9 PACKAGE_LIST="/etc/enigma2/packages.bak"
10
11 usage()
12 {
13         echo "Usage: ${0} [-hiqtv]"
14
15         cat << EOF
16 Compare the current list of installed packages with the point in time when the
17 last restored settings backup was created.
18
19 It lists packages which are no longer installed, one per line. Differing versions
20 get ignored.
21
22 When invoked with -i, an attempt is made to install these packages, if available.
23 EOF
24
25         exit "${1}"
26 }
27
28 INSTALL_ENABLE=0
29 INSTALL_PKGS=
30 while getopts hiqtv opt; do
31         case "${opt}" in
32                 i)
33                         INSTALL_ENABLE=1
34                         ;;
35         esac
36         std_opt "${opt}"
37 done
38
39 if [ ! -f "${PACKAGE_LIST}" ]; then
40         echo "No list of packages found in ${PACKAGE_LIST}." >&2
41         exit 1
42 fi
43
44 pkglist() {
45         (cd "/var/lib/dpkg/info" && ls -1 ./*.list) | sed -e 's,^\./\(.*\)\.list$,\1,' | diff -u - ${PACKAGE_LIST} | sed -ne 's,^+\([^+]\),\1,p'
46 }
47
48 OLDIFS=$IFS
49 IFS='
50 '
51 set -- $(pkglist)
52 for pkg; do
53         if [ "$INSTALL_ENABLE" -eq 1 ]; then
54                 if apt-cache show "$pkg" >/dev/null 2>&1; then
55                         INSTALL_PKGS="$INSTALL_PKGS $pkg"
56                 fi
57         else
58                 echo "$pkg"
59         fi
60 done
61 IFS=$OLDIFS
62
63 if [ -n "$INSTALL_PKGS" ]; then
64         apt-get install $INSTALL_PKGS && apt-get clean
65 fi