Commit a8a515df authored by Yuanle Song's avatar Yuanle Song
Browse files

v1.6.3 put config files in their target dir in deb

- no longer use install command to copy them at install time.
- this allow better handling of systemd service file.
  also allow user to run apt remove and purge.

user should update ./utils/build-deb and deb-scripts if systemd service
file is used.

also dropped support for upstart. upstart is irrelevant now.
parent a7c468ce
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
(defproject python/lein-template "1.6.2"
(defproject python/lein-template "1.6.3"
  :description "lein template for a python project"
  :url "https://gitlab.emacsos.com/sylecn/python-project-template"
  :license {:name "Apache License 2.0"
+4 −16
Original line number Diff line number Diff line
@@ -15,20 +15,8 @@ cd "$PREFIX"
make bootstrap
# make install

# install crontab, systemd service, nginx site file, logrotate config etc
# systemctl start {{name}} || true
# systemctl enable {{name}} || true

# if you enable logrotate.conf, remember to choose a good rotate interval and
# set how many copies to keep.

# install -m 644 "$PREFIX/conf/logrotate.conf" /etc/logrotate.d/{{name}}
# install -m 644 "$PREFIX/conf/web.upstart" /etc/init/{{name}}.conf
# install -m 644 "$PREFIX/conf/web.service" /etc/systemd/system/{{name}}.service
# service {{name}} start || true

# SITE_FILE=/etc/nginx/conf.d/{{name}}.conf
# if [ -e "$SITE_FILE" ]; then
# 	echo "warning: not overwriting existing nginx site file $SITE_FILE"
# else
# 	install "$PREFIX/conf/http.site" "$SITE_FILE"
# 	service nginx reload
# fi
# if site file is installed
# systemctl reload nginx || true
+0 −8
Original line number Diff line number Diff line
#!/bin/sh
set -e

stop_upstart_service_maybe() {
	service="$1"
	if [ -e /etc/init/${service}.conf ]; then
		if status "$service" |grep 'start/running'; then
			stop "$service" || true
		fi
	fi
}
stop_systemd_service_maybe() {
	service="$1"
	if [ -e /etc/systemd/system/${service}.service ]; then
+3 −16
Original line number Diff line number Diff line
@@ -3,17 +3,10 @@ set -e

PREFIX=${PREFIX:-/opt/{{name}}}

stop_upstart_service_maybe() {
	service="$1"
	if [ -e /etc/init/${service}.conf ]; then
		if status "$service" |grep 'start/running'; then
			stop "$service" || true
		fi
	fi
}
stop_systemd_service_maybe() {
stop_and_disable_systemd_service_maybe() {
	service="$1"
	if [ -e /etc/systemd/system/${service}.service ]; then
		systemctl disable "$service" || true
		if systemctl -q is-active "$service"; then
			systemctl stop "$service" || true
		fi
@@ -22,13 +15,7 @@ stop_systemd_service_maybe() {

cd /

# stop_systemd_service_maybe {{name}}

# delete installed cron jobs, systemd service files, and binaries.
# rm -f /etc/logrotate.d/{{name}}
# rm -f /etc/init/{{name}}.conf
# rm -f /etc/systemd/system/{{name}}.service
# echo "You can safely delete /etc/nginx/conf.d/{{name}}.conf if it's no longer needed"
# stop_and_disable_systemd_service_maybe {{name}}

if [ -d "$PREFIX" ]; then
	make -C "$PREFIX" full-clean
+27 −3
Original line number Diff line number Diff line
@@ -7,6 +7,29 @@ create a deb package for this project."
	exit 1
}

build_dest_dir() {
	if [ -z "$DEST" ]; then
		DEST=DEST
	fi
	rm -rf "$DEST"
	mkdir -p "${DEST}${DEST_DIR}"
	for f in Makefile README.rst setup.py utils requirements*.txt wheelhouse conf $PYTHON_MODULES
	do
		cp -al "$PWD/$f" "${DEST}${DEST_DIR}/$f"
	done
	# mkdir -p ${DEST}/etc/systemd/system/
	# cp $PWD/conf/web.service ${DEST}/etc/systemd/system/{{name}}.service

	# if you enable logrotate.conf, remember to choose a good rotate
	# interval and set how many copies to keep.
	# mkdir -p ${DEST}/etc/logrotate.d/
	# cp $PWD/conf/logrotate.conf ${DEST}/etc/logrotate.d/{{name}}

	# nginx site file
	# mkdir -p ${DEST}/etc/nginx/conf.d/
	# cp $PWD/conf/https.site ${DEST}/etc/nginx/conf.d/{{name}}.conf
}

# main()
if [ "$1" = "--help" ]; then
	print_help_and_exit
@@ -22,8 +45,10 @@ if [ ! -d wheelhouse ]; then
	make wheel
fi

build_dest_dir

# add dependencies on libpq5 if you use psycopg2.
fpm -t deb -s dir -n "$DEB_PKG_NAME" -v "$VERSION" --prefix "$DEST_DIR" -f \
fpm -t deb -s dir -n "$DEB_PKG_NAME" -v "$VERSION" -f \
    --depends make \
    -x '*__pycache__' \
    -x '*.pyc' \
@@ -32,8 +57,7 @@ fpm -t deb -s dir -n "$DEB_PKG_NAME" -v "$VERSION" --prefix "$DEST_DIR" -f \
    --before-install deb-scripts/before-install.sh \
    --after-install deb-scripts/after-install.sh \
    --before-remove deb-scripts/before-remove.sh \
    Makefile README.rst setup.py utils requirements*.txt wheelhouse conf \
    $PYTHON_MODULES
    -C "$DEST" .

# create Dockerfile and .dockerignore file
DEB_PKG="{{name}}_${VERSION}_amd64.deb"