Added files.

master
Franco Masotti 2017-02-17 12:21:16 +01:00
commit 278bf947e7
7 changed files with 410 additions and 0 deletions

25
.SRCINFO Normal file
View File

@ -0,0 +1,25 @@
pkgbase = swish-cplint-bin
pkgdesc = SWI-Prolog for SHaring: a SWI-Prolog web IDE integrated with the cplint suite - precompiled version
pkgver = r1789.2563692
pkgrel = 1
url = https://github.com/friguzzi/swish
install = .install
arch = x86_64
license = BSD
makedepends = git
makedepends = sed
makedepends = unzip
makedepends = curl
depends = libxinerama
depends = libxpm
depends = git
depends = graphviz
depends = swi-prolog-devel
depends = rserve-sandbox-docker-bin
conflicts = swish
conflicts = swish-cplint
source = git+https://github.com/friguzzi/swish#branch=master
md5sums = SKIP
pkgname = swish-cplint-bin

25
.install Normal file
View File

@ -0,0 +1,25 @@
post_install() {
# Add swish user and group with a home directory (which will contain all
# the packs).
getent group swish &>/dev/null || groupadd -r swish >/dev/null
getent passwd swish &>/dev/null || useradd -m -d /home/swish \
-r -g swish swish >/dev/null
# Add swish user to the rserve group. If this is not done, access to the
# socket will be forbidden.
gpasswd -a swish rserve >/dev/null
chown -R swish:swish /usr/share/swish-cplint
printf "\n\n%s\n\n" "To initialize and download all the necessary \
components you must run: \
sudo -u swish swish-cplint -i"
printf "%s\n\n" "You can then start and enable \
swish-cplint.service to run the server."
}
post_remove() {
printf "\n\n%s\n" "You can remove /home/swish."
printf "%s\n\n" "You can also remove swish user and group."
}

55
PKGBUILD Normal file
View File

