Compare commits

..

No commits in common. "main" and "peach-menu" have entirely different histories.

9 changed files with 33 additions and 168 deletions

View File

@ -1,15 +0,0 @@
# For details about go-sbot configuration, please visit the repo: https://github.com/cryptoscope/ssb
repo = "/home/peach/.ssb-go"
debugdir = ""
shscap = "1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s="
hmac = ""
hops = 2
lis = "127.0.0.1:8008"
wslis = ":8987"
debuglis = "localhost:6078"
localadv = true
localdiscov = true
enable_ebt = true
promisc = true
nounixsock = false
repair = true

View File

@ -1,4 +1,4 @@
Package: go-sbot
Package: peach-go-sbot
Version: {{version}}
Architecture: all
Maintainer: Andrew Reid <gnomad@cryptolab.net>

View File

@ -2,30 +2,26 @@
set -e
# create user which go-sbot runs as
id -u peach &>/dev/null || adduser --quiet peach
adduser --quiet --system peach-go-sbot
# set permissions
chown peach /usr/bin/go-sbot
chown peach /usr/bin/sbotcli
# create and set permissions for /home/peach/.ssb-go
mkdir -p /home/peach/.ssb-go
chown -R peach:peach /home/peach/.ssb-go
chown peach-go-sbot /usr/bin/go-sbot
chown peach-go-sbot /usr/bin/sbotcli
# Automatically added by cargo-deb
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 go-sbot.service >/dev/null || true
deb-systemd-helper unmask peach-go-sbot.service >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled go-sbot.service; then
if deb-systemd-helper --quiet was-enabled peach-go-sbot.service; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable go-sbot.service >/dev/null || true
deb-systemd-helper enable peach-go-sbot.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 go-sbot.service >/dev/null || true
deb-systemd-helper update-state peach-go-sbot.service >/dev/null || true
fi
fi
# End automatically added section
@ -38,7 +34,7 @@ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-decon
else
_dh_action=start
fi
deb-systemd-invoke $_dh_action go-sbot.service >/dev/null || true
deb-systemd-invoke $_dh_action peach-go-sbot.service >/dev/null || true
fi
fi
# End automatically added section

View File

@ -8,14 +8,14 @@ fi
# Automatically added by cargo-deb
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask go-sbot.service >/dev/null || true
deb-systemd-helper mask peach-go-sbot.service >/dev/null || true
fi
fi
if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge go-sbot.service >/dev/null || true
deb-systemd-helper unmask go-sbot.service >/dev/null || true
deb-systemd-helper purge peach-go-sbot.service >/dev/null || true
deb-systemd-helper unmask peach-go-sbot.service >/dev/null || true
fi
fi
# End automatically added section

View File

@ -2,6 +2,6 @@
set -e
# Automatically added by cargo-deb
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
deb-systemd-invoke stop go-sbot.service >/dev/null || true
deb-systemd-invoke stop peach-go-sbot.service >/dev/null || true
fi
# End automatically added section

View File

@ -1,10 +1,9 @@
[Unit]
Description=peachcloud go-sbot
Description=peachs go-sbot
[Service]
Type=simple
User=peach
Environment="LIBRARIAN_WRITEALL=0"
User=peach-go-sbot
ExecStart=/usr/bin/go-sbot
Restart=always

View File

