barnowl/zcrypt.pl: BarnOwl::quote the editwin prompt.
[snippets/.git] / apt-zephyr / apt-zephyr
index 3650cc572b915c7d8e22de267e626024245e249a..fdf13182a2abd4883c6c1d1d43960363053c565a 100755 (executable)
@@ -69,27 +69,51 @@ parse_v1 ()
     rm -f "$oldpkgs" "$newpkgs"
 }
 
-read -r line
-case "$line" in
-    'VERSION 2')
-       while read -r line && [ -n "$line" ]; do :; done
-       while read -r package oldver cmp newver action; do
-           case "$action" in
-               '**CONFIGURE**' | '**REMOVE**')
-                   package "$package" "$oldver" "$cmp" "$newver"
-                   ;;
-               '**ERROR**')
-                   echo "ERROR on $package $newver"
-                   ;;
-           esac
-       done
-       ;;
-    'VERSION *')
-       echo "$0: unrecognized version: $line"
-       ;;
-    '')
-       ;;
-    *)
-       (echo "$line"; cat) | parse_v1
-       ;;
-esac | send_zephyr
+parse_v2 ()
+{
+    while read -r line && [ -n "$line" ]; do :; done
+    while read -r package oldver cmp newver action; do
+       case "$action" in
+           '**CONFIGURE**' | '**REMOVE**')
+               package "$package" "$oldver" "$cmp" "$newver"
+               ;;
+           '**ERROR**')
+               echo "ERROR on $package $newver"
+               ;;
+       esac
+    done
+}
+
+pre_install_pkgs ()
+{
+    read -r line
+    case "$line" in
+       'VERSION 2')
+           parse_v2 | send_zephyr
+           ;;
+       'VERSION *')
+           echo "$0: unrecognized version: $line" | send-zephyr
+           ;;
+       '')
+           ;;
+       *)
+           (echo "$line"; cat) | parse_v1 | send_zephyr
+           ;;
+    esac
+}
+
+post_invoke ()
+{
+    echo 'Done.' | send_zephyr
+}
+
+if [ "$1" = "--pre-install-pkgs" ]; then
+    pre_install_pkgs
+elif [ "$1" = "--post-invoke" ]; then
+    post_invoke
+else
+    echo "usage: $0 {--pre-install-pkgs | --post-invoke}" >&2
+    echo "(Hint: you probably need to update /etc/apt/apt.conf.d/90zephyr.)" >&2
+fi
+
+exit 0