diff --git a/Makefile b/Makefile index eed6717bb..25081480b 100644 --- a/Makefile +++ b/Makefile @@ -62,10 +62,10 @@ copyfiles: PLUGIN_PATH=${CORE_PLUGINS_PATH} plugn enable $$plugin ;\ PLUGIN_PATH=${PLUGINS_PATH} plugn enable $$plugin ;\ done - chown dokku:dokku -R ${PLUGINS_PATH} ${CORE_PLUGINS_PATH} + chown dokku:dokku -R ${PLUGINS_PATH} ${CORE_PLUGINS_PATH} || true $(MAKE) addman -addman: +addman: help2man mkdir -p /usr/local/share/man/man1 help2man -Nh help -v version -n "configure and get information from your dokku installation" -o /usr/local/share/man/man1/dokku.1 dokku mandb diff --git a/Vagrantfile b/Vagrantfile index 80403c638..4f3fc6c60 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -82,7 +82,7 @@ Vagrant::configure("2") do |config| vm.vm.hostname = "#{DOKKU_DOMAIN}" vm.vm.network :private_network, ip: DOKKU_IP vm.vm.provision :shell, :inline => "export DEBIAN_FRONTEND=noninteractive && apt-get update > /dev/null && apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}" - vm.vm.provision :shell, :inline => "cd /root/dokku && make deb-all" + vm.vm.provision :shell, :inline => "export IS_RELEASE=true && cd /root/dokku && make deb-all" end config.vm.define "build-arch", autostart: false do |vm| diff --git a/deb.mk b/deb.mk index eac734a1e..27875cc30 100644 --- a/deb.mk +++ b/deb.mk @@ -44,6 +44,10 @@ SIGIL_ARCHITECTURE = amd64 SIGIL_PACKAGE_NAME = gliderlabs_sigil_$(SIGIL_VERSION)_$(SIGIL_ARCHITECTURE).deb SIGIL_URL = https://github.com/gliderlabs/sigil/releases/download/v$(SIGIL_VERSION)/sigil_$(SIGIL_VERSION)_Linux_x86_64.tgz +ifndef IS_RELEASE + IS_RELEASE = true +endif + export PLUGN_DESCRIPTION export SIGIL_DESCRIPTION export SSHCOMMAND_DESCRIPTION @@ -64,18 +68,18 @@ install-from-deb: sudo apt-get update -qq > /dev/null sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -yy dokku -deb-all: deb-herokuish deb-dokku deb-plugn deb-sshcommand deb-sigil +deb-all: deb-setup deb-herokuish deb-dokku deb-plugn deb-sshcommand deb-sigil mv /tmp/*.deb . @echo "Done" deb-setup: @echo "-> Updating deb repository and installing build requirements" @sudo apt-get update -qq > /dev/null - @sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -qq -y gcc git ruby-dev ruby1.9.1 lintian > /dev/null 2>&1 + @sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -qq -y gcc git build-essential wget ruby-dev ruby1.9.1 lintian > /dev/null 2>&1 @command -v fpm > /dev/null || sudo gem install fpm --no-ri --no-rdoc @ssh -o StrictHostKeyChecking=no git@github.com || true -deb-herokuish: deb-setup +deb-herokuish: rm -rf /tmp/tmp /tmp/build $(HEROKUISH_PACKAGE_NAME) mkdir -p /tmp/tmp /tmp/build @@ -102,16 +106,17 @@ deb-herokuish: deb-setup sudo fpm -t deb -s dir -C /tmp/build -n herokuish -v $(HEROKUISH_VERSION) -a $(HEROKUISH_ARCHITECTURE) -p $(HEROKUISH_PACKAGE_NAME) --deb-pre-depends 'docker-engine-cs (>= 1.9.1) | docker-engine (>= 1.9.1)' --deb-pre-depends sudo --after-install /tmp/tmp/post-install --url "https://github.com/$(HEROKUISH_REPO_NAME)" --description $(HEROKUISH_DESCRIPTION) --license 'MIT License' . mv *.deb /tmp -deb-dokku: deb-setup +deb-dokku: rm -rf /tmp/tmp /tmp/build dokku_*_$(DOKKU_ARCHITECTURE).deb mkdir -p /tmp/tmp /tmp/build cp -r debian /tmp/build/DEBIAN mkdir -p /tmp/build/usr/bin - mkdir -p /tmp/build/var/lib/dokku/core-plugins/available - mkdir -p /tmp/build/usr/share/man/man1 - mkdir -p /tmp/build/usr/share/dokku/contrib mkdir -p /tmp/build/usr/share/doc/dokku + mkdir -p /tmp/build/usr/share/dokku/contrib + mkdir -p /tmp/build/usr/share/lintian/overrides + mkdir -p /tmp/build/usr/share/man/man1 + mkdir -p /tmp/build/var/lib/dokku/core-plugins/available cp dokku /tmp/build/usr/bin cp LICENSE /tmp/build/usr/share/doc/dokku/copyright @@ -125,12 +130,17 @@ deb-dokku: deb-setup cp contrib/dokku-installer.py /tmp/build/usr/share/dokku/contrib git describe --tags > /tmp/build/var/lib/dokku/VERSION cat /tmp/build/var/lib/dokku/VERSION | cut -d '-' -f 1 | cut -d 'v' -f 2 > /tmp/build/var/lib/dokku/STABLE_VERSION +ifneq (,$(findstring false,$(IS_RELEASE))) + sed -i.bak -e "s/^/`date +%s`:/" /tmp/build/var/lib/dokku/STABLE_VERSION && rm /tmp/build/var/lib/dokku/STABLE_VERSION.bak +endif + rm /tmp/build/DEBIAN/lintian-overrides + mv debian/lintian-overrides /tmp/build/usr/share/lintian/overrides/dokku git rev-parse HEAD > /tmp/build/var/lib/dokku/GIT_REV sed -i "s/^Version: .*/Version: `cat /tmp/build/var/lib/dokku/STABLE_VERSION`/g" /tmp/build/DEBIAN/control - dpkg-deb --build /tmp/build "/vagrant/dokku_`cat /tmp/build/var/lib/dokku/STABLE_VERSION`_$(DOKKU_ARCHITECTURE).deb" - mv *.deb /tmp + dpkg-deb --build /tmp/build "/tmp/dokku_`cat /tmp/build/var/lib/dokku/STABLE_VERSION`_$(DOKKU_ARCHITECTURE).deb" + lintian "/tmp/dokku_`cat /tmp/build/var/lib/dokku/STABLE_VERSION`_$(DOKKU_ARCHITECTURE).deb" -deb-plugn: deb-setup +deb-plugn: rm -rf /tmp/tmp /tmp/build $(PLUGN_PACKAGE_NAME) mkdir -p /tmp/tmp /tmp/build /tmp/build/usr/bin @@ -179,7 +189,7 @@ deb-sshcommand: . mv *.deb /tmp -deb-sigil: deb-setup +deb-sigil: rm -rf /tmp/tmp /tmp/build $(SIGIL_PACKAGE_NAME) mkdir -p /tmp/tmp /tmp/build /tmp/build/usr/bin diff --git a/debian/config b/debian/config index 8b294e076..d988e0516 100755 --- a/debian/config +++ b/debian/config @@ -1,6 +1,10 @@ -#!/bin/sh -e +#!/bin/bash +set -eo pipefail; [[ $TRACE ]] && set -x -. /usr/share/debconf/confmodule +if [[ -e /usr/share/debconf/confmodule ]]; then + # shellcheck disable=SC1091 + . /usr/share/debconf/confmodule +fi readonly ACTION="${1:-configure}" readonly VERSION="${2:-dev}" diff --git a/debian/lintian-overrides b/debian/lintian-overrides new file mode 100644 index 000000000..5fb3547e9 --- /dev/null +++ b/debian/lintian-overrides @@ -0,0 +1,3 @@ +dokku: command-with-path-in-maintainer-script postinst:16 /usr/bin/sshcommand +dokku: maintainer-script-calls-systemctl postinst:87 +dokku: changelog-file-missing-in-native-package diff --git a/debian/postinst b/debian/postinst index 920be1830..424c82322 100755 --- a/debian/postinst +++ b/debian/postinst @@ -1,11 +1,25 @@ #!/bin/bash set -eo pipefail; [[ $TRACE ]] && set -x -. /usr/share/debconf/confmodule +if [[ -e /usr/share/debconf/confmodule ]]; then + # shellcheck disable=SC1091 + . /usr/share/debconf/confmodule +fi readonly DOKKU_ROOT="${DOKKU_ROOT:-/home/dokku}" readonly DOKKU_LIB_ROOT="${DOKKU_LIB_PATH:-/var/lib/dokku}" +call-sshcommand() { + if [[ -x /usr/local/bin/sshcommand ]]; then + /usr/local/bin/sshcommand "$@" + elif [[ -x /usr/bin/sshcommand ]]; then + /usr/bin/sshcommand "$@" + else + echo "Unable to find sshcommand binary" 1>&2 + exit 1 + fi +} + case "$1" in abort-upgrade|abort-remove|abort-deconfigure) ;; @@ -14,7 +28,8 @@ case "$1" in mandb [ ! -x /usr/bin/docker.io ] || ln -sf /usr/bin/docker.io /usr/local/bin/docker modprobe aufs || echo "WARNING: Restart server to finish installing dokku!" - sshcommand create dokku /usr/local/bin/dokku + call-sshcommand create dokku /usr/bin/dokku + egrep -i "^docker" /etc/group || groupadd docker usermod -aG docker dokku @@ -50,6 +65,13 @@ case "$1" in find -L ${DOKKU_LIB_ROOT} -type l -delete chown dokku:dokku -R ${DOKKU_LIB_ROOT}/plugins ${DOKKU_LIB_ROOT}/core-plugins + echo "Ensure proper sshcommand path" + echo '/usr/bin/dokku' > "${DOKKU_ROOT}/.sshcommand" + if [[ -f .ssh/authorized_keys ]]; then + sed -i.bak 's#/usr/local/bin/dokku#/usr/bin/dokku#' "${DOKKU_ROOT}/.ssh/authorized_keys" + rm "${DOKKU_ROOT}/.ssh/authorized_keys" + fi + echo "Install all core plugins" dokku plugin:install --core @@ -92,7 +114,7 @@ case "$1" in if [ -z "${DEBCONF_RECONFIGURE}" ]; then db_get "dokku/key_file" if [ -f "$RET" ]; then - sshcommand acl-add dokku default < "$RET" || true + call-sshcommand acl-add dokku default < "$RET" || true fi fi ;; diff --git a/debian/postrm b/debian/postrm index cd1a4f664..9e9feac9d 100755 --- a/debian/postrm +++ b/debian/postrm @@ -1,6 +1,11 @@ #!/bin/bash set -eo pipefail; [[ $TRACE ]] && set -x +if [[ -e /usr/share/debconf/confmodule ]]; then + # shellcheck disable=SC1091 + . /usr/share/debconf/confmodule +fi + readonly DOKKU_ROOT="${DOKKU_ROOT:-/home/dokku}" readonly DOKKU_LIB_ROOT="${DOKKU_LIB_PATH:-/var/lib/dokku}" @@ -35,10 +40,7 @@ main() { find ${DOKKU_ROOT} -type d -empty -delete fi - if [[ -e /usr/share/debconf/confmodule ]]; then - . /usr/share/debconf/confmodule - db_purge - fi + db_purge fi } diff --git a/debian/preinst b/debian/preinst index e5ae254b0..a9f11c882 100755 --- a/debian/preinst +++ b/debian/preinst @@ -1,7 +1,10 @@ #!/bin/bash set -eo pipefail; [[ $TRACE ]] && set -x -. /usr/share/debconf/confmodule +if [[ -e /usr/share/debconf/confmodule ]]; then + # shellcheck disable=SC1091 + . /usr/share/debconf/confmodule +fi case "$1" in install) diff --git a/docs/checks-examples.md b/docs/checks-examples.md index 766bcf07c..4098ee1c6 100644 --- a/docs/checks-examples.md +++ b/docs/checks-examples.md @@ -274,7 +274,7 @@ Could not start due to 1 failed checks. vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new' vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection =====> end myapp container output -/usr/local/bin/dokku: line 49: 23409 Killed dokku deploy "$APP" +/usr/bin/dokku: line 49: 23409 Killed dokku deploy "$APP" To dokku@dokku.example.com:myapp ! [remote rejected] dokku -> master (pre-receive hook declined) error: failed to push some refs to 'dokku@dokku.example.com:myapp' diff --git a/tests.mk b/tests.mk index 8754486df..8549d8259 100644 --- a/tests.mk +++ b/tests.mk @@ -36,9 +36,11 @@ else ifeq ($(shell grep dokku.me /root/.ssh/config),) echo "Host 127.0.0.1 \\r\\n Port 22333 \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config endif +ifneq ($(wildcard /etc/ssh/sshd_config),) ifeq ($(shell grep 22333 /etc/ssh/sshd_config),) sed --in-place "s:^Port 22:Port 22 \\nPort 22333:g" /etc/ssh/sshd_config restart ssh +endif endif @echo "-----> Installing SSH public key..."