@ -14,15 +14,15 @@ from peach_package_builder.constants import *
from peach_package_builder.utils import render_template, add_deb_to_freight, update_freight_cache
# manually update this version when we want to build a new peach-go-sbot package
GO_SBOT_VERSION = '0.1.25'
PEACH_GO_SBOT_VERSION = '0.1.4'
# constants
DEB_CONF_DIR = os.path.join(PROJECT_PATH, 'conf/templates/go_sbot')
DEB_BUILD_DIR = "/tmp/go_sbot"
DEB_CONF_DIR = os.path.join(PROJECT_PATH, 'conf/templates/peach_go_sbot')
DEB_BUILD_DIR = "/tmp/peach_go_sbot"
GO_SSB_DIR = "/srv/peachcloud/automation/go-ssb"
def crosscompile_go_sbot():
def crosscompile_peach_go_sbot():
subprocess.check_call(["git", "pull"], cwd=GO_SSB_DIR)
print("[CROSS-COMPILING sbotcli]")
subprocess.check_call(["env", "GOOS=linux", "GOARCH=arm64", "go", "build", "./cmd/sbotcli"], cwd=GO_SSB_DIR)
@ -30,8 +30,8 @@ def crosscompile_go_sbot():
subprocess.check_call(["env", "GOOS=linux", "GOARCH=arm64", "go", "build", "./cmd/go-sbot"], cwd=GO_SSB_DIR)
def package_go_sbot(version):
print("[ PACKAGING go-sbot ]")
def package_peach_go_sbot(version):
print("[ PACKAGING peach-go-sbot ]")
# copy debian conf files into correct locations in package build directory
DEBIAN_SRC_DIR = os.path.join(DEB_CONF_DIR, 'DEBIAN')
DEBIAN_DEST_DIR = os.path.join(DEB_BUILD_DIR, 'DEBIAN')
@ -43,7 +43,7 @@ def package_go_sbot(version):
shutil.copyfile(src, dest)
subprocess.check_call(["chmod", "775", dest])
# copy control file putting in correct version number
src = os.path.join("go_sbot/DEBIAN/control")
src = os.path.join("peach_go_sbot/DEBIAN/control")
dest = os.path.join(DEBIAN_DEST_DIR, "control")
render_template(src=src, dest=dest, template_vars={"version": version})
@ -51,16 +51,8 @@ def package_go_sbot(version):
SERVICE_DIR = os.path.join(DEB_BUILD_DIR, 'lib/systemd/system')
os.makedirs(SERVICE_DIR)
shutil.copyfile(
os.path.join(DEB_CONF_DIR, 'go-sbot.service'),
os.path.join(SERVICE_DIR, 'go-sbot.service')
)
# copy go-sbot config.toml
SBOT_CONFIG_DIR = os.path.join(DEB_BUILD_DIR, 'home/peach/.ssb-go')
os.makedirs(SBOT_CONFIG_DIR)
shutil.copyfile(
os.path.join(DEB_CONF_DIR, 'config.toml'),
os.path.join(SBOT_CONFIG_DIR, 'config.toml')
os.path.join(DEB_CONF_DIR, 'peach-go-sbot.service'),
os.path.join(SERVICE_DIR, 'peach-go-sbot.service')
)
# copy cross-compiled binaries
@ -76,7 +68,7 @@ def package_go_sbot(version):
subprocess.check_call(["chmod", "770", destination])
# create deb package
deb_file_name = "go-sbot_{}_arm64.deb".format(version)
deb_file_name = "peach-go-sbot_{}_arm64.deb".format(version)
print("[ CREATING {}]".format(deb_file_name))
subprocess.check_call(["dpkg-deb", "-b", ".", deb_file_name], cwd=DEB_BUILD_DIR)
@ -91,22 +83,22 @@ def package_go_sbot(version):
update_freight_cache()
def build_go_sbot():
def build_peach_go_sbot():
# gets the most recently built go_sbot version, and increments the micro-number by 1
version = GO_SBOT_VERSION
print("[ BUILDING GO-SBOT VERSION {}]".format(version))
# gets the most recently built peach_go_sbot version, and increments the micro-number by 1
version = PEACH_GO_SBOT_VERSION
print("[ BUILDING PEACH-GO-SBOT VERSION {}]".format(version))
# delete build directory if it already exists or create it
subprocess.check_call(["rm", "-rf", DEB_BUILD_DIR])
if not os.path.exists(DEB_BUILD_DIR):
os.makedirs(DEB_BUILD_DIR)
# cross-compile and package go-sbot with new version number
crosscompile_go_sbot()
package_go_sbot(version=version)
# cross-compile and package peach-go-sbot with new version number
crosscompile_peach_go_sbot()
package_peach_go_sbot(version=version)
if __name__ == '__main__':
build_go_sbot()
build_peach_go_sbot()

View File

