From daece03c7a90bab30b8e9c0ba1330261a6e3dd70 Mon Sep 17 00:00:00 2001 From: Praveen Arimbrathodiyil Date: Thu, 8 Dec 2016 23:46:56 +0530 Subject: [PATCH] add dpkg trigger to recreate Gemfile.lock --- debian/adduser.sh | 2 ++ debian/gitlab.triggers | 1 + debian/postinst | 68 +++++++++++++++++++++++++++++------------- 3 files changed, 51 insertions(+), 20 deletions(-) create mode 100644 debian/gitlab.triggers diff --git a/debian/adduser.sh b/debian/adduser.sh index 2649fdc019..5c484e2925 100755 --- a/debian/adduser.sh +++ b/debian/adduser.sh @@ -12,3 +12,5 @@ adduser --system --home /var/lib/${gitlab_user} --gecos "${gitlab_user} user" -- --quiet --disabled-password --group ${gitlab_user} || { echo "Proceeding with existing ${gitlab_user} user..." } +echo "Making ${gitlab_user} owner of /var/lib/${gitlab_user}..." +chown -R ${gitlab_user} /var/lib/${gitlab_user} diff --git a/debian/gitlab.triggers b/debian/gitlab.triggers new file mode 100644 index 0000000000..e64f8f7ecb --- /dev/null +++ b/debian/gitlab.triggers @@ -0,0 +1 @@ +interest-noawait /usr/lib/ruby/vendor_ruby diff --git a/debian/postinst b/debian/postinst index 5d94f719b1..4858540097 100755 --- a/debian/postinst +++ b/debian/postinst @@ -7,6 +7,9 @@ set -e +# Show debconf questions +. /usr/share/debconf/confmodule + # summary of how this script can be called: # * `configure' # * `abort-upgrade' @@ -25,28 +28,51 @@ set -e # installation fails and the `postinst' is called with `abort-upgrade', # `abort-remove' or `abort-deconfigure'. +####################################################################### +# Read and export debian specific configuration +# Only exported variables will be passed on to gitlab app +####################################################################### + +# Bootstrap config file - first try +gitlab_debian_conf_example=/usr/share/doc/gitlab/gitlab-debian.conf.example +export $(cat ${gitlab_debian_conf_example}) +# second try +test -f ${gitlab_debian_conf_private} || \ +cp ${gitlab_debian_conf_example} ${gitlab_debian_conf_private} +export $(cat ${gitlab_debian_conf_private}) + +# If /etc/gitlab/gitlab-debian.conf is already present, use it +test -f ${gitlab_debian_conf} && export $(cat ${gitlab_debian_conf}) + +# Create gitlab user +. /usr/lib/gitlab/scripts/adduser.sh + +####################################################################### +# update Gemfile.lock, always +####################################################################### +su ${gitlab_user} -s /bin/sh -c 'truncate -s 0 ${gitlab_data_dir}/Gemfile.lock' +cd ${gitlab_app_root} +if ! su ${gitlab_user} -s /bin/sh -c 'bundle --local --quiet'; then + if [ "$1" = "triggered" ]; then + # probably triggered in the middle of an system upgrade; ignore failure + # but abort here + echo "#########################################################################" + echo "# Failed to detect gitlab dependencies; if you are in the middle of an #" + echo "# upgrade, this is probably fine, there will be another attempt later. #" + echo "# #" + echo "# If you are NOT in the middle of an upgrade, there is probably a real #" + echo "# issue. Please report a bug. #" + echo "#########################################################################" + exit 0 + else + # something is really broken + exit 1 + fi +fi +cd - >/dev/null case "$1" in configure) - # Show debconf questions - . /usr/share/debconf/confmodule - - # Read and export debian specific configuration - # Only exported variables will be passed on to gitlab app - # Bootstrap config file - first try - gitlab_debian_conf_example=/usr/share/doc/gitlab/gitlab-debian.conf.example - export $(cat ${gitlab_debian_conf_example}) - # second try - test -f ${gitlab_debian_conf_private} || \ - cp ${gitlab_debian_conf_example} ${gitlab_debian_conf_private} - export $(cat ${gitlab_debian_conf_private}) - - # If /etc/gitlab/gitlab-debian.conf is already present, use it - test -f ${gitlab_debian_conf} && export $(cat ${gitlab_debian_conf}) - - # Create gitlab user - . /usr/lib/gitlab/scripts/adduser.sh - gitlab_builds_log=${gitlab_log_dir}/builds gitlab_repo_path=${gitlab_data_dir}/repositories gitlab_uploads_path=${gitlab_data_dir}/public/uploads @@ -222,8 +248,10 @@ EOF echo "Running final rake tasks and tweaks..." . /usr/lib/gitlab/scripts/rake-tasks.sh + ;; - + triggered) + # Already handled ;; abort-upgrade|abort-remove|abort-deconfigure)