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

add mitmproxy spk #2557

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions cross/ruamel/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PKG_NAME = ruamel.yaml
PKG_VERS = 0.13.4
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://files.pythonhosted.org/packages/source/r/$(PKG_NAME)
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)

DEPENDS = cross/libyaml

HOMEPAGE =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use some info here ;)

COMMENT =
LICENSE =

include ../../mk/spksrc.python-wheel.mk
Empty file added cross/ruamel/PLIST
Empty file.
3 changes: 3 additions & 0 deletions cross/ruamel/digests
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ruamel.yaml-0.13.4.tar.gz SHA1 2ef3884105b60c7723b7d74c83ed68d090d45d52
ruamel.yaml-0.13.4.tar.gz SHA256 a4d8cc1ac83796eb2104be57d41d318d53c1b8a7a4122d8637ad0b777c94b45c
ruamel.yaml-0.13.4.tar.gz MD5 c6f0cc6922899103f81cc6226c629e57
29 changes: 29 additions & 0 deletions spk/mitmproxy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SPK_NAME = mitmproxy
SPK_VERS = 0.18.2
SPK_REV = 1
SPK_ICON = src/mitmproxy.png

WHEELS = src/requirements.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep the flow in the file, should we perhaps format it as BUILD_DEPENDS, DEPENDS, WHEELS, SPK_DEPENDS, essentially in the order that the entries will be processed?

SPK_DEPENDS = "python>=2.7.11-15"

BUILD_DEPENDS = cross/python cross/setuptools cross/pip cross/wheel
BUILD_DEPENDS += cross/ruamel cross/cffi cross/lxml cross/pillow
DEPENDS =

MAINTAINER = cytec
DESCRIPTION = mitmproxy is an interactive, SSL-capable intercepting proxy with a console interface.
DISPLAY_NAME = mitmproxy
CHANGELOG = initial release of mitmproxy

STARTABLE = no
BETA = 1

HOMEPAGE = https://mitmproxy.org/
LICENSE = MIT

INSTALLER_SCRIPT = src/installer.sh
SSS_SCRIPT = src/dsm-control.sh

INSTALL_PREFIX = /usr/local/$(SPK_NAME)

include ../../mk/spksrc.spk.mk
1 change: 1 addition & 0 deletions spk/mitmproxy/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rsc:share/wheelhouse
23 changes: 23 additions & 0 deletions spk/mitmproxy/src/dsm-control.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

# Package
PACKAGE="mitmproxy"
DNAME="mitmproxy"

# Others
INSTALL_DIR="/usr/local/${PACKAGE}"

case $1 in
start)
exit 0
;;
stop)
exit 0
;;
status)
exit 0
;;
log)
exit 0
;;
esac
114 changes: 114 additions & 0 deletions spk/mitmproxy/src/installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/sh

# Package
PACKAGE="mitmproxy"
DNAME="mitmproxy"

# Others
INSTALL_DIR="/usr/local/${PACKAGE}"
SSS="/var/packages/${PACKAGE}/scripts/start-stop-status"
PYTHON_DIR="/usr/local/python"
PATH="${INSTALL_DIR}/bin:${INSTALL_DIR}/env/bin:${PYTHON_DIR}/bin:${PATH}"
USER="mitmproxy"
GROUP="users"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I belive the users group isn't correct here. Does the package need file system access? For DSM5, we generally use the nobody group instead.