@ -0,0 +1,55 @@
# Maintainer: Franco Masotti <franco dot masotti at student dot unife dot it>
# Contributor: Franco Masotti <franco dot masotti at student dot unife dot it>
pkgname=swish-cplint-bin
pkgver=r1789.2563692
pkgrel=1
pkgdesc="SWI-Prolog for SHaring: a SWI-Prolog web IDE integrated with the cplint suite - precompiled version"
arch=('x86_64')
url="https://github.com/friguzzi/swish"
license=('BSD')
depends=('libxinerama'
'libxpm'
'git'
'graphviz'
'swi-prolog-devel'
'rserve-sandbox-docker-bin')
makedepends=('git'
'sed'
'unzip'
'curl')
conflicts=('swish'
'swish-cplint')
install=.install
source=('git+https://github.com/friguzzi/swish#branch=master')
md5sums=('SKIP')
build() {
cd ${srcdir}/swish
# Unzip in swish/web/bower_components
curl -o swish-bower-components.zip \
http://www.swi-prolog.org/download/swish/swish-bower-components.zip
unzip swish-bower-components.zip
rm -rf swish-bower-components.zip
# Patch
cp ../../run.pl .
cp ../../run.sh .
cp ../../install_web_iface_deps.pl .
}
pkgver () {
cd ${srcdir}/swish
( set -o pipefail
git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
)
}
package() {
cd ${srcdir}
install -d "${pkgdir}"/usr/share/"${pkgname%-bin}"
install -d "${pkgdir}"/usr/bin
cp -r swish/* "${pkgdir}"/usr/share/"${pkgname%-bin}"
install -D -m644 swish/LICENSE "${pkgdir}"/usr/share/licenses/"${pkgname%-bin}"/LICENSE
install -D -m644 ../"${pkgname%-bin}".service ${pkgdir}/usr/lib/systemd/system/"${pkgname%-bin}".service
ln -s /usr/share/"${pkgname%-bin}"/run.sh "${pkgdir}"/usr/bin/"${pkgname%-bin}"
}

38
install_web_iface_deps.pl Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env swipl
/*
*
* install_web_iface_deps.pl
*
* Copyright (C) 2016 frnmst (Franco Masotti) <franco.masotti@student.unife.it>
*
* This file is part of cplint-installer.
*
* cplint-installer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cplint-installer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cplint-installer. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* Package directory will be the default one */
:- initialization main.
install:-
pack_install(aleph, [url('https://github.com/friguzzi/aleph.git'),interactive(false)]),
pack_install(real, [url('http://stoics.org.uk/~nicos/sware/packs/real/real-2.0.tgz'),interactive(false)]),
pack_install('cplint_r', [url('https://github.com/frnmst/cplint_r.git'),interactive(false)]).
main:-
catch(install, E, (print_message(error, E), fail)),
halt.
main:-
halt(1).

45
run.pl Normal file
View File

@ -0,0 +1,45 @@
/*
*
* run.pl
*
* Copyright (C) 2016 frnmst (Franco Masotti) <franco.masotti@student.unife.it>
*
* This file is part of cplint-installer.
*
* cplint-installer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cplint-installer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cplint-installer. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* Patch to run the server in backround. This file should replace the one
* provided in the repository.
*/
:- use_module(server).
:- use_module('lib/r_swish').
:- use_module(library(r/r_sandbox)).
% Using `localhost:3050`, we only bind to localhost interface!
% Use plain `3050` (or any port number you like) to make the server
% accessible from all network interfaces.
%:- initialization server(localhost:3050).
:- initialization main.
main:-
server(3050),
wait.
wait:-
thread_get_message(_),
halt.

179
run.sh Executable file
View File

@ -0,0 +1,179 @@
#!/usr/bin/env sh
#
# run.sh
#
# Copyright (C) 2016 frnmst (Franco Masotti) <franco.masotti@student.unife.it>
#
# This file is part of cplint-installer.
#
# cplint-installer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cplint-installer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cplint-installer. If not, see <http://www.gnu.org/licenses/>.
#
#
# This is the file called from the /usr/bin/swish-cplint symlink
pkg_dir="/usr/share/swish-cplint"
pid_file="/run/swish-cplint/swish-cplint.pid"
installed_file=""$pkg_dir"/installed"
deps_installer=""$pkg_dir"/install_web_iface_deps.pl"
user="swish"
group="swish"
help()
{
cat<<-EOF
swish-cplint [OPTION]
SWI-Prolog for SHaring: a SWI-Prolog web IDE integrated with the cplint suite
Only a single option is permitted.
-h print this help
-i install dependencies
-k kill swish-cplint
-s start swish-cplint
Exit status:
0 if OK,
1 some error occurred.
Full documentation at: <https://github.com/friguzzi/swish>
and at: <https://github.com/friguzzi/cplint>
EOF
}
init()
{
printf "%s\n" "This may take a while."
pushd "$pkg_dir"
$deps_installer
if [ $? -eq 0 ]; then
echo "# Don't touch this file" > "$installed_file"
echo "true" >> "$installed_file"
else
1>&2 printf "%s\n" "Install web dependencies error"
exit 1
fi
}
installed()
{
if [ ! -f "$installed_file" ]; then
1>&2 printf "%s\n" "You need to run \
'sudo -u swish swish-cplint -i' \
first"
exit 1
fi
}
killd()
{
# kill action only if process exists.
if [ -f "$pid_file" ]; then
pid=$(cat "$pid_file")
ps -q $pid > /dev/null
if [ $? -eq 0 ]; then
kill -s TERM $pid
fi
fi
}
remove()
{
:
}
startd()
{
local pid=""
# The following means installed && { ... }
installed
{
(
cd "$pkg_dir"
exec swipl --quiet -f "$pkg_dir"/run.pl
) &
pid="$!"
} 1>&2
write_pid_file "$pid"
}
#
# shared_functions.sh
#
# Copyright (C) 2016 frnmst (Franco Masotti) <franco.masotti@student.unife.it>
#
# This file is part of swish-installer.
#
# swish-installer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# swish-installer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with swish-installer. If not, see <http://www.gnu.org/licenses/>.
#
#
# This file is used by the various run.sh.
check_running_user_and_group()
{
if [ "$(id -un)" = "$user" ] && [ "$(id -gn)" = "$group" ]; then
:
else
printf "User must be "$user"\n"
printf "Group must be "$group"\n"
return 1
fi
}
write_pid_file()
{
local pid="$1"
if [ -n "$pid" ]; then
printf "Server running with pid $pid\n"
printf "$pid\n" > "$pid_file"
else
printf "Server error\n"
return 1
fi
}
option_parser()
{
getopts ":hikrs" opt "$@"
case "$opt" in
h ) help ;;
i ) init ;;
k ) killd ;;
r ) remove ;;
s ) startd ;;
? ) help; return 1 ;;
esac
}
main()
{
check_running_user_and_group && option_parser "$@"
}
main "$@"

43
swish-cplint.service Normal file
View File

@ -0,0 +1,43 @@
#
# swish-cplint.service
#
# Copyright (C) 2016 frnmst (Franco Masotti) <franco.masotti@student.unife.it>
#
# This file is part of cplint-installer.
#
# cplint-installer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cplint-installer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cplint-installer. If not, see <http://www.gnu.org/licenses/>.
#
#
# To be placed in /usr/lib/systemd/system/swish-cplint.service
[Unit]
Description=Cplint on SWISH
Documentation=http://github.com/friguzzi/cplint https://github.com/friguzzi/swish
Requires=rserve-sandbox-docker.service
After=rserve-sandbox-docker.service
[Service]
ExecStart=/usr/bin/swish-cplint -s
ExecStop=/usr/bin/swish-cplint -k
Type=forking
PIDFile=/run/swish-cplint/swish-cplint.pid
User=swish
Group=swish
RuntimeDirectory=swish-cplint
[Install]
Also=rserve-sandbox-docker.service
WantedBy=default.target