Skip to content

Commit 60096aa

Browse files
authored
feat: prevent upgrades (#5843)
* feat: prevent upgrades * fix: correctly handle dpkg state machine * feat: add suggestion about apt-mark hold and improved log
1 parent 14e5250 commit 60096aa

10 files changed

Lines changed: 177 additions & 8 deletions

File tree

kura/distrib/src/main/resources/aarch64-nn/deb/control/postinst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2023, 2024 Eurotech and/or its affiliates and others
3+
# Copyright (c) 2023, 2025 Eurotech and/or its affiliates and others
44
#
55
# This program and the accompanying materials are made
66
# available under the terms of the Eclipse Public License 2.0
@@ -93,6 +93,13 @@ function postInstall {
9393
##############################################
9494
# POST INSTALL SCRIPT
9595
##############################################
96+
97+
# Handle abort-upgrade case
98+
if [ "$1" = "abort-upgrade" ]; then
99+
echo "postinst called with abort-upgrade: nothing to do."
100+
exit 0
101+
fi
102+
96103
runPostInstall
97104
exit 0
98105
#############################################

kura/distrib/src/main/resources/aarch64-nn/deb/control/prerm

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2023, 2024 Eurotech and/or its affiliates and others
3+
# Copyright (c) 2023, 2025 Eurotech and/or its affiliates and others
44
#
55
# This program and the accompanying materials are made
66
# available under the terms of the Eclipse Public License 2.0
@@ -112,6 +112,28 @@ function preRemove {
112112
##############################################
113113
# PRE-REMOVE SCRIPT
114114
##############################################
115+
116+
# Fail if the first argument is 'upgrade' or 'failed-upgrade'
117+
if [ "$1" == "upgrade" ]; then
118+
echo ""
119+
echo "#####################################################################"
120+
echo "# #"
121+
echo "# ERROR: KURA upgrade is NOT supported! #"
122+
echo "# Please uninstall the existing version before upgrading. #"
123+
echo "# #"
124+
echo "# To prevent accidental upgrades, you can hold this package with: #"
125+
echo "# sudo apt-mark hold kura #"
126+
echo "# #"
127+
echo "#####################################################################"
128+
echo ""
129+
exit 1
130+
fi
131+
132+
if [ "$1" == "failed-upgrade" ]; then
133+
echo "This package cannot be upgraded. Please uninstall the existing version before installing a new one."
134+
exit 1
135+
fi
136+
115137
echo ""
116138
echo "Uninstalling KURA..."
117139

kura/distrib/src/main/resources/aarch64/deb/control/postinst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2023 Eurotech and/or its affiliates and others
3+
# Copyright (c) 2023, 2025 Eurotech and/or its affiliates and others
44
#
55
# This program and the accompanying materials are made
66
# available under the terms of the Eclipse Public License 2.0
@@ -93,6 +93,13 @@ function postInstall {
9393
##############################################
9494
# POST INSTALL SCRIPT
9595
##############################################
96+
97+
# Handle abort-upgrade case
98+
if [ "$1" = "abort-upgrade" ]; then
99+
echo "postinst called with abort-upgrade: nothing to do."
100+
exit 0
101+
fi
102+
96103
runPostInstall
97104
exit 0
98105
#############################################

kura/distrib/src/main/resources/aarch64/deb/control/prerm

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2023, 2024 Eurotech and/or its affiliates and others
3+
# Copyright (c) 2023, 2025 Eurotech and/or its affiliates and others
44
#
55
# This program and the accompanying materials are made
66
# available under the terms of the Eclipse Public License 2.0
@@ -140,6 +140,28 @@ function preRemove {
140140
##############################################
141141
# PRE-REMOVE SCRIPT
142142
##############################################
143+
144+
# Fail if the first argument is 'upgrade' or 'failed-upgrade'
145+
if [ "$1" == "upgrade" ]; then
146+
echo ""
147+
echo "#####################################################################"
148+
echo "# #"
149+
echo "# ERROR: KURA upgrade is NOT supported! #"
150+
echo "# Please uninstall the existing version before upgrading. #"
151+
echo "# #"
152+
echo "# To prevent accidental upgrades, you can hold this package with: #"
153+
echo "# sudo apt-mark hold kura #"
154+
echo "# #"
155+
echo "#####################################################################"
156+
echo ""
157+
exit 1
158+
fi
159+
160+
if [ "$1" == "failed-upgrade" ]; then
161+
echo "This package cannot be upgraded. Please uninstall the existing version before installing a new one."
162+
exit 1
163+
fi
164+
143165
echo ""
144166
echo "Uninstalling KURA..."
145167

kura/distrib/src/main/resources/docker-x86_64-nn/deb/control/postinst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
#!/bin/bash
2+
#
3+
# Copyright (c) 2023, 2025 Eurotech and/or its affiliates and others
4+
#
5+
# This program and the accompanying materials are made
6+
# available under the terms of the Eclipse Public License 2.0
7+
# which is available at https://www.eclipse.org/legal/epl-2.0/
8+
#
9+
# SPDX-License-Identifier: EPL-2.0
10+
#
11+
# Contributors:
12+
# Eurotech
13+
#
214

315
INSTALL_DIR=/opt/eclipse
416
TIMESTAMP=`date +%Y%m%d%H%M%S`
@@ -81,6 +93,13 @@ function postInstall {
8193
##############################################
8294
# POST INSTALL SCRIPT
8395
##############################################
96+
97+
# Handle abort-upgrade case
98+
if [ "$1" = "abort-upgrade" ]; then
99+
echo "postinst called with abort-upgrade: nothing to do."
100+
exit 0
101+
fi
102+
84103
runPostInstall
85104
exit 0
86105
#############################################

kura/distrib/src/main/resources/docker-x86_64-nn/deb/control/prerm

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
#!/bin/bash
2+
#
3+
# Copyright (c) 2023, 2025 Eurotech and/or its affiliates and others
4+
#
5+
# This program and the accompanying materials are made
6+
# available under the terms of the Eclipse Public License 2.0
7+
# which is available at https://www.eclipse.org/legal/epl-2.0/
8+
#
9+
# SPDX-License-Identifier: EPL-2.0
10+
#
11+
# Contributors:
12+
# Eurotech
13+
#
214

315
INSTALL_DIR=/opt/eclipse
416
WD_TMP_FILE=/tmp/watchdog
@@ -95,6 +107,28 @@ function preRemove {
95107
##############################################
96108
# PRE-REMOVE SCRIPT
97109
##############################################
110+
111+
# Fail if the first argument is 'upgrade' or 'failed-upgrade'
112+
if [ "$1" == "upgrade" ]; then
113+
echo ""
114+
echo "#####################################################################"
115+
echo "# #"
116+
echo "# ERROR: KURA upgrade is NOT supported! #"
117+
echo "# Please uninstall the existing version before upgrading. #"
118+
echo "# #"
119+
echo "# To prevent accidental upgrades, you can hold this package with: #"
120+
echo "# sudo apt-mark hold kura #"
121+
echo "# #"
122+
echo "#####################################################################"
123+
echo ""
124+
exit 1
125+
fi
126+
127+
if [ "$1" == "failed-upgrade" ]; then
128+
echo "This package cannot be upgraded. Please uninstall the existing version before installing a new one."
129+
exit 1
130+
fi
131+
98132
echo ""
99133
echo "Uninstalling KURA..."
100134

kura/distrib/src/main/resources/x86_64-nn/deb/control/postinst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2023, 2024 Eurotech and/or its affiliates and others
3+
# Copyright (c) 2023, 2025 Eurotech and/or its affiliates and others
44
#
55
# This program and the accompanying materials are made
66
# available under the terms of the Eclipse Public License 2.0
@@ -93,6 +93,13 @@ function postInstall {
9393
##############################################
9494
# POST INSTALL SCRIPT
9595
##############################################
96+
97+
# Handle abort-upgrade case
98+
if [ "$1" = "abort-upgrade" ]; then
99+
echo "postinst called with abort-upgrade: nothing to do."
100+
exit 0
101+
fi
102+
96103
runPostInstall
97104
exit 0
98105
#############################################

kura/distrib/src/main/resources/x86_64-nn/deb/control/prerm

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2023, 2024 Eurotech and/or its affiliates and others
3+
# Copyright (c) 2023, 2025 Eurotech and/or its affiliates and others
44
#
55
# This program and the accompanying materials are made
66
# available under the terms of the Eclipse Public License 2.0
@@ -112,6 +112,28 @@ function preRemove {
112112
##############################################
113113
# PRE-REMOVE SCRIPT
114114
##############################################
115+
116+
# Fail if the first argument is 'upgrade' or 'failed-upgrade'
117+
if [ "$1" == "upgrade" ]; then
118+
echo ""
119+
echo "#####################################################################"
120+
echo "# #"
121+
echo "# ERROR: KURA upgrade is NOT supported! #"
122+
echo "# Please uninstall the existing version before upgrading. #"
123+
echo "# #"
124+
echo "# To prevent accidental upgrades, you can hold this package with: #"
125+
echo "# sudo apt-mark hold kura #"
126+
echo "# #"
127+
echo "#####################################################################"
128+
echo ""
129+
exit 1
130+
fi
131+
132+
if [ "$1" == "failed-upgrade" ]; then
133+
echo "This package cannot be upgraded. Please uninstall the existing version before installing a new one."
134+
exit 1
135+
fi
136+
115137
echo ""
116138
echo "Uninstalling KURA..."
117139

kura/distrib/src/main/resources/x86_64/deb/control/postinst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2023 Eurotech and/or its affiliates and others
3+
# Copyright (c) 2023, 2025 Eurotech and/or its affiliates and others
44
#
55
# This program and the accompanying materials are made
66
# available under the terms of the Eclipse Public License 2.0
@@ -93,6 +93,13 @@ function postInstall {
9393
##############################################
9494
# POST INSTALL SCRIPT
9595
##############################################
96+
97+
# Handle abort-upgrade case
98+
if [ "$1" = "abort-upgrade" ]; then
99+
echo "postinst called with abort-upgrade: nothing to do."
100+
exit 0
101+
fi
102+
96103
runPostInstall
97104
exit 0
98105
#############################################

kura/distrib/src/main/resources/x86_64/deb/control/prerm

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2023, 2024 Eurotech and/or its affiliates and others
3+
# Copyright (c) 2023, 2025 Eurotech and/or its affiliates and others
44
#
55
# This program and the accompanying materials are made
66
# available under the terms of the Eclipse Public License 2.0
@@ -140,6 +140,28 @@ function preRemove {
140140
##############################################
141141
# PRE-REMOVE SCRIPT
142142
##############################################
143+
144+
# Fail if the first argument is 'upgrade' or 'failed-upgrade'
145+
if [ "$1" == "upgrade" ]; then
146+
echo ""
147+
echo "#####################################################################"
148+
echo "# #"
149+
echo "# ERROR: KURA upgrade is NOT supported! #"
150+
echo "# Please uninstall the existing version before upgrading. #"
151+
echo "# #"
152+
echo "# To prevent accidental upgrades, you can hold this package with: #"
153+
echo "# sudo apt-mark hold kura #"
154+
echo "# #"
155+
echo "#####################################################################"
156+
echo ""
157+
exit 1
158+
fi
159+
160+
if [ "$1" == "failed-upgrade" ]; then
161+
echo "This package cannot be upgraded. Please uninstall the existing version before installing a new one."
162+
exit 1
163+
fi
164+
143165
echo ""
144166
echo "Uninstalling KURA..."
145167

0 commit comments

Comments
 (0)