diff options
author | Jesús Daniel Colmenares Oviedo <DtxdF@disroot.org> | 2023-04-29 00:35:13 +0100 |
---|---|---|
committer | Matthew Seaman <matthew@FreeBSD.org> | 2023-04-29 00:40:54 +0100 |
commit | c73027b88862fb51a350382b751173e9f63adc8e (patch) | |
tree | e9c8d6a300cff5ffa1406f6e86da17d1b39a8b1d /irc/py-sopel | |
parent | x11-wm/hyprland: simplify GIT_COMMIT_MESSAGE after da134084ee1e (diff) |
irc/py-sopel: New port
Sopel is a simple, lightweight, open source, easy-to-use IRC Utility
bot, written in Python. It's designed to be easy to use, run and
extend.
PR: 265807
Approved by: Jesús Daniel Colmenares Oviedo (maintainer)
Diffstat (limited to 'irc/py-sopel')
-rw-r--r-- | irc/py-sopel/Makefile | 50 | ||||
-rw-r--r-- | irc/py-sopel/distinfo | 3 | ||||
-rw-r--r-- | irc/py-sopel/files/patch-requirements.txt | 37 | ||||
-rw-r--r-- | irc/py-sopel/files/pkg-message.in | 45 | ||||
-rw-r--r-- | irc/py-sopel/files/sopel-default.cfg | 21 | ||||
-rw-r--r-- | irc/py-sopel/files/sopel.in | 147 | ||||
-rw-r--r-- | irc/py-sopel/pkg-descr | 3 | ||||
-rw-r--r-- | irc/py-sopel/pkg-plist | 6 |
8 files changed, 312 insertions, 0 deletions
diff --git a/irc/py-sopel/Makefile b/irc/py-sopel/Makefile new file mode 100644 index 000000000000..a083e5d21d19 --- /dev/null +++ b/irc/py-sopel/Makefile @@ -0,0 +1,50 @@ +PORTNAME= sopel +DISTVERSION= 7.1.9 +CATEGORIES= irc python +MASTER_SITES= PYPI +PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} + +MAINTAINER= DtxdF@disroot.org +COMMENT= Easy-to-use and highly extensible IRC Bot framework +WWW= https://sopel.chat/ + +LICENSE= EFLv2 +LICENSE_GROUPS= FSF GPL OSI +LICENSE_NAME= Eiffel Forum License, version 2 +LICENSE_FILE= ${WRKSRC}/COPYING +LICENSE_PERMS= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept + +RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}dnspython>0:dns/py-dnspython@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}GeoIP2>0:net/py-GeoIP2@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}importlib-metadata>0:devel/py-importlib-metadata@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}packaging>0:devel/py-packaging@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}praw>0:www/py-praw@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}pytz>0:devel/py-pytz@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}requests>0:www/py-requests@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}sqlalchemy13>0:databases/py-sqlalchemy13@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}urllib3>0:net/py-urllib3@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}xmltodict>=0.12:devel/py-xmltodict@${PY_FLAVOR} + +USES= python:3.8+ +USE_PYTHON= autoplist distutils + +USE_RC_SUBR= sopel +SUB_FILES+= pkg-message +SUB_LIST+= PYTHON_CMD=${PYTHON_CMD} + +USERS= sopel +GROUPS= sopel + +PLIST_SUB= GROUP="${GROUPS:[0]}" \ + USER="${USERS:[0]}" + +post-install: + @${MKDIR} ${STAGEDIR}/${ETCDIR} + @${CP} ${FILESDIR}/sopel-default.cfg ${STAGEDIR}/${ETCDIR}/sopel-default.cfg.sample +.for dir in run log db + @${MKDIR} ${STAGEDIR}/var/${dir}/sopel +.endfor + @${MKDIR} ${STAGEDIR}/var/db/sopel/www + +.include <bsd.port.mk> diff --git a/irc/py-sopel/distinfo b/irc/py-sopel/distinfo new file mode 100644 index 000000000000..384a7f61a75c --- /dev/null +++ b/irc/py-sopel/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1660249423 +SHA256 (sopel-7.1.9.tar.gz) = 209fa8bcb42febf514d687a9994423cda5811b745d777c6fba2ec58caf3952bb +SIZE (sopel-7.1.9.tar.gz) = 263438 diff --git a/irc/py-sopel/files/patch-requirements.txt b/irc/py-sopel/files/patch-requirements.txt new file mode 100644 index 000000000000..b04c63825266 --- /dev/null +++ b/irc/py-sopel/files/patch-requirements.txt @@ -0,0 +1,37 @@ +--- requirements.txt.orig 2023-02-26 10:45:58 UTC ++++ requirements.txt +@@ -1,27 +1,8 @@ +-xmltodict<0.12.0; python_version == '3.3' +-xmltodict==0.12; python_version != '3.3' ++xmltodict + pytz +-praw>=4.0.0,<6.0.0 +-# transitive dependency of praw; v0.18 introduced f-string syntax +-update-checker<0.18; python_version < '3.6' +-geoip2<3.0; python_version <= '3.5' and python_version != '2.7' +-geoip2>=3.0,<4.0; python_version == '2.7' +-geoip2>=4.0,<5.0; python_version >= '3.6' +-# transitive dependency of geoip2; v2 dropped py2.7 & py3 < 3.6 +-maxminddb<2.0; python_version < '3.6' +-ipaddress<2.0; python_version < '3.3' +-requests>=2.24.0,<3.0.0; python_version != '3.3' and python_version != '3.4' +-# py3.3 doesn't work with the chardet/charset-normalizer detection added in 2.26 +-requests>=2.24.0,<2.26; python_version == '3.3' +-# py3.4 isn't supported after requests 2.21 +-requests==2.21.0; python_version == '3.4' +-# transitive dependency of requests +-# 2.0 will drop EOL Python 2.7 & 3.5, just like Sopel 8 plans to +-urllib3<1.27; python_version != '3.3' and python_version != '3.4' +-urllib3<1.23; python_version == '3.3' +-urllib3<1.25; python_version == '3.4' +-dnspython<2.0; python_version == '2.7' +-dnspython<1.16.0; python_version == '3.3' +-dnspython<3.0; python_version >= '3.4' +-sqlalchemy<1.3; python_version == '3.3' +-sqlalchemy<1.4; python_version != '3.3' ++praw ++geoip2 ++requests ++urllib3 ++dnspython ++sqlalchemy diff --git a/irc/py-sopel/files/pkg-message.in b/irc/py-sopel/files/pkg-message.in new file mode 100644 index 000000000000..119c74c283a3 --- /dev/null +++ b/irc/py-sopel/files/pkg-message.in @@ -0,0 +1,45 @@ +[ +{ + type: install + message: <<EOM +Sopel was installed and there are some notes: + +1. The default profile or configuration file is installed in +%%ETCDIR%%/sopel-default.cfg. + +2. The default profile uses logdir (/var/log/sopel), pid_dir +(/var/run/sopel) and homedir (/var/db/sopel) directories, which are +already created. You can change them in %%ETCDIR%%/sopel-default.cfg. + +3. Enable sopel with: +sysrc sopel_enable="YES" + +4. Sopel can configure the common options with: +service sopel configure + +5. Before starting sopel, it must be configured using service sopel configure +or directly in the configuration file. After it is configured, the +not_configured parameter in the configuration file must be removed +or change its value to False. + +6. The service can run multiple instances of sopel, the default +profile is "default". You can change or add more profiles by making +a copy or creating other files with the prefix sopel- and the name +of the profile: + +cp %%ETCDIR%%/sopel-default.cfg.sample %%ETCDIR%%/sopel-profile1.cfg +cp %%ETCDIR%%/sopel-default.cfg.sample %%ETCDIR%%/sopel-profile2.cfg +cp %%ETCDIR%%/sopel-default.cfg.sample %%ETCDIR%%/sopel-profile3.cfg + +Edit and add them in /etc/rc.conf: + +sysrc sopel_profiles+="profile1 profile2 profile3" + +7. Each plugin has its own configuration. If you observe strange behavior, please +make sure you have configured the module correctly before reporting it as a bug. + +8. Start the service: +service sopel start +EOM +} +] diff --git a/irc/py-sopel/files/sopel-default.cfg b/irc/py-sopel/files/sopel-default.cfg new file mode 100644 index 000000000000..7f8a5a4a2877 --- /dev/null +++ b/irc/py-sopel/files/sopel-default.cfg @@ -0,0 +1,21 @@ +# +# IMPORTANT NOTE! +# You must delete the not_configured line in order for the bot to work, +# otherwise it will refuse to start. +[core] +nick=sopel +not_configured=True +host=irc.libera.chat +port=6697 +use_ssl=True +verify_ssl=True +owner= +logdir=/var/log/sopel +pid_dir=/var/run/sopel +homedir=/var/db/sopel + +[meetbot] +# If this directory is not created, sopel will see "/www/meetings" +# and not as "/var/db/sopel/www/meetings". Sopel runs by default +# as a non-root user, it cannot make a directory in /. +meeting_log_path = /var/db/sopel/www/meetings diff --git a/irc/py-sopel/files/sopel.in b/irc/py-sopel/files/sopel.in new file mode 100644 index 000000000000..278c461cbe37 --- /dev/null +++ b/irc/py-sopel/files/sopel.in @@ -0,0 +1,147 @@ +#!/bin/sh + +# PROVIDE: sopel +# REQUIRE: LOGIN +# KEYWORD: shutdown +# +# Configuration settings for sopel in /etc/rc.conf +# +# sopel_enable (bool): Enable sopel. (default=NO) +# sopel_piddir (str): Directory in which to put the process ID file. (default=/var/run/sopel) +# sopel_confdir (str): Configuration directory. (default=%%ETCDIR%%) +# sopel_flags (str): Flags used for sopel. (default=--config-dir "${sopel_confdir}") +# sopel_script (str): Path to sopel application. (default=%%PREFIX%%/bin/sopel) +# sopel_user (str): User to run sopel as. (default=sopel) +# sopel_profiles (str): List of profiles for running multiple sopel instances. +# (default=default) +# sopel_prefix (str): Each profile or configuration file must begin with thix prefix +# followed by the profile name, followed by the extension .cfg, +# such as sopel-default.cfg, sopel-libera.chat.cfg, etc. +# (default=sopel-) +# sopel_output (str): Send stdout and stderr to a file. If you set the logdir parameter in +# the sopel file configuration, your best option is to send the output +# to /dev/null. But this can be changed for debugging. +# (default=/dev/null) + +. /etc/rc.subr + +name=sopel +rcvar=sopel_enable +desc="Simple, easy-to-use, open-source IRC utility bot, written in Python" +start_precmd=sopel_checkprofile +stop_precmd=sopel_checkprofile +start_cmd=sopel_start +stop_cmd=sopel_stop +restart_cmd=sopel_restart +status_cmd=sopel_status +configure_cmd=sopel_configure +extra_commands="configure status" +command_interpreter="%%PYTHON_CMD%%" + +load_rc_config $name + +: ${sopel_enable:=NO} +: ${sopel_piddir:=/var/run/sopel} +: ${sopel_confdir:=%%ETCDIR%%} +: ${sopel_flags=--config-dir "${sopel_confdir}"} +: ${sopel_script:=%%PREFIX%%/bin/sopel} +: ${sopel_user:=sopel} +: ${sopel_profiles:=default} +: ${sopel_prefix:=sopel-} +: ${sopel_output:=/dev/null} + +sopel_checkprofile() +{ + if ! [ -f "${sopel_confdir}/${sopel_prefix}${profile}.cfg" ]; then + echo "Sopel profile '${profile}' does not exist." + return 1 + fi + + return 0 +} + +sopel_start() +{ + local profile + + profile="$1"; shift + + echo "Starting sopel profile '${profile}'." && sleep 1 + daemon \ + -o "${sopel_output}" \ + -t "${desc}" \ + -u "${sopel_user}" \ + ${command_interpreter} \ + ${sopel_script} start ${sopel_flags} \ + -c "${sopel_prefix}${profile}" $@ +} + +sopel_stop() +{ + local pid pidfile profile + + profile="$1"; shift + + pidfile="${sopel_piddir}/sopel-${sopel_prefix}${profile}.pid" + if ! [ -f "${pidfile}" ]; then + echo "sopel profile '${profile}' not running? (check ${sopel_piddir}/sopel-${sopel_prefix}${profile}.pid)." + return 1 + fi + + pid=`cat ${pidfile}` + + echo "Stopping sopel profile '${profile}'." + daemon \ + -o "${sopel_output}" \ + ${command_interpreter} \ + ${sopel_script} stop ${sopel_flags} \ + -c "${sopel_prefix}${profile}" $@ + + wait_for_pids $pid +} + +sopel_restart() +{ + local profile + + profile="$1"; shift + + run_rc_command stop "${profile}" $@ + run_rc_command start "${profile}" $@ +} + +sopel_status() +{ + local profile pid + + profile="$1"; shift + + pid=`check_pidfile \ + "${sopel_piddir}/sopel-${sopel_prefix}${profile}.pid" \ + "${sopel_script}" \ + "${command_interpreter}"` + + if [ -n "${pid}" ]; then + echo "Sopel profile '${profile}' is running as pid ${pid}." + else + echo "Sopel profile '${profile}' is not running." + fi +} + +sopel_configure() +{ + local profile + + profile="$1"; shift + + echo "Configuring profile '${profile}'..." + + ${command_interpreter} \ + ${sopel_script} configure ${sopel_flags} \ + -c "${sopel_confdir}/${sopel_prefix}${profile}" $@ +} + +cmd="$1"; shift +for profile in ${sopel_profiles}; do + run_rc_command "${cmd}" "${profile}" $@ +done diff --git a/irc/py-sopel/pkg-descr b/irc/py-sopel/pkg-descr new file mode 100644 index 000000000000..906e7de0af68 --- /dev/null +++ b/irc/py-sopel/pkg-descr @@ -0,0 +1,3 @@ +Sopel is a simple, lightweight, open source, easy-to-use IRC Utility +bot, written in Python. It's designed to be easy to use, run and +extend. diff --git a/irc/py-sopel/pkg-plist b/irc/py-sopel/pkg-plist new file mode 100644 index 000000000000..504814fd29f5 --- /dev/null +++ b/irc/py-sopel/pkg-plist @@ -0,0 +1,6 @@ +@sample(%%USER%%,%%GROUP%%,640) %%ETCDIR%%/sopel-default.cfg.sample %%ETCDIR%%/sopel-default.cfg +@dir(%%USER%%,%%GROUP%%,0700) %%ETCDIR%% +@dir(%%USER%%,%%GROUP%%,0700) /var/db/sopel +@dir(%%USER%%,%%GROUP%%,) /var/db/sopel/www +@dir(%%USER%%,%%GROUP%%,0700) /var/log/sopel +@dir(%%USER%%,%%GROUP%%,0700) /var/run/sopel |