Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/debian installer #917

Merged
merged 28 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ go.mod-e

# goreleaser and frontend builds
*.deb
/packages
/deb
/sysroot
static/skywire-manager-src/dist/*
/visor
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ build-ui: install-deps-ui ## Builds the UI
mkdir ${MANAGER_UI_BUILT_DIR}
cp -r ${MANAGER_UI_DIR}/dist/. ${MANAGER_UI_BUILT_DIR}

deb-install-prequisites: ## Create unsigned application
sudo chmod +x ./scripts/deb_installer/prequisites.sh
./scripts/deb_installer/prequisites.sh

deb-package: deb-install-prequisites ## Create unsigned application
./scripts/deb_installer/package_deb.sh

deb-package-help: ## Show installer creation help
./scripts/deb_installer/package_deb.sh -h

mac-installer: ## Create signed and notarized application, run make mac-installer-help for more
./scripts/mac_installer/create_installer.sh -s -n

Expand Down
139 changes: 139 additions & 0 deletions docs/deb_install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Debian

## Installation

### Developer

Prequisites:

- Debian Host
- devscripts
- binutils-i686-linux-gnu
- binutils-aarch64-linux-gnu
- binutils-arm-linux-gnueabi
- dh-systemd
- build-essential
- crossbuild-essential-armhf
- gpg
- dpkg-sig


In order to create the Skywire debian packages, make sure you are running a debian based distro.

To sign the debian packages, add both the public and secret key if not already.
Follow [this guide](https://www.debuntu.org/how-to-importexport-gpg-key-pair/) for more info.

```bash
$ gpg --import ~/mygpgkey_pub.gpg
$ gpg --allow-secret-key-import --import ~/mygpgkey_sec.gpg
```

Check if it is added correctly:
```bash
$ gpg --list-keys
```

Run the packaging make target. Make sure the `Author Email` and `Author Name` is the same as the key in `gpg --list-keys`:
(NOTE: the email should be the same as the email of the key you are sigining with)

The debian package should be created after a release has been made in `github.com/skycoin/skywire` and the version should follow the tag defined in the `skywire` repo.

```bash
$ make deb-package

...
...
Version : 0.5.0
Author Email : [email protected]
Author Name : Some Name
```
The Version, Author Email, and Author Name needs to be added via the terminal in order to build the packages.

During its work script will create packages for the following architectures:
- amd64
- i386
- arm
- arm64
- armhf

For each architecture a changelog file will be created for a package and will be opened with the editor. Apply needed changes and save it.

The script will complain that there's no original code tarball. Ignore the warning by pressing `y`.

Once the script finishes, you'll see a `deb` directory in you current folder. This is where the finished packages are. Put these to `/var/www/repos/apt/debian` on the `apt server` and remove the old packages there.

To sign the packages use:<br>
(NOTE: the email should be the same as the one used in `make deb-package`. as well as the email of the key you are sigining with)
```bash
$ ./scripts/deb_installer/sign_deb.sh [email protected]
```

This will sign all packages.

To verify the signature of a single package use:
```bash
$ dpkg-sig --verify ./deb/skywire_0.5.0-1_amd64.deb
Processing ./deb/skywire_0.5.0-1_amd64.deb...
GOODSIG _gpgbuilder 9A86A72D257E9EEAD3CE6ADDCC2026E6F21CEDA7 1620395902
```

If the package isn't signed, then the output will be `NOSIGN`.
If there is some error, it will be `BADSIG`.
If the package is signed, then the output will be `GOODSIG`. Followed by who signed the package `_gpgbuilder`
and then the keyid of the key that the package is signed with `9A86A72D257E9EEAD3CE6ADDCC2026E6F21CEDA7`
and lastly the epoch time of when it was signed `1620395902`.
To verify that the correct key was used for the signing, compare the `keyid` with the correct `keyid` from
`gpg --list-keys`.

To remove old packages from the repo, cd to `/var/www/repos/apt/debian` and use:
```bash
$ reprepro remove stretch skywire
```

This should be repeated for all needed debian releases.

To add new packages to the repo, from the `/var/www/repos/apt/debian` use:
```bash
$ reprepro includedeb jessie ./skywire_0.5.0-1_amd64.deb
```

This should be repeated for all needed debian releases and built packages.

To install the package use:
```
$ sudo dpkg -i ./deb/skywire_0.5.0-1_amd64.deb
```
This will install `skywire` and `skywire-cli`

To generate a config use
```
$ skywire-cli config gen -pro /opt/skywire/skywire-visor.json
```

To uninstall the package use:
```
$ sudo apt-get remove skywire
```

### End User

Import the public key
```bash
$ wget -O - http://subdomain.skycoin.com/public-gpg.key | sudo apt-key add -
```

Add repo to sources.list

```bash
$ deb http://subdomain.skycoin.com/ skywire main
```

Run
```bash
$ apt-get update
```

To uninstall use:
```
$ sudo apt-get remove skywire
```
19 changes: 19 additions & 0 deletions scripts/deb_installer/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
distclean:
echo dummy
install:
mkdir -p $(DESTDIR)/opt/skywire/apps
mkdir -p $(DESTDIR)/usr/bin
install -m 0755 skywire-visor $(DESTDIR)/opt/skywire/skywire-visor
install -m 0755 skywire-cli $(DESTDIR)/opt/skywire/skywire-cli
install -m 0755 apps/skychat $(DESTDIR)/opt/skywire/apps/skychat
install -m 0755 apps/skysocks $(DESTDIR)/opt/skywire/apps/skysocks
install -m 0755 apps/skysocks-client $(DESTDIR)/opt/skywire/apps/skysocks-client
install -m 0755 apps/vpn-server $(DESTDIR)/opt/skywire/apps/vpn-server
install -m 0755 apps/vpn-client $(DESTDIR)/opt/skywire/apps/vpn-client
ln -s /opt/skywire/skywire-visor $(DESTDIR)/usr/bin/skywire-visor
ln -s /opt/skywire/skywire-cli $(DESTDIR)/usr/bin/skywire-cli

uninstall:
rm -rf $(DESTDIR)/usr/bin/skywire-visor
rm -rf $(DESTDIR)/usr/bin/skywire-cli
rm -rf $(DESTDIR)/opt/skywire
44 changes: 44 additions & 0 deletions scripts/deb_installer/deb.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

rm -rf /opt/skywire/upgrading
if [ -f "/opt/skywire/removing" ]
then
rm -rf /opt/skywire/removing
else
/opt/skywire/skywire-cli visor gen-config -o /opt/skywire/skywire-config.json
fi

setcap 'cap_net_admin+p' /opt/skywire/apps/vpn-client

# Automatically added by dh_systemd_enable/12.1.1
if [ \"\$1\" = \"configure\" ] || [ \"\$1\" = \"abort-upgrade\" ] || [ \"\$1\" = \"abort-deconfigure\" ] || [ \"\$1\" = \"abort-remove\" ] ; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask 'skywire.service' >/dev/null || true

# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled 'skywire.service'; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable 'skywire.service' >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state 'skywire.service' >/dev/null || true
fi
fi
# End automatically added section
# Automatically added by dh_systemd_start/12.1.1
if [ \"\$1\" = \"configure\" ] || [ \"\$1\" = \"abort-upgrade\" ] || [ \"\$1\" = \"abort-deconfigure\" ] || [ \"\$1\" = \"abort-remove\" ] ; then
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -n \"\$2\" ]; then
_dh_action=restart
else
_dh_action=start
fi
deb-systemd-invoke \$_dh_action 'skywire.service' >/dev/null || true
fi
fi
# End automatically added section

#DEBHELPER#
28 changes: 28 additions & 0 deletions scripts/deb_installer/deb.postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

if [ ! -f "opt/skywire/upgrading" ]
then
rm -rf /opt/skywire
fi

# Automatically added by dh_systemd_start/12.1.1
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_systemd_enable/12.1.1
if [ \"\$1\" = \"remove\" ]; then
if [ -x \"/usr/bin/deb-systemd-helper\" ]; then
deb-systemd-helper mask 'skywire.service' >/dev/null || true
fi
fi

if [ \"\$1\" = \"purge\" ]; then
if [ -x \"/usr/bin/deb-systemd-helper\" ]; then
deb-systemd-helper purge 'skywire.service' >/dev/null || true
deb-systemd-helper unmask 'skywire.service' >/dev/null || true
fi
fi
# End automatically added section

#DEBHELPER#
8 changes: 8 additions & 0 deletions scripts/deb_installer/deb.preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [ -f "/opt/skywire/removing" ]
then
touch /opt/skywire/upgrading
fi

#DEBHELPER#
11 changes: 11 additions & 0 deletions scripts/deb_installer/deb.prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

touch /opt/skywire/removing

# Automatically added by dh_systemd_start/12.1.1
if [ -d /run/systemd/system ] && [ \"\$1\" = remove ]; then
deb-systemd-invoke stop 'skywire.service' >/dev/null || true
fi
# End automatically added section

#DEBHELPER#
Loading