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

ffsync: Update to syncstorage-rs #5942

Merged
merged 55 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
00a5b9d
Initial file reorganisation
mreid-tt Nov 26, 2023
cdbc21b
Include syncstorage-rs source
mreid-tt Nov 26, 2023
f016cfa
Migrate service scripts
mreid-tt Nov 27, 2023
4e5b5a6
Fix repo download path
mreid-tt Nov 27, 2023
8e9f713
Fix package name
mreid-tt Nov 27, 2023
16da8d9
Fix rust build args
mreid-tt Nov 27, 2023
4d86ff5
Amend rust build args
mreid-tt Nov 28, 2023
05adf10
Alternate fix for rust build args
mreid-tt Nov 28, 2023
167cafb
Initial fixes from review
mreid-tt Nov 28, 2023
988f41d
Split up wheels requirements
mreid-tt Nov 28, 2023
e639974
Fix wheels requirements
mreid-tt Nov 28, 2023
3175be5
Amend wheels requirements fix
mreid-tt Nov 28, 2023
0a6ff26
Framework: Add rust build args
mreid-tt Nov 29, 2023
1cd0026
Optimise python build
mreid-tt Nov 30, 2023
d092988
Testing build without rustc wheel directive
mreid-tt Nov 30, 2023
e8aab6b
Version bump and fixes for build
mreid-tt Nov 30, 2023
dbe9e55
Additional fixes for build
mreid-tt Nov 30, 2023
5ae59a9
Fixes for scripts and build
mreid-tt Dec 1, 2023
94bd900
Add password validation to wizards
mreid-tt Dec 1, 2023
18bf9f6
Testing build with self-contained dependencies
mreid-tt Dec 1, 2023
9d9b038
Update cross/syncstorage-rs/Makefile
hgy59 Dec 1, 2023
8f1e577
Remove duplicate ENV assignment
mreid-tt Dec 1, 2023
baecf94
Fix for mysqlclient dependencies
mreid-tt Dec 1, 2023
0926673
Amend fix for mysqlclient dependencies
mreid-tt Dec 1, 2023
dbe934c
add cross/diesel
hgy59 Dec 1, 2023
a4af41d
Minor fixes
mreid-tt Dec 1, 2023
318cdcb
cross/syncstorage-rs: fix build linker flags
hgy59 Dec 1, 2023
d318145
spk/ffsync: fix cross build of cryptography and library path
hgy59 Dec 1, 2023
4e8141c
ffsync: improve package installation
hgy59 Dec 1, 2023
640c611
Merge branch 'ffsync-update' of https://github.com/mreid-tt/spksrc in…
hgy59 Dec 1, 2023
027c038
service-setup: cleanup merge errors, provide tools and merge resources
hgy59 Dec 2, 2023
3915e90
Additional fixes
mreid-tt Dec 2, 2023
6dd3e83
Fix for build exclusions and uninstall
mreid-tt Dec 2, 2023
59a2238
Amendments to fixes
mreid-tt Dec 2, 2023
654e0b3
Amendments to fixes
mreid-tt Dec 2, 2023
81ec41c
Incorporating build suggestions
mreid-tt Dec 2, 2023
2aa2dd6
Testing build options
mreid-tt Dec 2, 2023
fc78bea
configure default mysql socket
hgy59 Dec 2, 2023
4445ad3
ffsync: use prebuilt python again and fix dependencies
hgy59 Dec 2, 2023
ebcf6de
fix host configuration
hgy59 Dec 2, 2023
a65b8b7
fix service-setup
hgy59 Dec 2, 2023
c9cef22
try to fix greenlet requirement
hgy59 Dec 2, 2023
65f37a5
fix mysql socket definition
hgy59 Dec 3, 2023
51f1647
fix secret generation for DSM 6
hgy59 Dec 3, 2023
aa24968
Fixes proposed after review
mreid-tt Dec 3, 2023
e4b972a
Final code cleanup
mreid-tt Dec 4, 2023
40f2b95
Amend code cleanup
mreid-tt Dec 4, 2023
0f59f43
Fix wizard grammar
mreid-tt Dec 4, 2023
f37ece2
Make clientUrl dynamic
mreid-tt Dec 4, 2023
0ac6601
Refine wizards
mreid-tt Dec 4, 2023
f6d87b2
Include USB export paths
mreid-tt Dec 4, 2023
f43d69c
Update package naming
mreid-tt Dec 6, 2023
108fa91
Escape parentheses in description
mreid-tt Dec 6, 2023
0c76c93
Remove quoting on description
mreid-tt Dec 6, 2023
17dffcd
Fix service setup formatting
mreid-tt Dec 6, 2023
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
27 changes: 27 additions & 0 deletions cross/syncstorage-rs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
PKG_NAME = syncstorage-rs
PKG_VERS = 0.14.1
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/mozilla-services/$(PKG_NAME)/archive/${PKG_VERS}
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)

