Build rpm and deb packages

This commit is contained in:
Kirill Zaitsev
2014-10-12 20:22:51 +04:00
parent 12757476d8
commit b64cd83424
18 changed files with 315 additions and 76 deletions

View File

@@ -0,0 +1,71 @@
[server]
port=":80"
#####################################################################
# SSL configuration
#
# [server.ssl]
# key=""
# cert=""
# [session]
# secret=""
# duration=""
#####################################################################
# Database configuration, by default using SQLite3.
# You can also use postgres and mysql. See the documentation
# for more details.
[database]
driver="sqlite3"
datasource="/var/lib/drone/drone.sqlite"
#####################################################################
# Open Registration allows users to self-register for Drone.
# This is recommended if Drone is being hosted behind a
# firewall.
#
# When false, the system admin will need to manually add
# users to Drone through the admin screens.
#
# [registration]
# open=true
# [github]
# client=""
# secret=""
# [github_enterprise]
# client=""
# secret=""
# api=""
# url=""
# private_mode=false
# [bitbucket]
# client=""
# secret=""
# [gitlab]
# url=""
#####################################################################
# SMTP configuration for Drone. This is required if you plan
# to send email notifications for build statuses.
#
# [smtp]
# host=""
# port=""
# from=""
# user=""
# pass=""
# [worker]
# nodes=[
# "unix:///var/run/docker.sock",
# "unix:///var/run/docker.sock"
# ]

View File

@@ -0,0 +1,8 @@
start on (filesystem and net-device-up)
chdir /var/lib/drone
console log
script
/usr/local/bin/droned --config=/etc/drone/drone.toml
end script

View File

@@ -0,0 +1,26 @@
#
# systemd unit file for CentOS 7, Ubuntu bleeding edge
#
[Unit]
Description=Drone
# start us only once the network and logging subsystems are available
After=syslog.target network.target
# See these pages for lots of options:
# http://0pointer.de/public/systemd-man/systemd.service.html
# http://0pointer.de/public/systemd-man/systemd.exec.html
[Service]
Type=simple
ExecStart=/usr/local/bin/droned --config=/etc/drone/drone.toml
# if we crash, restart
RestartSec=1
Restart=on-failure
# use syslog for logging
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=droned
[Install]
WantedBy=multi-user.target

View File

View File

@@ -0,0 +1,91 @@
#!/bin/sh
set -e
case "$1" in
abort-upgrade|abort-remove|abort-deconfigure|configure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
if [ -f /etc/drone/drone.toml ]; then
chmod 600 /etc/drone/drone.toml
fi
dist() {
lsb_release -i | awk '{print tolower($3)}' | sed -e 's/^ *//' -e 's/ *$//'
}
version() {
lsb_release -r | awk '{print $2}' | sed -e 's/^ *//' -e 's/ *$//'
}
upstart() {
if [ -d /etc/init ]; then
if [ -f /usr/local/bin/droned ]; then
if pidof /usr/local/bin/droned >/dev/null; then
initctl stop drone || :
fi
fi
echo "You have $(dist) $(version): using upstart to control Drone"
cp -r /usr/share/drone/init/drone.conf /etc/init/drone.conf
initctl start drone || :
else
echo "Couldn't find upstart to control Drone, cannot proceed."
echo "Open an issue and tell us about your system."
exit 1
fi
}
systemd() {
if which systemctl > /dev/null; then
echo "Your system $(dist) $(version): using systemd to control Drone"
cp /usr/share/drone/systemd/drone.service /lib/systemd/system/drone.service
systemctl daemon-reload || :
if [ "$1" = 1 ] ; then
# first time install
systemctl enable drone || :
systemctl start drone || :
else
echo "Upgrading drone"
systemctl restart drone
fi
else
echo "Couldn't find systemd to control Drone, cannot proceed."
echo "Open an issue and tell us about your system."
exit 1
fi
}
validate_ver() {
echo "$(version) < $1" | bc
}
case "$(dist)" in
debian)
if [ $(validate_ver "8.0") -eq 1 ]; then
upstart
else
systemd $1
fi
;;
ubuntu)
if [ $(validate_ver "14.10") -eq 1 ]; then
upstart
else
systemd $1
fi
;;
*)
echo "\033[33m Your system $(dist) $(version) \033[0m"
echo "\033[33m This system is not supported, you can install service manually \033[0m"
;;
esac
exit 0

View File

@@ -0,0 +1,27 @@
#!/bin/sh
set -e
if [ -f /etc/drone/drone.toml ]; then
chmod 600 /etc/drone/drone.toml
fi
if which systemctl > /dev/null; then
echo "Using systemd to control Drone"
cp /usr/share/drone/systemd/drone.service /lib/systemd/system/drone.service
systemctl daemon-reload || :
if [ "$1" = 1 ] ; then
# first time install
systemctl enable drone || :
systemctl start drone || :
else
echo "Upgrading drone"
fi
else
echo "Couldn't find systemd to control Drone, cannot proceed."
echo "Open an issue and tell us about your system."
exit 1
fi
exit 0

View File

@@ -0,0 +1,50 @@
#!/bin/sh
set -e
dist() {
lsb_release -i | awk '{print tolower($3)}' | sed -e 's/^ *//' -e 's/ *$//'
}
version() {
lsb_release -r | awk '{print $2}' | sed -e 's/^ *//' -e 's/ *$//'
}
upstart() {
rm -f /etc/init/drone.conf
}
systemd() {
rm -f /lib/systemd/system/drone.service
}
validate_ver() {
echo "$(version) < $1" | bc
}
case "$(dist)" in
debian)
if [ $(validate_ver "8.0") -eq 1 ]; then
upstart
else
systemd
fi
;;
ubuntu)
if [ $(validate_ver "14.10") -eq 1 ]; then
upstart
else
systemd
fi
;;
*)
echo "\033[33m Please remove service manually \033[0m"
;;
esac
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
if [ "$1" = "purge" ] ; then
echo "Purging drone configuration"
rm -rf /etc/drone
fi

View File

@@ -0,0 +1,11 @@
#!/bin/sh
set -e
# https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch09s04s05.html
systemctl daemon-reload || :
if [ "$1" -ge 1 ] ; then
# Package upgrade, not uninstall
systemctl try-restart drone || :
fi

View File

@@ -0,0 +1,51 @@
#!/bin/sh
set -e
dist() {
lsb_release -i | awk '{print tolower($3)}' | sed -e 's/^ *//' -e 's/ *$//'
}
version() {
lsb_release -r | awk '{print $2}' | sed -e 's/^ *//' -e 's/ *$//'
}
echo Stopping drone
upstart() {
initctl stop drone || :
}
systemd() {
if [ "$1" -eq 0 ] ; then
systemctl --no-reload disable drone || :
systemctl stop drone || :
fi
}
validate_ver() {
echo "$(version) < $1" | bc
}
case "$(dist)" in
debian)
if [ $(validate_ver "8.0") -eq 1 ]; then
upstart
else
systemd $1
fi
;;
ubuntu)
if [ $(validate_ver "14.10") -eq 1 ]; then
upstart
else
systemd $1
fi
;;
*)
if [ -f /usr/local/bin/droned ]; then
if pidof /usr/local/bin/droned >/dev/null; then
kill -9 `pidof /usr/local/bin/droned`
fi
fi
;;
esac

View File

@@ -0,0 +1,8 @@
#!/bin/sh
set -e
if [ "$1" -eq 0 ] ; then
echo Stopping Drone
systemctl --no-reload disable drone || :
systemctl stop drone || :
fi