Compare commits
23 Commits
build-peac
...
main
Author | SHA1 | Date | |
---|---|---|---|
d230ae9b13 | |||
fd57165c08 | |||
c2f079eb46 | |||
f320a570e3 | |||
757efb07cc | |||
f7e2efedde | |||
8342ce2a0c | |||
1facf38a69 | |||
059edf598b | |||
336fc9536a | |||
0907c07c97 | |||
6155e361b2 | |||
659b298249 | |||
9041352454 | |||
62c5096183 | |||
9fc95a78f0 | |||
7efce72f6e | |||
4f2c05276e | |||
2fcc95d7f9 | |||
|
75275bc5ca | ||
|
601b302b02 | ||
|
a2cf650774 | ||
|
3940782bdb |
@ -1,4 +1,4 @@
|
||||
Package: peach-go-sbot
|
||||
Package: go-sbot
|
||||
Version: {{version}}
|
||||
Architecture: all
|
||||
Maintainer: Andrew Reid <gnomad@cryptolab.net>
|
20
conf/templates/peach_go_sbot/DEBIAN/postinst → conf/templates/go_sbot/DEBIAN/postinst
Executable file → Normal file
20
conf/templates/peach_go_sbot/DEBIAN/postinst → conf/templates/go_sbot/DEBIAN/postinst
Executable file → Normal file
@ -2,26 +2,30 @@
|
||||
set -e
|
||||
|
||||
# create user which go-sbot runs as
|
||||
adduser --quiet --system peach-go-sbot
|
||||
id -u peach &>/dev/null || adduser --quiet peach
|
||||
|
||||
# set permissions
|
||||
chown peach-go-sbot /usr/bin/go-sbot
|
||||
chown peach-go-sbot /usr/bin/sbotcli
|
||||
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
|
||||
|
||||
# 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 peach-go-sbot.service >/dev/null || true
|
||||
deb-systemd-helper unmask go-sbot.service >/dev/null || true
|
||||
|
||||
# was-enabled defaults to true, so new installations run enable.
|
||||
if deb-systemd-helper --quiet was-enabled peach-go-sbot.service; then
|
||||
if deb-systemd-helper --quiet was-enabled 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 peach-go-sbot.service >/dev/null || true
|
||||
deb-systemd-helper enable 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 peach-go-sbot.service >/dev/null || true
|
||||
deb-systemd-helper update-state go-sbot.service >/dev/null || true
|
||||
fi
|
||||
fi
|
||||
# End automatically added section
|
||||
@ -34,7 +38,7 @@ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-decon
|
||||
else
|
||||
_dh_action=start
|
||||
fi
|
||||
deb-systemd-invoke $_dh_action peach-go-sbot.service >/dev/null || true
|
||||
deb-systemd-invoke $_dh_action go-sbot.service >/dev/null || true
|
||||
fi
|
||||
fi
|
||||
# End automatically added section
|
6
conf/templates/peach_go_sbot/DEBIAN/postrm → conf/templates/go_sbot/DEBIAN/postrm
Executable file → Normal file
6
conf/templates/peach_go_sbot/DEBIAN/postrm → conf/templates/go_sbot/DEBIAN/postrm
Executable file → Normal 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 peach-go-sbot.service >/dev/null || true
|
||||
deb-systemd-helper mask go-sbot.service >/dev/null || true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "purge" ]; then
|
||||
if [ -x "/usr/bin/deb-systemd-helper" ]; then
|
||||
deb-systemd-helper purge peach-go-sbot.service >/dev/null || true
|
||||
deb-systemd-helper unmask peach-go-sbot.service >/dev/null || true
|
||||
deb-systemd-helper purge go-sbot.service >/dev/null || true
|
||||
deb-systemd-helper unmask go-sbot.service >/dev/null || true
|
||||
fi
|
||||
fi
|
||||
# End automatically added section
|
2
conf/templates/peach_go_sbot/DEBIAN/prerm → conf/templates/go_sbot/DEBIAN/prerm
Executable file → Normal file
2
conf/templates/peach_go_sbot/DEBIAN/prerm → conf/templates/go_sbot/DEBIAN/prerm
Executable file → Normal file
@ -2,6 +2,6 @@
|
||||
set -e
|
||||
# Automatically added by cargo-deb
|
||||
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
|
||||
deb-systemd-invoke stop peach-go-sbot.service >/dev/null || true
|
||||
deb-systemd-invoke stop go-sbot.service >/dev/null || true
|
||||
fi
|
||||
# End automatically added section
|
15
conf/templates/go_sbot/config.toml
Normal file
15
conf/templates/go_sbot/config.toml
Normal file
@ -0,0 +1,15 @@
|
||||
# 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
|
@ -1,9 +1,10 @@
|
||||
[Unit]
|
||||
Description=peachs go-sbot
|
||||
Description=peachcloud go-sbot
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=peach-go-sbot
|
||||
User=peach
|
||||
Environment="LIBRARIAN_WRITEALL=0"
|
||||
ExecStart=/usr/bin/go-sbot
|
||||
Restart=always
|
||||
|
@ -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
|
||||
PEACH_GO_SBOT_VERSION = '0.1.4'
|
||||
GO_SBOT_VERSION = '0.1.25'
|
||||
|
||||
# constants
|
||||
DEB_CONF_DIR = os.path.join(PROJECT_PATH, 'conf/templates/peach_go_sbot')
|
||||
DEB_BUILD_DIR = "/tmp/peach_go_sbot"
|
||||
DEB_CONF_DIR = os.path.join(PROJECT_PATH, 'conf/templates/go_sbot')
|
||||
DEB_BUILD_DIR = "/tmp/go_sbot"
|
||||
GO_SSB_DIR = "/srv/peachcloud/automation/go-ssb"
|
||||
|
||||
|
||||
def crosscompile_peach_go_sbot():
|
||||
def crosscompile_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_peach_go_sbot():
|
||||
subprocess.check_call(["env", "GOOS=linux", "GOARCH=arm64", "go", "build", "./cmd/go-sbot"], cwd=GO_SSB_DIR)
|
||||
|
||||
|
||||
def package_peach_go_sbot(version):
|
||||
print("[ PACKAGING peach-go-sbot ]")
|
||||
def package_go_sbot(version):
|
||||
print("[ PACKAGING 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_peach_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("peach_go_sbot/DEBIAN/control")
|
||||
src = os.path.join("go_sbot/DEBIAN/control")
|
||||
dest = os.path.join(DEBIAN_DEST_DIR, "control")
|
||||
render_template(src=src, dest=dest, template_vars={"version": version})
|
||||
|
||||
@ -51,8 +51,16 @@ def package_peach_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, 'peach-go-sbot.service'),
|
||||
os.path.join(SERVICE_DIR, 'peach-go-sbot.service')
|
||||
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')
|
||||
)
|
||||
|
||||
# copy cross-compiled binaries
|
||||
@ -68,7 +76,7 @@ def package_peach_go_sbot(version):
|
||||
subprocess.check_call(["chmod", "770", destination])
|
||||
|
||||
# create deb package
|
||||
deb_file_name = "peach-go-sbot_{}_arm64.deb".format(version)
|
||||
deb_file_name = "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)
|
||||
|
||||
@ -83,22 +91,22 @@ def package_peach_go_sbot(version):
|
||||
update_freight_cache()
|
||||
|
||||
|
||||
def build_peach_go_sbot():
|
||||
def build_go_sbot():
|
||||
|
||||
# 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))
|
||||
# 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))
|
||||
|
||||
# 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 peach-go-sbot with new version number
|
||||
crosscompile_peach_go_sbot()
|
||||
package_peach_go_sbot(version=version)
|
||||
# cross-compile and package go-sbot with new version number
|
||||
crosscompile_go_sbot()
|
||||
package_go_sbot(version=version)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
build_peach_go_sbot()
|
||||
build_go_sbot()
|
||||
|
@ -1,7 +1,6 @@
|
||||
import argparse
|
||||
|
||||
from peach_package_builder.build_rust_packages import build_rust_packages
|
||||
from peach_package_builder.build_peach_config import build_peach_config
|
||||
|
||||
|
||||
def build_packages(default_branch=False, package=None):
|
||||
@ -10,13 +9,11 @@ def build_packages(default_branch=False, package=None):
|
||||
:param default_branch: checks out main git branch if True
|
||||
:param package: if provided, only builds this package
|
||||
"""
|
||||
if package:
|
||||
print("[ BUILDING ONLY {} ]".format(package))
|
||||
build_rust_packages(default_branch=default_branch, package=package)
|
||||
# only build peach-config if no package argument was provided or if peach-config is what is being built
|
||||
if not package or package == 'peach-config':
|
||||
build_peach_config(default_branch=default_branch)
|
||||
print("[ MICROSERVICE PACKAGE ARCHIVE UPDATED ]")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
@ -28,7 +25,9 @@ if __name__ == '__main__':
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--package",
|
||||
help="Ensure default branch for all repos for build",
|
||||
help="Optionally specify package to build",
|
||||
required=False,
|
||||
default=None
|
||||
)
|
||||
args = parser.parse_args()
|
||||
build_packages(default_branch=args.default, package=args.package)
|
@ -1,73 +0,0 @@
|
||||
"""
|
||||
script to build the peach-config debian module and add it to the freight repository
|
||||
"""
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
|
||||
from peach_package_builder.constants import *
|
||||
from peach_package_builder.utils import add_deb_to_freight, update_freight_cache
|
||||
|
||||
|
||||
def get_version_from_setup_file(file_path):
|
||||
with open(file_path, 'r') as f:
|
||||
lines = f.read().splitlines()
|
||||
for line in lines:
|
||||
match = re.match('.*version = "(\S+)",', line)
|
||||
if match:
|
||||
version = match.group(1)
|
||||
return version
|
||||
# if a version wasn't found then raise an exception
|
||||
raise Exception("version not found")
|
||||
|
||||
|
||||
def build_peach_config(default_branch=True):
|
||||
service_path = os.path.join(MICROSERVICES_SRC_DIR, "peach-config")
|
||||
if default_branch:
|
||||
# because some repo have main as default and some as master, we get the default
|
||||
default_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'origin/HEAD'],
|
||||
cwd=service_path).decode(sys.stdout.encoding).strip()
|
||||
branch = default_branch.replace('origin/', '')
|
||||
subprocess.check_call(["git", "checkout", branch], cwd=service_path)
|
||||
subprocess.check_call(["git", "fetch", "--all"], cwd=service_path)
|
||||
subprocess.check_call(["git", "reset", "--hard", default_branch], cwd=service_path)
|
||||
# remove old build dir
|
||||
subprocess.check_call([
|
||||
"rm",
|
||||
"-rf",
|
||||
os.path.join(service_path, 'deb_dist')
|
||||
])
|
||||
# build .deb
|
||||
subprocess.check_call([
|
||||
"python3",
|
||||
"setup.py",
|
||||
"--command-packages=stdeb.command",
|
||||
"bdist_deb"
|
||||
],
|
||||
cwd=service_path)
|
||||
# get version number of peach-config from setup.py file
|
||||
setup_file = os.path.join(service_path, 'setup.py')
|
||||
version = get_version_from_setup_file(setup_file)
|
||||
# build the deb
|
||||
deb_name = "python3-peach-config_{version}-1_all.deb".format(version=version)
|
||||
debian_package_path = os.path.join(
|
||||
service_path,
|
||||
"deb_dist/{}".format(deb_name)
|
||||
)
|
||||
subprocess.check_call(["cp", debian_package_path, MICROSERVICES_DEB_DIR])
|
||||
add_deb_to_freight(package_name=debian_package_path, package_path=debian_package_path)
|
||||
update_freight_cache()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"-d",
|
||||
"--default",
|
||||
help="Ensure default branch for all repos for build",
|
||||
action="store_true"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
build_peach_config(default_branch=args.default)
|
@ -4,7 +4,6 @@ import argparse
|
||||
import sys
|
||||
import os
|
||||
|
||||
from peach_package_builder.build_peach_config import build_peach_config
|
||||
from peach_package_builder.constants import *
|
||||
from peach_package_builder.utils import add_deb_to_freight, update_freight_cache
|
||||
|
||||
@ -27,47 +26,57 @@ def build_rust_packages(default_branch=False, package=None):
|
||||
:param package: if provided, only builds this package
|
||||
"""
|
||||
print("[ BUILDING AND UPDATING RUST MICROSERVICE PACKAGES ]")
|
||||
# if package argument was provided, then only build that one package, otherwise build all packages
|
||||
if package:
|
||||
services = filter(lambda s: s["name"] == package, SERVICES)
|
||||
else:
|
||||
services = SERVICES
|
||||
for service in services:
|
||||
service_name = service["name"]
|
||||
service_path = os.path.join(MICROSERVICES_SRC_DIR, service_name)
|
||||
print("[ BUILIDING SERVICE {} ]".format(service_name))
|
||||
# this arg ensures we build the default branch, otherwise we build what ever is found locally
|
||||
if default_branch:
|
||||
remote_branch = 'origin/main'
|
||||
branch = 'main'
|
||||
subprocess.check_call(["git", "reset", "HEAD", "--hard"])
|
||||
subprocess.check_call(["git", "checkout", branch], cwd=service_path)
|
||||
subprocess.check_call(["git", "fetch", "--all"], cwd=service_path)
|
||||
subprocess.check_call(["git", "reset", "--hard", remote_branch], cwd=service_path)
|
||||
debian_package_path = subprocess.check_output(
|
||||
[
|
||||
CARGO_PATH,
|
||||
"deb",
|
||||
"--target",
|
||||
"aarch64-unknown-linux-gnu"],
|
||||
cwd=service_path).decode("utf-8").strip()
|
||||
subprocess.call(["cp", debian_package_path, MICROSERVICES_DEB_DIR])
|
||||
|
||||
# add deb to freight
|
||||
package_name = os.path.basename(debian_package_path)
|
||||
add_deb_to_freight(package_name=package_name, package_path=debian_package_path)
|
||||
build_peach_workspace_rust_packages(default_branch=default_branch, package=package)
|
||||
|
||||
# update freight cache
|
||||
update_freight_cache()
|
||||
|
||||
|
||||
def build_packages(default_branch=False):
|
||||
def build_peach_workspace_rust_packages(default_branch=False, package=None):
|
||||
print("[ BUILDING AND UPDATING PEACH WORKSPACE RUST PACKAGES ]")
|
||||
|
||||
# this arg ensures we build the default branch, otherwise we build what ever is found locally
|
||||
if default_branch:
|
||||
remote_branch = 'origin/main'
|
||||
branch = 'main'
|
||||
subprocess.check_call(["git", "reset", "HEAD", "--hard"])
|
||||
subprocess.check_call(["git", "checkout", branch], cwd=WORKSPACE_SRC_DIR)
|
||||
subprocess.check_call(["git", "fetch", "--all"], cwd=WORKSPACE_SRC_DIR)
|
||||
subprocess.check_call(["git", "reset", "--hard", remote_branch], cwd=WORKSPACE_SRC_DIR)
|
||||
|
||||
# if package argument was provided, then only build that one package, otherwise build all packages
|
||||
if package:
|
||||
services = filter(lambda s: s["name"] == package, SERVICES)
|
||||
else:
|
||||
services = SERVICES
|
||||
|
||||
# iterate through crates and build
|
||||
for service in services:
|
||||
service_name = service["name"]
|
||||
service_path = os.path.join(WORKSPACE_SRC_DIR, service_name)
|
||||
build_rust_package(service_path, service_name)
|
||||
|
||||
|
||||
def build_rust_package(service_path, service_name):
|
||||
"""
|
||||
builds all PeachCloud microservices as .deb files and adds them to the freight repo
|
||||
this function builds a specific service and adds the deb to the deb dir
|
||||
:param service_path: string path to where the package src code is
|
||||
:param service_name: string name of the service
|
||||
:return:
|
||||
"""
|
||||
build_rust_packages(default_branch=default_branch)
|
||||
build_peach_config(default_branch=default_branch)
|
||||
print("[ MICROSERVICE PACKAGE ARCHIVE UPDATED ]")
|
||||
print("[ BUILIDING SERVICE {} ]".format(service_name))
|
||||
debian_package_path = subprocess.check_output(
|
||||
[
|
||||
CARGO_PATH,
|
||||
"deb",
|
||||
"--target",
|
||||
"aarch64-unknown-linux-gnu"],
|
||||
cwd=service_path).decode("utf-8").strip()
|
||||
subprocess.call(["cp", debian_package_path, MICROSERVICES_DEB_DIR])
|
||||
|
||||
# add deb to freight
|
||||
package_name = os.path.basename(debian_package_path)
|
||||
add_deb_to_freight(package_name=package_name, package_path=debian_package_path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -78,5 +87,12 @@ if __name__ == '__main__':
|
||||
help="Ensure default branch for all repos for build",
|
||||
action="store_true"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--package",
|
||||
help="Optionally specify package to build",
|
||||
required=False,
|
||||
default=None
|
||||
)
|
||||
args = parser.parse_args()
|
||||
build_packages(default_branch=args.default)
|
||||
build_rust_packages(default_branch=args.default, package=args.package)
|
105
peach_package_builder/build_yunohost_binaries.py
Normal file
105
peach_package_builder/build_yunohost_binaries.py
Normal file
@ -0,0 +1,105 @@
|
||||
"""
|
||||
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)
|
@ -13,23 +13,18 @@ AUTOMATION_DIR = "/srv/peachcloud/automation"
|
||||
FREIGHT_CONF = "/etc/freight.conf"
|
||||
FREIGHT_LIB = "/var/lib/freight"
|
||||
FREIGHT_CACHE = "/var/www/apt.peachcloud.org"
|
||||
MICROSERVICES_SRC_DIR = "/srv/peachcloud/automation/microservices"
|
||||
WORKSPACE_SRC_DIR = "/srv/peachcloud/automation/peach-workspace"
|
||||
MICROSERVICES_DEB_DIR = "/srv/peachcloud/debs"
|
||||
USER_PATH = "/home/rust"
|
||||
CARGO_PATH = os.path.join(USER_PATH, ".cargo/bin/cargo")
|
||||
|
||||
SERVICES = [
|
||||
{"name": "peach-buttons",
|
||||
"repo_url": "https://github.com/peachcloud/peach-buttons.git"},
|
||||
{"name": "peach-menu", "repo_url": "https://github.com/peachcloud/peach-menu.git"},
|
||||
{"name": "peach-monitor",
|
||||
"repo_url": "https://github.com/peachcloud/peach-monitor.git"},
|
||||
{"name": "peach-network",
|
||||
"repo_url": "https://github.com/peachcloud/peach-network.git"},
|
||||
{"name": "peach-oled", "repo_url": "https://github.com/peachcloud/peach-oled.git"},
|
||||
{"name": "peach-stats", "repo_url": "https://github.com/peachcloud/peach-stats.git"},
|
||||
{"name": "peach-probe", "repo_url": "https://github.com/peachcloud/peach-probe.git"},
|
||||
{"name": "peach-dyndns-updater", "repo_url": "https://github.com/peachcloud/peach-dyndns-updater.git"},
|
||||
{"name": "peach-web", "repo_url": "https://github.com/peachcloud/peach-web.git"},
|
||||
{"name": "peach-tbot", "repo_url": "https://github.com/peachcloud/peach-tbot.git"},
|
||||
# peach-probe is disabled until it is fixed
|
||||
# {"name": "peach-probe", "repo_url": "https://git.coopcloud.tech/PeachCloud/peach-workspace.git"},
|
||||
{"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"},
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user