@ -1,105 +0,0 @@
"""
script to cross-compile PeachCloud packages for arm64 and other architectures
"""
import subprocess
from peach_package_builder.constants import *
from peach_package_builder.build_go_sbot import GO_SBOT_VERSION, GO_SSB_DIR
# constants
PEACHCLOUD_VERSION = "1.0"
PROJECT_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
RUST_WORKSPACE_DIR = WORKSPACE_SRC_DIR
BINARIES_DIR = "/srv/files.commoninternet.net/binaries"
PEACH_WORKSPACE_GIT_URL = "https://git.coopcloud.tech/PeachCloud/peach-workspace"
GO_SBOT_GIT_URL = "https://github.com/cryptoscope/ssb.git"
OUTPUT_DIR = "/srv/files.commoninternet.net"
def pull_go_repo():
if not os.path.exists(GO_SSB_DIR):
subprocess.check_call(["git", "clone", GO_SBOT_GIT_URL, GO_SSB_DIR])
else:
subprocess.check_call(["git", "pull"], cwd=GO_SSB_DIR)
def crosscompile_go_sbot(architecture, binaries_dir):
subprocess.check_call(["git", "pull"], cwd=GO_SSB_DIR)
if architecture == "arm7":
base_cmd = ["env", "CGO_ENABLED=1", "CC=arm-linux-gnueabi-gcc",
"GOOS=linux",
"GOARCH=arm", "GOARM=7", "go", "build"]
else:
base_cmd = ["env", "GOOS=linux", "GOARCH={}".format(architecture), "go", "build"]
print("[CROSS-COMPILING sbotcli]")
cmd = base_cmd + ["./cmd/sbotcli"]
subprocess.check_call(cmd, cwd=GO_SSB_DIR)
print("[CROSS-COMPILING go-sbot]")
cmd = base_cmd + ["./cmd/go-sbot"]
subprocess.check_call(cmd, cwd=GO_SSB_DIR)
for binary in ["sbotcli", "go-sbot"]:
binary_path = os.path.join(GO_SSB_DIR, binary)
output_path = os.path.join(binaries_dir, binary)
print("[COPYING {} TO {}]".format(binary_path, output_path))
subprocess.check_call(["cp", binary_path, output_path])
def build_rust_binary(service_name, binaries_dir, target="aarch64-unknown-linux-gnu"):
"""
this function builds a specific binary
:param service_name: string name of the service
:param target: architecture to build for
:return:
"""
print("[ BUILIDING SERVICE {} ]".format(service_name))
service_path = os.path.join(RUST_WORKSPACE_DIR, service_name)
subprocess.check_output(
[
CARGO_PATH,
"build",
"--release",
"--target",
target],
cwd=service_path).decode("utf-8").strip()
binary_path = os.path.join(RUST_WORKSPACE_DIR, "target/{}/release/{}".format(target, service_name))
output_path = os.path.join(binaries_dir, service_name)
print("[ COPYING {} TO {} ]".format(binary_path, output_path))
subprocess.call(["cp", binary_path, output_path])
def publish(binaries_dir, architecture):
subprocess.check_call(["mkdir", "-p", OUTPUT_DIR])
binaries = ["peach-web", "peach-config", "go-sbot", "sbotcli"]
output_folder_name = "peachcloud_{}_Linux_{}".format(PEACHCLOUD_VERSION, architecture)
output_folder_path = os.path.join(OUTPUT_DIR, output_folder_name)
subprocess.check_call(["mkdir", "-p", output_folder_path])
for binary in binaries:
f_path = os.path.join(binaries_dir, binary)
output_path = os.path.join(output_folder_path, binary)
subprocess.check_call(["cp", f_path, output_path])
# copy static files for peach-web
peach_web_static_path = os.path.join(RUST_WORKSPACE_DIR, "peach-web/static")
output_static_path = os.path.join(binaries_dir, "static")
subprocess.check_call(["cp", "-r", peach_web_static_path, output_static_path])
# create a tar
tar_path = output_folder_path + ".tar.gz"
subprocess.check_call(["tar", "-czvf", tar_path, "-C", binaries_dir, "."], cwd=binaries_dir)
if __name__ == '__main__':
subprocess.check_call(["mkdir", "-p", OUTPUT_DIR])
subprocess.check_call(["mkdir", "-p", BINARIES_DIR])
pull_go_repo()
architectures = [
("aarch64-unknown-linux-gnu", "arm64", "aarch64"),
("x86_64-unknown-linux-gnu", "amd64", "amd64"),
("armv7-unknown-linux-gnueabihf", "arm7", "arm7"),
]
for rust_architecture, go_architecture, yunohost_architecture in architectures:
print("BUILDING WITH ARCHITECTURE {}, {}, {}".format(rust_architecture, go_architecture, yunohost_architecture))
binaries_dir = os.path.join(BINARIES_DIR, yunohost_architecture)
subprocess.check_call(["mkdir", "-p", binaries_dir])
crosscompile_go_sbot(architecture=go_architecture, binaries_dir=binaries_dir)
build_rust_binary("peach-web", target=rust_architecture, binaries_dir=binaries_dir)
build_rust_binary("peach-config", target=rust_architecture, binaries_dir=binaries_dir)
publish(binaries_dir=binaries_dir, architecture=yunohost_architecture)

View File

@ -24,7 +24,5 @@ SERVICES = [
{"name": "peach-dyndns-updater", "repo_url": "https://git.coopcloud.tech/PeachCloud/peach-workspace.git"},
{"name": "peach-web", "repo_url": "https://git.coopcloud.tech/PeachCloud/peach-workspace.git"},
{"name": "peach-menu", "repo_url": "https://git.coopcloud.tech/PeachCloud/peach-workspace.git"},
{"name": "peach-oled", "repo_url": "https://git.coopcloud.tech/PeachCloud/peach-workspace.git"},
{"name": "peach-buttons", "repo_url": "https://git.coopcloud.tech/PeachCloud/peach-workspace.git"},
{"name": "peach-config", "repo_url": "https://git.coopcloud.tech/PeachCloud/peach-workspace.git"},
]