Skip to content

Commit

Permalink
Merge #29
Browse files Browse the repository at this point in the history
29: Adding rpm build capability and CI publish to release r=sacherjj a=sacherjj



Co-authored-by: Joe Sacher <[email protected]>
  • Loading branch information
casperlabs-bors-ng[bot] and sacherjj authored Jul 28, 2021
2 parents 5e0216b + 7110c2a commit 6debc2a
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 17 deletions.
40 changes: 30 additions & 10 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ steps:
- name: docker_sock
path: /var/run/docker.sock

- name: build-rpm
image: casperlabs/rpm-package
commands:
- cargo rpm build -v

volumes:
- name: docker_sock
host:
Expand Down Expand Up @@ -99,16 +104,6 @@ steps:
commands:
- cargo deb

- name: publish-bintray
image: casperlabs/casper-node-launcher-build
commands:
- "./upload_to_bintray.sh --repo-name debian --package-name casper-node-launcher --package-tag true"
environment:
CL_VAULT_TOKEN:
from_secret: vault_token
CL_VAULT_HOST:
from_secret: vault_host

- name: publish-repo-prod
image: casperlabs/aptly:latest
failure: ignore
Expand Down Expand Up @@ -156,6 +151,31 @@ steps:
DOCKER_PASSWORD:
from_secret: docker_password

- name: build-rpm
image: casperlabs/rpm-package
commands:
- cargo rpm build -v


- name: publish-github-release
image: plugins/github-release
settings:
api_key:
from_secret: github_token
checksum:
- sha256
- md5
files:
- "./target/debian/*.deb"
- "./target/release/rpmbuild/RPMS/x86_64/*.rpm"
prerelease:
- true
when:
ref:
- refs/tags/v*

# Need to attach rpm to github artifacts.

volumes:
- name: docker_sock
host:
Expand Down
104 changes: 104 additions & 0 deletions .rpm/casper-node-launcher.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
BuildRequires: systemd-rpm-macros
Requires: curl
%define __spec_install_post %{nil}
%define __os_install_post %{_dbpath}/brp-compress
%define debug_package %{nil}

Name: casper-node-launcher
Summary: A binary which runs and upgrades the casper-node of the Casper network
Version: @@VERSION@@
Release: @@RELEASE@@%{?dist}
License: CasperLabs Open Source License (COSL)
Group: Applications/System
Source0: %{name}-%{version}.tar.gz
URL: https://casperlabs.io

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

%description
%{summary}

%prep
%setup -q

%pre
# Default Variables
# ---
DEFAULT_USERNAME="casper"
DEFAULT_CONFIG_DIRECTORY="/etc/${DEFAULT_USERNAME}"
DEFAULT_DATA_DIRECTORY="/var/lib/${DEFAULT_USERNAME}/bin"
DEFAULT_LOG_DIRECOTRY="/var/log/${DEFAULT_USERNAME}"

# Creation of Files/Directories
# ---
# Assure DEFAULT_DATA_DIRECTORY is available for state data
if [ -d ${DEFAULT_DATA_DIRECTORY} ] ; then
echo "Directory ${DEFAULT_DATA_DIRECTORY} already exists."
else
mkdir -p ${DEFAULT_DATA_DIRECTORY}
fi

# Assure DEFAULT_CONFIG_DIRECTORY is available for config data
if [ -d ${DEFAULT_CONFIG_DIRECTORY} ] ; then
echo "Directory ${DEFAULT_CONFIG_DIRECTORY} already exists."
else
mkdir -p ${DEFAULT_CONFIG_DIRECTORY}
fi

# Assure DEFAULT_LOG_DIRECOTRY is available for logging
if [ -d ${DEFAULT_LOG_DIRECOTRY} ] ; then
echo "Directory ${DEFAULT_LOG_DIRECOTRY} already exists."
else
mkdir -p ${DEFAULT_LOG_DIRECOTRY}
fi
exit 0

%post
# Default Variables
# ---
DEFAULT_USERNAME="casper"
DEFAULT_CONFIG_DIRECTORY="/etc/${DEFAULT_USERNAME}"
DEFAULT_DATA_DIRECTORY="/var/lib/${DEFAULT_USERNAME}"
DEFAULT_LOG_DIRECOTRY="/var/log/${DEFAULT_USERNAME}"

# User Creation
# ---
# Assure DEFAULT_USERNAME user exists
getent group casper >/dev/null || groupadd -r casper
getent passwd casper >/dev/null || \
useradd -r -g casper -s /sbin/nologin \
-c "User for running casper-node-launcher" casper

# Take ownership of directories and files installed
chown -R ${DEFAULT_USERNAME}:${DEFAULT_USERNAME} ${DEFAULT_DATA_DIRECTORY}
chown -R ${DEFAULT_USERNAME}:${DEFAULT_USERNAME} ${DEFAULT_CONFIG_DIRECTORY}
chown -R ${DEFAULT_USERNAME}:${DEFAULT_USERNAME} ${DEFAULT_LOG_DIRECOTRY}

# Update systemd for unit file
systemctl daemon-reload

exit 0


%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
cp -a * %{buildroot}

%clean
rm -rf %{buildroot}