DEPENDS =

# powerpc archs (except qoriq) are not supported
UNSUPPORTED_ARCHS += $(OLD_PPC_ARCHS)

HOMEPAGE = https://github.com/mozilla-services/syncstorage-rs/
COMMENT = Mozilla Sync Storage built with Rust.
LICENSE = https://github.com/mozilla-services/syncstorage-rs/blob/master/LICENSE

# Mandatory for rustc wheel building
ENV += PYO3_CROSS_LIB_DIR=$(STAGING_INSTALL_PREFIX)/lib/
ENV += PYO3_CROSS_INCLUDE_DIR=$(STAGING_INSTALL_PREFIX)/include/

# arguments to install the main server program
RUST_SRC_DIR = $(WORK_DIR)/$(PKG_DIR)/syncserver
CARGO_BUILD_ARGS += --no-default-features
CARGO_BUILD_ARGS += --features=syncstorage-db/mysql
CARGO_BUILD_ARGS += --locked

include ../../mk/spksrc.cross-rust.mk
3 changes: 3 additions & 0 deletions cross/syncstorage-rs/digests
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
syncstorage-rs-0.14.1.tar.gz SHA1 2b4fd69655caf646bed046fcc85db4ef844f0746
syncstorage-rs-0.14.1.tar.gz SHA256 224d8c4af114b0af4eebd90decef951a08dde1204c13caada416347aa5ebe35c
syncstorage-rs-0.14.1.tar.gz MD5 de9034fc2fcc5bcbccf9df5c0e86f405
5 changes: 5 additions & 0 deletions mk/spksrc.cross-rust.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ endif
CARGO_INSTALL_ARGS += --path $(RUST_SRC_DIR)
CARGO_INSTALL_ARGS += --root $(STAGING_INSTALL_PREFIX)

# Append additional install options if present
ifneq ($(strip $(CARGO_BUILD_ARGS)),)
CARGO_INSTALL_ARGS += $(CARGO_BUILD_ARGS)
endif

# Default build with rust and install with cargo
rust_install_target:
@echo " ==> Cargo install rust package $(PKG_NAME) ($(shell rustc --version); $(RUST_TOOLCHAIN))"
Expand Down
58 changes: 33 additions & 25 deletions spk/ffsync/Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
SPK_NAME = ffsync
SPK_VERS = 1.5.2
SPK_REV = 3
SPK_VERS = 0.14.1
SPK_REV = 4
mreid-tt marked this conversation as resolved.
Show resolved Hide resolved
SPK_ICON = src/ffsync.png
BETA = 1

BUILD_DEPENDS = cross/python2 cross/setuptools_py2 cross/pip_py2 cross/wheel
BUILD_DEPENDS += cross/gevent cross/greenlet cross/cffi
BUILD_DEPENDS = cross/curl cross/mysql-connector-c
DEPENDS = cross/syncstorage-rs

DEPENDS = cross/busybox
WHEELS = src/requirements.txt
PYTHON_PACKAGE = python311
WHEELS = src/requirements-crossenv.txt src/requirements-pure.txt

