-
Notifications
You must be signed in to change notification settings - Fork 0
/
chef-workstation.SlackBuild
executable file
·97 lines (74 loc) · 3.42 KB
/
chef-workstation.SlackBuild
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
# Copyright 2009-2010 Erik Hanson, Minneapolis, MN, USA
# Copyright 2011, 2015 Patrick J. Volkerding, Sebeka, MN, USA
# Copyright 2018-2020 Zak B. Elep, Makati, Manila, Philippines
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PKGNAM=chef-workstation
RELEASE=${RELEASE:-21.7.524-1}
# Allow $ARCH to be preset before running the script. This is useful in the
# case where someone is running a 32-bit chroot environment under an x86_64
# kernel:
ARCH="x86_64"
DEBARCH="amd64"
# Get the version from the Debian/Ubuntu .deb (thanks to Fred Richards):
VERSION=$(ar p "chef-workstation_${RELEASE}_${DEBARCH}.deb" control.tar.gz 2> /dev/null | tar zxO ./control 2> /dev/null | grep Version | awk '{print $2}' | cut -d- -f1)
BUILD=${BUILD:-1zakame}
if [ ! "$(id -u)" = 0 ]; then
cat << EOF
This script must be run as root.
EOF
exit 1
fi
if ! /bin/ls chef-workstation_*.deb 1> /dev/null 2> /dev/null ; then
cat << EOF
This is a script to repackage a chef-workstation .deb package
for Slackware. Run this script in the same directory as this
binary package:
chef-workstation_${RELEASE}_${DEBARCH}.deb
This will create a Slackware .txz package. Install it with installpkg
or use upgradepkg to upgrade from a previous version.
EOF
exit 1
fi
CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-$PKGNAM
OUTPUT=${OUTPUT:-/tmp}
/bin/sha256sum -c chef-workstation.checksums || exit 1
rm -rf "$PKG"
mkdir -p "$TMP" "$PKG" "$OUTPUT"
cd "$PKG" || exit 1
ar p "$CWD/chef-workstation_${RELEASE}_${DEBARCH}.deb" data.tar.xz | tar xJv || exit 1
chown -R root:root .
chmod -R u+w,go+r-w,a-s .
# Link binaries in /opt/chef-workstation/bin to /usr/bin:
binaries="berks chef chef-analyze chef-apply chef-automate-collect chef-cli chef-client chef-resource-inspector chef-run chef-service-manager chef-shell chef-solo chef-vault chef-windows-service chef-zero cookstyle delivery fauxhai foodcritic hab inspec kitchen knife mixlib-install ohai stove"
mkdir -p "$PKG/usr/bin"
for binary in $binaries; do
( cd "$PKG/usr/bin" || exit 1 ; ln -sf "../../opt/chef-workstation/bin/$binary" "$binary" )
done
# Link experimental chef-workstation-app to /usr/bin:
( cd "$PKG/usr/bin" || exit 1 ; ln -sf ../../opt/chef-workstation/components/chef-workstation-app/chef-workstation-app chef-workstation-app )
# Make sure top-level perms are correct:
chmod 0755 .
mkdir -p "$PKG/install"
cat "$CWD/slack-desc" > "$PKG/install/slack-desc"
cd "$PKG" || exit 1
/sbin/makepkg -l y -c n "$OUTPUT/$PKGNAM-$VERSION-$ARCH-$BUILD.txz"