Skip to content

Commit

Permalink
deb packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
scivey committed Dec 1, 2015
1 parent 84fc689 commit 4804d0b
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ build
*.sublime-workspace
*~
*.deb

unwrap_deb
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,14 @@ publish-clients:
$(MAKE) -C clients/ruby publish
$(MAKE) -C clients/java publish

.PHONY: test-clients publish-clients
.PHONY: test-clients publish-clients unwrap-deb

unwrap-deb:
mkdir -p unwrap_deb && rm -rf unwrap_deb/*
cp build/deb/*.deb unwrap_deb/relevanced.deb
cd unwrap_deb && ar -vx relevanced.deb
mkdir -p unwrap_deb/control unwrap_deb/data
mv unwrap_deb/control.tar.gz unwrap_deb/control
mv unwrap_deb/data.tar.gz unwrap_deb/data
cd unwrap_deb/data && tar -xaf data.tar.gz
cd unwrap_deb/control && tar -xaf control.tar.gz
18 changes: 18 additions & 0 deletions scripts/packaging/deb/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -eu

# shamelessly stolen from redis

USER="relevanced"
GROUP="$USER"

chown $USER:$GROUP /var/lib/relevanced
chown $USER:$GROUP /var/log/relevanced

# Automatically added by dh_installinit
if [ -x "/etc/init.d/relevanced" ]; then
invoke-rc.d relevanced start || exit $?
fi
# End automatically added section

19 changes: 19 additions & 0 deletions scripts/packaging/deb/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

set -e

# shamelessly stolen from redis

if [ "$1" = "purge" ]
then
rm -rf /var/lib/relevanced
userdel relevanced
fi

# In case this system is running systemd, we make systemd reload the unit files
# to pick up changes.
if [ -d /run/systemd/system ] ; then
systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section

37 changes: 37 additions & 0 deletions scripts/packaging/deb/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

set -eu

# shamelessly stolen from redis

USER="relevanced"
GROUP="$USER"
HOME="/var/lib/relevanced"

# If we use NIS then errors should be tolerated.
if which ypwhich >/dev/null 2>&1 && ypwhich >/dev/null 2>&1
then
set +e
fi

if ! getent group $GROUP >/dev/null
then
addgroup --system $GROUP >/dev/null
fi

# creating user if it isn't already there
if ! getent passwd $USER >/dev/null
then
adduser \
--system \
--disabled-login \
--ingroup $GROUP \
--home $HOME \
--gecos "$USER server" \
--shell /bin/false \
$USER >/dev/null
fi

# end of NIS tolerance zone
set -e

10 changes: 10 additions & 0 deletions scripts/packaging/deb/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -e

#shamelessly stolen from redis

# Automatically added by dh_installinit
if [ -x "/etc/init.d/relevanced" ]; then
invoke-rc.d relevanced stop || exit $?
fi
# End automatically added section
File renamed without changes.
8 changes: 8 additions & 0 deletions scripts/packaging/etc/logrotate.d/relevanced
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/var/log/relevanced/*.log {
daily
missingok
copytruncate
rotate 12
compress
notifempty
}
File renamed without changes.
19 changes: 16 additions & 3 deletions scripts/packaging/make_linux_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ fi
OUTPUT_PKG_PATH="$BUILD_DIR/$PACKAGE_NAME-$PACKAGE_VERSION."

# Config files
INITD_SRC="$SCRIPT_DIR/relevanced.initd"
INITD_SRC="${SCRIPT_DIR}/etc/init.d/relevanced"
INITD_DST="/etc/init.d/relevanced"
JSON_CONFIG_SRC=${SCRIPT_DIR}/etc/relevanced/relevanced.json
LOGROTATE_CONFIG_SRC=${SCRIPT_DIR}/etc/logrotate.d/relevanced
RELEVANCED_LOG_DIR="/var/log/relevanced/"
RELEVANCED_VAR_DIR="/var/lib/relevanced"
RELEVANCED_ETC_DIR="/etc/relevanced"
Expand Down Expand Up @@ -100,14 +102,18 @@ function main() {
mkdir -p $INSTALL_PREFIX/$RELEVANCED_VAR_DIR/data
mkdir -p $INSTALL_PREFIX/$RELEVANCED_LOG_DIR
mkdir -p $INSTALL_PREFIX/$RELEVANCED_ETC_DIR
mkdir -p $INSTALL_PREFIX/etc/logrotate.d

mkdir -p `dirname $INSTALL_PREFIX$INITD_DST`
cp $SCRIPT_DIR/relevanced.json $INSTALL_PREFIX/$RELEVANCED_ETC_DIR/relevanced.json
cp $INITD_SRC $INSTALL_PREFIX$INITD_DST
cp $JSON_CONFIG_SRC $INSTALL_PREFIX/$RELEVANCED_ETC_DIR/relevanced.json

cp $INITD_SRC $INSTALL_PREFIX$INITD_DST
chmod g-w $INSTALL_PREFIX$INITD_DST
chmod a+x $INSTALL_PREFIX$INITD_DST

LOGROTATE_DEST=$INSTALL_PREFIX/etc/logrotate.d/relevanced
cp $LOGROTATE_CONFIG_SRC $LOGROTATE_DEST
chmod 644 $LOGROTATE_DEST
log "creating package"
IFS=',' read -a deps <<< "$PACKAGE_DEPENDENCIES"
PACKAGE_DEPENDENCIES=
Expand All @@ -128,11 +134,18 @@ function main() {
$PACKAGE_DEPENDENCIES \
-p $OUTPUT_PKG_PATH \
--config-files etc/relevanced/relevanced.json \
--config-files etc/init.d/relevanced \
--config-files etc/logrotate.d/relevanced \
--before-install ${SCRIPT_DIR}/deb/preinst \
--after-install ${SCRIPT_DIR}/deb/postinst \
--before-remove ${SCRIPT_DIR}/deb/prerm \
--after-remove ${SCRIPT_DIR}/deb/postrm \
--url http://www.relevanced.org \
-m [email protected] \
--license MIT \
--description \"$DESCRIPTION\" \
\"$INSTALL_PREFIX/=/\""
echo "running: $CMD"
eval "$CMD"
log "package created at $OUTPUT_PKG_PATH"
}
Expand Down

0 comments on commit 4804d0b

Please sign in to comment.