REQUIRED_MIN_DSM = 6.0
SPK_DEPENDS = MariaDB10:$(PYTHON_PACKAGE)

MAINTAINER = SynoCommunity
DESCRIPTION = Firefox Sync Server 1.5, used for Firefox 29 and later. You can use Firefox Sync Server to synchronize your bookmarks, passwords, settings, history, add-ons and tabs with Firefox on other computers. The service runs on port 8132.
DISPLAY_NAME = Firefox Sync Server 1.5
CHANGELOG = "1. Fix Python requirement<br>2. Fix startup issue when pidfile is not yet written"
CHANGELOG = "1. Upgrade to Mozilla Sync Storage built with Rust."

HOMEPAGE = https://docs.services.mozilla.com/howtos/run-sync-1.5.html
LICENSE = MPL/GPL/LGPL
HOMEPAGE = https://mozilla-services.readthedocs.io/en/latest/howtos/run-sync-1.5.html
LICENSE = MPL-2.0
HELPURL = https://github.com/SynoCommunity/spksrc/wiki/Firefox-Sync-Server-1.5
mreid-tt marked this conversation as resolved.
Show resolved Hide resolved

INSTALLER_SCRIPT = src/installer.sh
SSS_SCRIPT = src/dsm-control.sh
FWPORTS = src/${SPK_NAME}.sc
WIZARDS_DIR = src/wizard/

STARTABLE = yes
SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh
SERVICE_PORT = 8132
SERVICE_PORT_TITLE = $(DISPLAY_NAME)

# Admin link for in DSM UI
ADMIN_PORT = $(SERVICE_PORT)

CONF_DIR = src/conf/

INSTALL_DEP_SERVICES = mysql
START_DEP_SERVICES = mysql
# [mysqlclient]
DEPENDS += cross/mysql-connector-c cross/mariadb-connector-c
ENV += MYSQLCLIENT_CFLAGS="$(CFLAGS) -I$(STAGING_INSTALL_PREFIX)/include/mysql -I$(STAGING_INSTALL_PREFIX)/include/mariadb -I$(STAGING_INSTALL_PREFIX)/$(PYTHON_INC_DIR)"
ENV += MYSQLCLIENT_LDFLAGS="$(LDFLAGS)"

INSTALL_PREFIX = /usr/local/$(SPK_NAME)
# [bcrypt] and [cryptography]
# Mandatory for rustc wheel building
ENV += PYO3_CROSS_LIB_DIR=$(STAGING_INSTALL_PREFIX)/lib/
ENV += PYO3_CROSS_INCLUDE_DIR=$(STAGING_INSTALL_PREFIX)/include/
ENV += CRYPTOGRAPHY_DONT_BUILD_RUST=1
mreid-tt marked this conversation as resolved.
Show resolved Hide resolved

POST_STRIP_TARGET = ffsync_extra_install

BUSYBOX_CONFIG = usermng
ENV += BUSYBOX_CONFIG="$(BUSYBOX_CONFIG)"

include ../../mk/spksrc.spk.mk
include ../../mk/spksrc.python.mk
mreid-tt marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: ffsync_extra_install
ffsync_extra_install:
install -m 755 -d $(STAGING_DIR)/var
install -m 644 src/ffsync.ini $(STAGING_DIR)/var/
sed -i -e "s|https://github.com/mozilla-services/mozservices/archive/e00e1b68130423ad98d0f6185655bde650443da8.zip|mozsvc==0.8|g" \
-e "s|https://github.com/mozilla-services/tokenserver/archive/d7e513e8a4f5c588b70d685a8df1d2e508c341c0.zip|tokenserver==1.2.7|g" \
-e "s|https://github.com/mozilla-services/server-syncstorage/archive/1.5.5.zip|SyncStorage==1.5.5|g" \
-e "s|https://github.com/mozilla-services/syncserver/archive/1.5.2.tar.gz|syncserver==1.5.2|g" \
$(STAGING_DIR)/share/wheelhouse/requirements.txt
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file modified spk/ffsync/src/ffsync.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions spk/ffsync/src/requirements-all.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# From requirements.txt