FTR, DSM6 users will not be member of the users group at all (we'll just use our sc-* groups if access to the FS is needed), and one thing to check if if there's even a nobody group.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On DSM6, I can confirm nobody group is available. On my system, domoticz account belongs to that group. I also can mention subliminal is in users group.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ymartin59 Just to check: are you sure the nobody group is available on a clean DSM6 environment, and not that it was created by one of our packages you have installed?
As for the subliminal user, yes, that's expected if you installed the user while on DSM5. It's not a DSM6 package...none of our packages are.

VIRTUALENV="${PYTHON_DIR}/bin/virtualenv"
TMP_DIR="${SYNOPKG_PKGDEST}/../../@tmp"

SERVICETOOL="/usr/syno/bin/servicetool"

syno_group_create ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can be removed

{
# Create syno group (Does nothing when group already exists)
synogroup --add ${SYNO_GROUP} ${USER} > /dev/null
# Set description of the syno group
synogroup --descset ${SYNO_GROUP} "${SYNO_GROUP_DESC}"

# Add user to syno group (Does nothing when user already in the group)
addgroup ${USER} ${SYNO_GROUP}
}

syno_group_remove ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...as can this one

{
# Remove user from syno group
delgroup ${USER} ${SYNO_GROUP}

# Check if syno group is empty
if ! synogroup --get ${SYNO_GROUP} | grep -q "0:"; then
# Remove syno group
synogroup --del ${SYNO_GROUP} > /dev/null
fi
}

preinst ()
{
exit 0
}

postinst ()
{
# Link
ln -s ${SYNOPKG_PKGDEST} ${INSTALL_DIR}

# Create a Python virtualenv
${VIRTUALENV} --system-site-packages ${INSTALL_DIR}/env > /dev/null

# Install the wheels
${INSTALL_DIR}/env/bin/pip install --no-deps --no-index -U --force-reinstall -f ${INSTALL_DIR}/share/wheelhouse ${INSTALL_DIR}/share/wheelhouse/*.whl > /dev/null 2>&1
# Create user
adduser -h ${INSTALL_DIR}/var -g "${DNAME} User" -G ${GROUP} -s /bin/sh -S -D ${USER}

# Correct the files ownership
chown -R ${USER}:root ${SYNOPKG_PKGDEST}

exit 0
}

preuninst ()
{
# Stop the package
${SSS} stop > /dev/null

# Remove the user if uninstalling
if [ "${SYNOPKG_PKG_STATUS}" == "UNINSTALL" ]; then
delgroup ${USER} ${GROUP}
deluser ${USER}
fi

# Remove firewall config
if [ "${SYNOPKG_PKG_STATUS}" == "UNINSTALL" ]; then
${SERVICETOOL} --remove-configure-file --package ${PACKAGE}.sc >> /dev/null
fi

exit 0
}

postuninst ()
{
# Remove link
rm -f ${INSTALL_DIR}

exit 0
}

preupgrade ()
{
# Stop the package
${SSS} stop > /dev/null

# Save some stuff
rm -fr ${TMP_DIR}/${PACKAGE}
mkdir -p ${TMP_DIR}/${PACKAGE}
mv ${INSTALL_DIR}/var ${TMP_DIR}/${PACKAGE}/

exit 0
}

postupgrade ()
{
# Restore some stuff
rm -fr ${INSTALL_DIR}/var
mv ${TMP_DIR}/${PACKAGE}/var ${INSTALL_DIR}/
rm -fr ${TMP_DIR}/${PACKAGE}

exit 0
}
Binary file added spk/mitmproxy/src/mitmproxy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions spk/mitmproxy/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
https://github.com/mitmproxy/mitmproxy/archive/v0.18.2.tar.gz
backports.ssl_match_hostname>=3.5.0.1, <3.6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the versions in this file should be pinned to exactly 1 version (==) for reproducability reasons, otherwise we will not be able to recreate the exact same package when even 1 of these requirements updates.
Run a pip freeze > requirements.txt when you've got everything installed, and use that as a base instead.

blinker>=1.4, <1.5
click>=6.2, <7.0
certifi>=2015.11.20.1 # no semver here - this should always be on the last release!
configargparse>=0.10, <0.12
construct>=2.5.2, <2.6
cryptography>=1.3, <1.6
cssutils>=1.0.1, <1.1
Flask>=0.10.1, <0.12
h2>=2.4.1, <2.5
html2text>=2016.1.8, <=2016.9.19
hyperframe>=4.0.1, <5
jsbeautifier>=1.6.3, <1.7
passlib>=1.6.5, <1.7
pyasn1>=0.1.9, <0.2
pyOpenSSL>=16.0, <17.0
pyparsing>=2.1.3, <2.2
pyperclip>=1.5.22, <1.6
requests>=2.9.1, <2.12
six>=1.10, <1.11
tornado>=4.3, <4.5
urwid>=1.3.1, <1.4
watchdog>=0.8.3, <0.9
brotlipy>=0.5.1, <0.7
ruamel.yaml>=0.13.2, <0.14
hpack==2.3.0
typing==3.5.2.2
enum34>=1.0.4, <2
ipaddress>=1.0.15, <1.1
backports-abc>=0.4
itsdangerous==0.24
singledispatch==3.4.0.3
argh>=0.24.1
pathtools>=0.1.1
editorconfig>=0.12.0
Jinja2>=2.4
Werkzeug>=0.7