Skip to content

Commit

Permalink
build: fix Debian installer file for deprecated apt-key add (#364)
Browse files Browse the repository at this point in the history
The Debian repository now uses the signed-by option on its list file,
instead of adding a key for the whole system.
This has been tested to work with Ubuntu 18.04 and newer versions
  • Loading branch information
fcastilloec authored Mar 4, 2021
1 parent 5a9d2e8 commit 675992d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 55 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ As an alternative to `.deb` and `.rpm` packages on the website, you can also ins
#### Debian

```shell
wget -q http://headsetapp.co/headset-electron/headset.asc -O- | sudo apt-key add -
echo "deb [arch=amd64] http://headsetapp.co/headset-electron/debian stable non-free" | sudo tee /etc/apt/sources.list.d/headset.list
wget -q http://headsetapp.co/headset-electron/headset.gpg -O- | sudo tee /usr/share/keyrings/headset-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/headset-archive-keyring.gpg] http://headsetapp.co/headset-electron/debian stable non-free" | sudo tee /etc/apt/sources.list.d/headset.list
sudo apt-get update
sudo apt-get install headset
```
Expand Down
62 changes: 23 additions & 39 deletions bin/debian_scripts/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,35 @@

set -e

REPOCONFIG="deb [arch=amd64] http://headsetapp.co/headset-electron/debian stable non-free"
APT_SOURCESDIR="/etc/apt/sources.list.d/"
SOURCELIST="$APT_SOURCESDIR/headset.list"
KEY_ID="6E15 1B86 388F 9659 70CA 2B90 53E3 2C39 9D78 2F91"
KEYRING_DIR="/usr/share/keyrings"
KEYRING="${KEYRING_DIR}/headset-archive-keyring.gpg"
APT_SOURCES_DIR="/etc/apt/sources.list.d/"
SOURCE_LIST="${APT_SOURCES_DIR}/headset.list"
REPO_CONFIG="deb [arch=amd64 signed-by=${KEYRING}] https://headsetapp.co/headset-electron/debian stable non-free"

install_key() {
APT_KEY="$(which apt-key 2> /dev/null)"
if [ -x "$APT_KEY" ]; then
"$APT_KEY" add - >/dev/null 2>&1 <<KEYDATA
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
uninstall_key() {
APT_KEY="$(command -v apt-key 2> /dev/null)"
if [ -x "${APT_KEY}" ]; then
if ${APT_KEY} list 2> /dev/null | grep -q "${KEY_ID}"; then
${APT_KEY} del "${KEY_ID}"
fi
fi
}

mQINBFnMhmcBEAC89TE4M7muWVfEjd6pU21+QQ54ve9g49sC8dcar/nT8FjkU4UU
g3TtDo4ISzYmc1ff/oic8EEwXiBkuRCB0idho8+g6ZY11lf+gMouM22xEkA27aEf
sjv5aBt9wKDRe4jmTMaz/g9LExsTnjvwGkC25257pNcpMZavBN7GkLZzOJ5OZC6Q
Lhfn0y4RwZvpzcGrEzyvql4/AdAVgLAR/wgw3HlN2R9L/YhM5Jis3BNvB5JT+O9I
R6q8/xe74NKUdkVg48ro2b+jekhRsu5Rz9m/hw2KXWZmjSduUq3D8BYAIh2PdiA9
+Q1u1zDrbpizbSztF6/Tg6LrspRfpNsY1koCe/izdj8aprEfk6Oy+6MiAcfIOtgB
E1IRZwBImjHX8gZpT1l1ewimpsRVgCJ5k1ajZk378wsF1Ftk3kn138SQWXbGDcYo
cVa/E/gdZLZkSu6VeDsU8VNGUUvH5avOxTanFwhoujs/VpzRNs739VBxj8jg/1Dc
BPJUat3ldb1KIas8MEdQ0Bck49aj2YOUnOqrzWpR2brbvYyZX65nNocHy1L0Gx4A
PUkgCC5qpJrbz+WX4a8XOn18XZIQ0xo7JAvEIX1UNkcWp400TiHBa+LJg06xWJ3D
4f38/HqJ0u6CPfjgQaQuqJyvwOR17f0zWBeMuZlXjyobduLo/oOMWFcdiQARAQAB
tD5IZWFkc2V0IChIZWFkc2V0IHJlcG9zaXRvcnkgc2lnbmluZyBrZXkpIDxoZWxs
b0BoZWFkc2V0YXBwLmNvPokCOAQTAQIAIgUCWcyGZwIbAwYLCQgHAwIGFQgCCQoL
BBYCAwECHgECF4AACgkQU+MsOZ14L5HbAw//RKVuTC8iF6C/dvnnvclf5NvQHIus
l73nWMSeMiVgJU+v+JhanIoi5tZJd0eJ/VBhIwPgRRcxobJXyq3xcW8IhCZemNy7
E5AXL+d6wFdRDe5l5Yu6cW6XF9JRKj0xGAhP3q1sSubE95UgQ5CuFoJBoOWbYg30
joNkQcD4CihFhY3+DA71Unuanx2LJE9k/FYYmgSdOlyDxa4lvvC3RecYt7Aci/C4
JbeI7jUt7LVRV8qU6vas8gfIJbLnEFz4cPU+dP+yhjOG9w9KuevoJWhgp3Iuk255
6SVCj654Y0LtQ5fqijKiOGyV+VE4zWO4DhnCa7/psNEqbDDu23eskhNYIbwUFb7X
+kW8uhhiPXtUL6BlfUXtjlFhKn5SnA6HKl0s51ZrUGrxkTKff6A/BX5FA7eKnQ97
ugjDVIjmGqll5lYYFLLno5fwks0ZtW9cKuTE+hlalYekszo0gh/6Ey8gsVg7QZOm
SCadlEm+yapn18PSuYDne3L4PllbAizHLQujY9OLoEfKX4qkMXxGWDFV15wqP7JH
7N3FyqFuclC3CPsRxjkbNlzEHPpJW1AvdrooChdSJxIsf0lJL9KrN684y/3Rczyd
d6INGg3lPhwkS+qot6dvuMup1zePb4h2GnMiEOykL5N9zQ4jiErnXD4SlYLzMdyq
0FDwaKLftbXQwBo=
=zPNg
-----END PGP PUBLIC KEY BLOCK-----
KEYDATA
# Move the key
install_key() {
if [ -d "${KEYRING_DIR}" ]; then
mv /usr/lib/headset/headset-archive-keyring.gpg "${KEYRING}"
return 0
fi
return 1
}

# Creates the repository source file
create_sources_lists() {
if [ -d "$APT_SOURCESDIR" ]; then
if echo "$REPOCONFIG" > "$SOURCELIST"; then
if [ -d "${APT_SOURCES_DIR}" ]; then
if echo "${REPO_CONFIG}" > "${SOURCE_LIST}"; then
return 0
fi
fi
Expand All @@ -57,3 +40,4 @@ create_sources_lists() {
## MAIN ##
install_key
create_sources_lists
uninstall_key
19 changes: 8 additions & 11 deletions bin/debian_scripts/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@

set -e

KEYID="9D782F91"

action=$1

# Only do complete clean-up on purge.
if [ "$action" != "purge" ] ; then
if [ "${action}" != "purge" ] ; then
exit 0
fi

APT_SOURCESDIR="/etc/apt/sources.list.d/"
SOURCELIST="$APT_SOURCESDIR/headset.list"
APT_SOURCES_DIR="/etc/apt/sources.list.d/"
SOURCE_LIST="${APT_SOURCES_DIR}/headset.list"
KEYRING_DIR="/usr/share/keyrings"
KEYRING="${KEYRING_DIR}/co.headsetapp.headset-keyring.gpg"

# Clean sources lists
rm -f "$SOURCELIST"*
rm -f "${SOURCE_LIST}"*

# Remove key
APT_KEY="$(which apt-key 2> /dev/null)"
if [ -x "$APT_KEY" ]; then
"$APT_KEY" remove "$KEYID" >/dev/null 2>&1
if [ -f "${KEYRING}" ]; then
rm -f "${KEYRING}"
fi

# TODO: Remove config?
9 changes: 6 additions & 3 deletions bin/packager/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ source="build/Headset-linux-x64"

OS=linux node bin/packager/packager.js

# Add repository signing key
cp gh-pages/headset.gpg "${source}/headset-archive-keyring.gpg"

echo -e '\n\033[1mFixing various file permissions: \033[01;0m'
find $source -type f -exec chmod 0644 {} +
find $source -type d -exec chmod 0755 {} +
chmod 0755 $source/headset
find "${source}" -type f -exec chmod 0644 {} +
find "${source}" -type d -exec chmod 0755 {} +
chmod 0755 "${source}/headset"
chmod 0755 bin/debian_scripts/postinst
chmod 0755 bin/debian_scripts/postrm
echo -e 'Done'
Binary file added gh-pages/headset.gpg
Binary file not shown.

0 comments on commit 675992d

Please sign in to comment.