# We pin cryptography to 3.4.8 due to a build error that occurs with the
# current version (36.0.0 at the time of this commit). In short, building
# the cryptography package with Rust results in a segfault, so we need to
# set the CRYPTOGRAPHY_DONT_BUILD_RUST env var to force the package to build
# with C instead. This env var is only present in cryptography<3.5.
cryptography==3.4.8
pyfxa==0.7.7
tokenlib==2.0.0

# From tools/tokenserver/requirements.txt

boto==2.49.0
hawkauthlib==2.0.0
mysqlclient==2.1.1
pyramid==2.0.1
sqlalchemy==1.4.46
testfixtures
tokenlib==2.0.0
PyBrowserID==0.14.0
mreid-tt marked this conversation as resolved.
Show resolved Hide resolved
24 changes: 24 additions & 0 deletions spk/ffsync/src/requirements-crossenv.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# From requirements.txt

# We pin cryptography to 3.4.8 due to a build error that occurs with the
# current version (36.0.0 at the time of this commit). In short, building
# the cryptography package with Rust results in a segfault, so we need to
# set the CRYPTOGRAPHY_DONT_BUILD_RUST env var to force the package to build
# with C instead. This env var is only present in cryptography<3.5.

# [bcrypt] & [cryptography]
# Require environment variables
# PYO3_CROSS_LIB_DIR=$(STAGING_INSTALL_PREFIX)/lib/
# PYO3_CROSS_INCLUDE_DIR=$(STAGING_INSTALL_PREFIX)/include/
cryptography==3.4.8

# From tools/tokenserver/requirements.txt

# [mysqlclient]
# Depends: mysql-connector-c, mariadb-connector-c
# Require environment variables
# MYSQLCLIENT_CFLAGS
# MYSQLCLIENT_LDFLAGS
mysqlclient==2.1.1

sqlalchemy==1.4.46
14 changes: 14 additions & 0 deletions spk/ffsync/src/requirements-pure.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# From requirements.txt

pyfxa==0.7.7
tokenlib==2.0.0

# From tools/tokenserver/requirements.txt

boto==2.49.0
hawkauthlib==2.0.0
pyramid==2.0.1
sqlalchemy==1.4.46
testfixtures
tokenlib==2.0.0
PyBrowserID==0.14.0
67 changes: 0 additions & 67 deletions spk/ffsync/src/requirements.txt

This file was deleted.

103 changes: 103 additions & 0 deletions spk/ffsync/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
PYTHON_DIR="/var/packages/python311/target/bin"
PATH="${SYNOPKG_PKGDEST}/env/bin:${SYNOPKG_PKGDEST}/bin:${PYTHON_DIR}:${PATH}"
MARIADB_10_INSTALL_DIRECTORY="/var/packages/MariaDB10"
MARIADB_10_BIN_DIRECTORY="${MARIADB_10_INSTALL_DIRECTORY}/target/usr/local/mariadb10/bin"
MYSQL="${MARIADB_10_BIN_DIRECTORY}/mysql"

PYTHON="${SYNOPKG_PKGDEST}/env/bin/python3"
SYNCSERVER="${HOME}/bin/syncserver"
HOME="${SYNOPKG_PKGDEST}/share/${SPK_NAME}"
CFG_FILE="${HOME}/config/local.toml"

SERVICE_COMMAND="${SYNCSERVER} --config=${CFG_FILE}"