%files
%defattr(-,casper,casper,-)
%{_bindir}/*
/var/lib/casper/bin/README.md
/etc/logrotate.d/casper-node
/etc/casper/PLATFORM
/etc/casper/pull_casper_node_version.sh
/etc/casper/network_configs/casper.conf
/etc/casper/network_configs/casper-test.conf
/etc/casper/delete_local_db.sh
/etc/casper/config_from_example.sh
/etc/casper/README.md
/etc/casper/validator_keys/README.md
/etc/systemd/system/casper-node-launcher.service
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "casper-node-launcher"
version = "0.3.3"
version = "0.3.4"
authors = ["Fraser Hutchison <[email protected]>", "Joe Sacher <[email protected]>"]
edition = "2018"
description = "A binary which runs and upgrades the casper-node of the Casper network"
readme = "README.md"
documentation = "https://docs.rs/casper-node-launcher"
homepage = "https://casperlabs.io"
homepage = "https://casper.network"
repository = "https://github.com/CasperLabs/casper-node/tree/master/client"
license-file = "./LICENSE"

Expand Down Expand Up @@ -35,11 +35,12 @@ assets = [
["./target/release/casper-node-launcher", "/usr/bin/casper-node-launcher", "755"],
["./resources/BIN_README.md", "/var/lib/casper/bin/README.md", "755"],
["./resources/maintainer_scripts/logrotate.d/casper-node", "/etc/logrotate.d/casper-node", "644"],
["./resources/PLATFORM_DEB", "/etc/casper/PLATFORM", "644"],
["./resources/maintainer_scripts/pull_casper_node_version.sh", "/etc/casper/pull_casper_node_version.sh", "755"],
["./resources/maintainer_scripts/network_configs/*", "/etc/casper/network_configs/", "644"],
["./resources/maintainer_scripts/delete_local_db.sh", "/etc/casper/delete_local_db.sh", "755"],
["./resources/maintainer_scripts/config_from_example.sh", "/etc/casper/config_from_example.sh", "755"],
["./resources/DEB_README.md", "/etc/casper/README.md", "644"],
["./resources/ETC_README.md", "/etc/casper/README.md", "644"],
["./resources/VALIDATOR_KEYS_README.md", "/etc/casper/validator_keys/README.md", "644"]
]
maintainer-scripts = "./resources/maintainer_scripts/debian"
Expand All @@ -52,3 +53,27 @@ For information on using package, see https://github.com/CasperLabs/casper-node-
[package.metadata.deb.systemd-units]
unit-scripts = "./resources/maintainer_scripts/casper_node_launcher"
restart-after-upgrade = false

[package.metadata.rpm]
package = "casper-node-launcher"

[package.metadata.rpm.cargo]
buildflags = ["--release"]

[package.metadata.rpm.systemd-units]
unit-scripts = "./resources/maintainer_scripts/casper_node_launcher"
restart-after-upgrade = false

[package.metadata.rpm.targets]
casper-node-launcher = { path = "/usr/bin/casper-node-launcher" }
"../../resources/BIN_README.md" = {path = "/var/lib/casper/bin/README.md"}
"../../resources/PLATFORM_RPM" = {path = "/etc/casper/PLATFORM"}
"../../resources/maintainer_scripts/logrotate.d/casper-node" = {path = "/etc/logrotate.d/casper-node"}
"../../resources/maintainer_scripts/pull_casper_node_version.sh" = {path = "/etc/casper/pull_casper_node_version.sh"}
"../../resources/maintainer_scripts/network_configs/casper.conf" = {path = "/etc/casper/network_configs/casper.conf"}
"../../resources/maintainer_scripts/network_configs/casper-test.conf" = {path = "/etc/casper/network_configs/casper-test.conf"}
"../../resources/maintainer_scripts/delete_local_db.sh" = {path = "/etc/casper/delete_local_db.sh"}
"../../resources/maintainer_scripts/config_from_example.sh" = {path = "/etc/casper/config_from_example.sh"}
"../../resources/ETC_README.md" = {path = "/etc/casper/README.md"}
"../../resources/VALIDATOR_KEYS_README.md" = {path = "/etc/casper/validator_keys/README.md"}
"../../resources/maintainer_scripts/casper_node_launcher/casper-node-launcher.service" = {path = "/etc/systemd/system/casper-node-launcher.service"}
2 changes: 1 addition & 1 deletion resources/BIN_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This directory holds casper-node executables in semver folder using underscores.

example:

`casper-node` version `1.0.2` would exist as `./1_0_2/casper-node`
`casper-node` version `1.0.0` would exist as `./1_0_0/casper-node`
7 changes: 5 additions & 2 deletions resources/DEB_README.md → resources/ETC_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ To stop:
If you need to delete the db for a new run,
you can use the script in `/etc/casper` with `sudo /etc/casper/delete_local_db.sh`.

## Upgrading casper-node
## Staging casper-node protocols

Upgrading is done by staging a new casper-node and configuration prior to the agreed upgrade era.

To simplify this, the `sudo -u casper /etc/casper/pull_casper_node_version.sh [semver] [network]` script is included. This will
To simplify this, the `sudo -u casper /etc/casper/pull_casper_node_version.sh [network config] [semver]` script is included. This will
pull files from the appropriate version. If desired, the casper-node can be built from source at the
same version.

To get a working default config.toml for a protocol version: `sudo -u casper /etc/casper/config_from_example.sh [semver]`.


When the upgrade era occurs, the currently running casper-node will exit and casper-node-launcher will
start the new upgraded version of casper-node.

Expand Down
1 change: 1 addition & 0 deletions resources/PLATFORM_DEB
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deb
1 change: 1 addition & 0 deletions resources/PLATFORM_RPM
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rpm

0 comments on commit 6debc2a

Please sign in to comment.