This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathpuppet-apply-dev
executable file
·82 lines (68 loc) · 2.13 KB
/
puppet-apply-dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
set -e
ANSI_YELLOW="\033[33m"
ANSI_BLUE="\033[34m"
ANSI_RESET="\033[0m"
ANSI_BOLD="\033[1m"
info () {
echo "${ANSI_BOLD}${ANSI_BLUE}INFO:${ANSI_RESET} ${ANSI_BOLD}${@}${ANSI_RESET}" >&2
}
warn () {
echo "${ANSI_BOLD}${ANSI_YELLOW}WARNING:${ANSI_RESET} ${ANSI_BOLD}${@}${ANSI_RESET}" >&2
}
safe_git_pull () {
local repo=$1
cd $1
local branch=$(git symbolic-ref HEAD | sed 's|^refs/heads/||')
if [ -f lock ]; then
warn "skipped updating ${repo} because 'lock' file exists"
elif [ "$branch" != "master" ]; then
warn "skipped updating ${repo} because on non-master branch"
elif ! git diff --quiet --ignore-submodules --no-ext-diff; then
warn "skipped updating ${repo} due to local changes"
else
if ! git fetch origin; then
warn "git fetch failed for ${repo}"
exit 1
fi
if ! git merge --ff-only origin/master; then
warn "updating ${repo} failed"
exit 1
fi
fi
}
cd "$(dirname "$0")"
cd ..
ROOT="$(pwd)"
SELF="${ROOT}/tools/puppet-apply-dev"
# Set NO_PULL to not bootstrap the machine with bundler, puppet etc.
# Set NO_GIT_PULL to not update the puppet Git repository
if [ -z "$NO_PULL" ]; then
info "preflight checks"
# Temporary workaround while dev VMs don't come with git preinstalled
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
PACKAGES="ruby1.9.1 ruby1.9.1-dev git build-essential libxml2-dev libxslt1-dev"
if ! dpkg -s $PACKAGES >/dev/null 2>&1; then
sudo apt-get update -y -qq
sudo apt-get install -y -qq $PACKAGES
fi
if ! gem list -i bundler >/dev/null 2>&1; then
sudo gem install bundler --no-ri --no-rdoc
fi
if [ -z "$NO_GIT_PULL" ]; then
safe_git_pull /var/govuk/govuk-puppet
fi
# Re-exec myself
NO_PULL=1 exec "$SELF" "$@"
fi
info "bundling"
bundle install --quiet
info "librarian-puppet"
bundle exec rake librarian:install
for dir in `ls vendor/modules`; do
test -d modules/$dir && info "modules/${dir} conflicts with vendor/modules/${dir}";
done
info "running puppet"
info "***If you see: E: Unable to locate package... errors, run sudo apt-get update***"
exec /var/govuk/govuk-puppet/tools/puppet-apply "$@"