service_preinst ()
{
# Check MySQL database
if [ "${SYNOPKG_PKG_STATUS}" = "INSTALL" ]; then
if [ -n "${wizard_mysql_password_root}" ]; then
if ! ${MYSQL} -u root -p"${wizard_mysql_password_root}" -e quit > /dev/null 2>&1; then
echo "Incorrect MySQL root password"
exit 1
fi
if ${MYSQL} -u root -p"${wizard_mysql_password_root}" mysql -e "SELECT User FROM user" | grep ^${SPK_NAME}$ > /dev/null 2>&1; then
echo "MySQL user ${SPK_NAME} already exists"
exit 1
fi
if ${MYSQL} -u root -p"${wizard_mysql_password_root}" -e "SHOW DATABASES" | grep -E '^(syncstorage_rs|tokenserver_rs)$' > /dev/null 2>&1; then
echo "MySQL database(s) for ${SPK_NAME} already exist(s)"
exit 1
fi
fi
fi
}

service_postinst ()
{
# Create a Python virtualenv
install_python_virtualenv

# Install wheels
install_python_wheels

if [ "${SYNOPKG_PKG_STATUS}" = "INSTALL" ]; then
# login as root sql user using whatever creds you set up for that
# this sets up a user for sync storage and sets up the databases
${MYSQL} -u root -p ${wizard_mysql_password_root} <<EOF
CREATE USER "${SPK_NAME}"@"localhost" IDENTIFIED BY "${wizard_password_ffsync}";
CREATE DATABASE syncstorage_rs;
CREATE DATABASE tokenserver_rs;
GRANT ALL PRIVILEGES on syncstorage_rs.* to ${SPK_NAME}@localhost;
GRANT ALL PRIVILEGES on tokenserver_rs.* to ${SPK_NAME}@localhost;
EOF

# Run initial database migrations
# syncstorage db initialization
$HOME/.cargo/bin/diesel --database-url "mysql://${SPK_NAME}:${wizard_password_ffsync}@localhost/syncstorage_rs" \
migration --migration-dir syncstorage-mysql/migrations run
# tokenserver db initialization
$HOME/.cargo/bin/diesel --database-url "mysql://${SPK_NAME}:${wizard_password_ffsync}@localhost/tokenserver_rs" \
migration --migration-dir tokenserver-db/migrations run

# Add sync endpoint to database
${MYSQL} -u ${SPK_NAME} -p "$(wizard_password_ffsync)" <<EOF
USE tokenserver_rs
INSERT INTO services (id, service, pattern) VALUES
(1, "sync-1.5", "{node}/1.5/{uid}");
EOF

# Add syncserver node
# the 10 is the user capacity.
SYNC_TOKENSERVER__DATABASE_URL="mysql://${SPK_NAME}:${wizard_password_ffsync}@localhost/tokenserver_rs" \
python3 tools/tokenserver/add_node.py \
${wizard_ffsync_public_url} 10

# Setup syncserver config file
MASTER_SECRET="$(cat /dev/urandom | base32 | head -c64)"
METRICS_HASH_SECRET="$(cat /dev/urandom | base32 | head -c64)"
cat > ${CFG_FILE} <<EOF
master_secret = "${MASTER_SECRET}"

# removing this line will default to moz_json formatted logs
human_logs = 1

host = "localhost" # default
port = ${SERVICE_PORT} # SPK default

syncstorage.database_url = "mysql://${SPK_NAME}:${wizard_password_ffsync}@localhost/syncstorage_rs"
syncstorage.enable_quota = 0
syncstorage.enabled = true
syncstorage.limits.max_total_records = 1666 # See issues #298/#333

# token
tokenserver.database_url = "mysql://${SPK_NAME}:${wizard_password_ffsync}@localhost/tokenserver_rs"
tokenserver.enabled = true
tokenserver.fxa_email_domain = "api.accounts.firefox.com"
tokenserver.fxa_metrics_hash_secret = "${METRICS_HASH_SECRET}"
tokenserver.fxa_oauth_server_url = "https://oauth.accounts.firefox.com"
tokenserver.fxa_browserid_audience = "https://token.services.mozilla.com"
tokenserver.fxa_browserid_issuer = "https://api.accounts.firefox.com"
tokenserver.fxa_browserid_server_url = "https://verifier.accounts.firefox.com/v2"
EOF
fi
}
Loading