Skip to content

Commit 9dffd55

Browse files
authored
build: Add pre-install and pre-removal scripts for DEBIAN package (#1041)
kill sourcegit before install
1 parent 7f8372f commit 9dffd55

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

SourceGit.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ EndProject
6060
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DEBIAN", "DEBIAN", "{F101849D-BDB7-40D4-A516-751150C3CCFC}"
6161
ProjectSection(SolutionItems) = preProject
6262
build\resources\deb\DEBIAN\control = build\resources\deb\DEBIAN\control
63+
build\resources\deb\DEBIAN\preinst = build\resources\deb\DEBIAN\preinst
64+
build\resources\deb\DEBIAN\prerm = build\resources\deb\DEBIAN\prerm
6365
EndProjectSection
6466
EndProject
6567
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "rpm", "rpm", "{9BA0B044-0CC9-46F8-B551-204F149BF45D}"

build/resources/deb/DEBIAN/preinst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# summary of how this script can be called:
6+
# * <new-preinst> `install'
7+
# * <new-preinst> `install' <old-version>
8+
# * <new-preinst> `upgrade' <old-version>
9+
# * <old-preinst> `abort-upgrade' <new-version>
10+
# for details, see http://www.debian.org/doc/debian-policy/
11+
12+
case "$1" in
13+
install|upgrade)
14+
# Check if SourceGit is running and stop it
15+
if pidof -q sourcegit || pgrep -f sourcegit > /dev/null; then
16+
echo "SourceGit is running, stopping it..."
17+
killall sourcegit 2>/dev/null || pkill -f sourcegit 2>/dev/null || true
18+
# Wait for SourceGit to exit
19+
sleep 1
20+
fi
21+
;;
22+
23+
abort-upgrade)
24+
;;
25+
26+
*)
27+
echo "preinst called with unknown argument \`$1'" >&2
28+
exit 1
29+
;;
30+
esac
31+
32+
exit 0

build/resources/deb/DEBIAN/prerm

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# summary of how this script can be called:
6+
# * <prerm> `remove'
7+
# * <old-prerm> `upgrade' <new-version>
8+
# * <new-prerm> `failed-upgrade' <old-version>
9+
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
10+
# * <deconfigured's-prerm> `deconfigure' `in-favour'
11+
# <package-being-installed> <version> `removing'
12+
# <conflicting-package> <version>
13+
# for details, see http://www.debian.org/doc/debian-policy/ or
14+
# the debian-policy package
15+
16+
case "$1" in
17+
remove|upgrade|deconfigure)
18+
# Check if SourceGit is running and stop it
19+
if pidof -q sourcegit || pgrep -f sourcegit > /dev/null; then
20+
echo "SourceGit is running, stopping it before removal..."
21+
killall sourcegit 2>/dev/null || pkill -f sourcegit 2>/dev/null || true
22+
# Wait for SourceGit to exit
23+
sleep 1
24+
fi
25+
;;
26+
27+
failed-upgrade)
28+
;;
29+
30+
*)
31+
echo "prerm called with unknown argument \`$1'" >&2
32+
exit 1
33+
;;
34+
esac
35+
36+
exit 0

0 commit comments

Comments
 (0)