]> git.lizzy.rs Git - micro.git/commitdiff
Add support for alternatives system in Debian package (#1935)
authorHugo Hromic <hhromic@users.noreply.github.com>
Wed, 17 Nov 2021 23:51:40 +0000 (23:51 +0000)
committerGitHub <noreply@github.com>
Wed, 17 Nov 2021 23:51:40 +0000 (15:51 -0800)
* Allows for micro to be selectable in the `editor` group
* Use same priority as in the nano package

Ref: https://wiki.debian.org/DebianAlternatives

assets/packaging/deb/micro.postinst [new file with mode: 0755]
assets/packaging/deb/micro.prerm [new file with mode: 0755]
tools/package-deb.sh

diff --git a/assets/packaging/deb/micro.postinst b/assets/packaging/deb/micro.postinst
new file mode 100755 (executable)
index 0000000..5a24444
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
+    update-alternatives --install /usr/bin/editor editor /usr/bin/micro 40 \
+      --slave /usr/share/man/man1/editor.1 editor.1 \
+      /usr/share/man/man1/micro.1
+fi
diff --git a/assets/packaging/deb/micro.prerm b/assets/packaging/deb/micro.prerm
new file mode 100755 (executable)
index 0000000..9999d9e
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" != "upgrade" ]; then
+    update-alternatives --remove editor /usr/bin/micro
+fi
index 7f3b81bcc212d833e85d3ea96bbcbd910cdcaacd..416b88f92c0ac19bd70b6812f5c4acdc7c148c4d 100755 (executable)
@@ -1 +1 @@
-fpm -s dir -t deb -p micro-$1-amd64.deb --name micro --license mit --version $1 --deb-recommends xclip --description "A modern and intuitive terminal-based text editor" ./micro=/usr/bin/micro ./assets/packaging/micro.1=/usr/share/man/man1/micro.1
+fpm -s dir -t deb -p micro-$1-amd64.deb --name micro --license mit --version $1 --deb-recommends xclip --description "A modern and intuitive terminal-based text editor" --after-install ./assets/packaging/deb/micro.postinst --before-remove ./assets/packaging/deb/micro.prerm ./micro=/usr/bin/micro ./assets/packaging/micro.1=/usr/share/man/man1/micro.1