Skip to content
Snippets Groups Projects
Unverified Commit 8d3e1a4e authored by Maxim Cournoyer's avatar Maxim Cournoyer
Browse files

packaging: Streamline jami-all.postinst script.

* packaging/rules/rpm/jami-all.postinst (is_distribution_supported):
Make version agnostic.
(has_rpm, is_opensuse): New procedures.
(CAN_ADD_REPO_SOURCE, JAMI_REPO, ENDTAG): Delete variable.
(jami_repo_name, jami_repo_base_url): New variables.

Change-Id: I01ee72da39a1a8377ec70ae9dc3ef218d0837633
parent 4ee93922
No related branches found
No related tags found
No related merge requests found
...@@ -77,68 +77,62 @@ is_distribution_supported() { ...@@ -77,68 +77,62 @@ is_distribution_supported() {
# This defines variables such as NAME, ID, VERSION_ID, etc. # This defines variables such as NAME, ID, VERSION_ID, etc.
. /etc/os-release . /etc/os-release
case ${ID}_${VERSION_ID%.*} in case ${ID} in
rhel_8|fedora_32|fedora_33|fedora_34|opensuse-leap_15.2|opensuse-tumbleweed) rhel*|fedora*|opensuse*)
return 0 return 0
esac esac
return 1 return 1
} }
has_rpm() {
command -v rpm > /dev/null
}
is_opensuse() {
case ${ID} in
opensuse*)
return 0
esac
return 1
}
############################################################################### ###############################################################################
# [3] Maintainer script main switch # # [3] Maintainer script main switch #
############################################################################### ###############################################################################
if is_distribution_supported; then # Exit unless the following conditions are met.
CAN_ADD_REPO_SOURCE=true is_distribution_supported && has_rpm || exit 0
else
CAN_ADD_REPO_SOURCE=false # Note: the NAME and ID variables are set as a side-effect of sourcing
fi # the /etc/os-release file in the above is_distribution_supported
# call.
if command -v rpm > /dev/null; then # SUSE specifics.
# RPM is required to add the key. if is_opensuse; then
CAN_ADD_REPO_SOURCE=false REPO_FILE=/etc/zypp/repos.d/jami-main.repo
GPG_FILE="/tmp/RPM-GPG-KEY-JAMI"
fi fi
JAMI_REPO=' # Add the key to the trusted keyring.
[jami] echo "$JAMI_KEY" > "$GPG_FILE"
name='"${NAME}"' $releasever - $basearch - Jami rm -f /var/lib/rpm/.rpm.lock > /dev/null 2>&1
baseurl='"${JAMI_REPO_BASE}"/"${ID}"'_$releasever rpm --import "$GPG_FILE" > /dev/null 2>&1
gpgcheck=1
gpgkey=https://dl.jami.net/jami.pub.key jami_repo_name="$NAME \$releasever - \$basearch - Jami"
enabled=1' jami_repo_base_url="$JAMI_REPO_BASE/$ID_\$releasever"
# Remove releasever for tumbleweed as it's a rolling release.
if [ "$ID" = "opensuse-tumbleweed" ]; then
jami_repo_name="$NAME \$basearch - Jami"
jami_repo_base_url=$JAMI_REPO_BASE/$ID
fi
# Set-up Jami repository end tag # Add an entry for the package repository to the trusted package.
if [ "${PLATFORM_ID}" = "opensuse-leap:15.2" ]; then cat > "$REPO_FILE" <<EOF
ENDTAG="opensuse-leap_15.2"
REPO_FILE="/etc/zypp/repos.d/jami-main.repo"
GPG_FILE="/tmp/RPM-GPG-KEY-JAMI"
elif [ "${PLATFORM_ID}" = "opensuse-tumbleweed" ]; then
ENDTAG="opensuse-tumbleweed"
REPO_FILE="/etc/zypp/repos.d/jami-main.repo"
GPG_FILE="/tmp/RPM-GPG-KEY-JAMI"
# Remove releasever for tumbleweed as it's a rolling release
JAMI_REPO='
[jami] [jami]
name='"${NAME}"' $basearch - Jami name=$jami_repo_name
baseurl='"${JAMI_REPO_BASE}"/"${ID}"' baseurl=$jami_repo_base_url
gpgcheck=1 gpgcheck=1
gpgkey=https://dl.jami.net/jami.pub.key gpgkey=https://dl.jami.net/jami.pub.key
enabled=1' enabled=1
fi
if [ "${CAN_ADD_REPO_SOURCE}" = "true" ]; then
# Add the key to the trusted keyring.
echo "$JAMI_KEY" > "$GPG_FILE"
rm -f /var/lib/rpm/.rpm.lock > /dev/null 2>&1
rpm --import "$GPG_FILE" > /dev/null 2>&1
# Add an entry for the package repository to the trusted package.
# XXX: The NAME and ID variables are set as a side-effect of
# sourcing the /etc/os-release file in the above
# is_distribution_supported call.
cat > $REPO_FILE <<EOF
$JAMI_REPO
EOF EOF
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment