Skip to content

Commit ca7d9dc

Browse files
committed
migrations: trixie: Ensure postgresql-common is installed before running debconf-set-selections on it
1 parent c90e726 commit ca7d9dc

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/migrations/0036_migrate_to_trixie.py.disabled

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ def download_gpg_key(url: str, file: Path) -> None:
143143
file.write_bytes(dearmored)
144144

145145

146+
def package_is_installed(package: str) -> bool:
147+
result = subprocess.run(
148+
f"dpkg --list | grep '^ii ' | grep -q -w {package}",
149+
check=False,
150+
shell=True,
151+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
152+
)
153+
return result.returncode == 0
154+
155+
146156
class MyMigration(Migration):
147157
"Upgrade the system to Debian Trixie and Yunohost 13.x"
148158

@@ -202,11 +212,12 @@ class MyMigration(Migration):
202212
])
203213

204214
# Don't send an email to root about the postgresql migration. It should be handled automatically after.
205-
subprocess.run(
206-
["debconf-set-selections"],
207-
input="postgresql-common postgresql-common/obsolete-major seen true".encode("utf-8"),
208-
check=True,
209-
)
215+
if package_is_installed("postgresql-common"):
216+
subprocess.run(
217+
["debconf-set-selections"],
218+
input="postgresql-common postgresql-common/obsolete-major seen true".encode("utf-8"),
219+
check=True,
220+
)
210221

211222
#
212223
# Patch yunohost conflicts

0 commit comments

Comments
 (0)