Skip to content

Commit 593c5f2

Browse files
committed
Rework scripts, fixes #25
1 parent 2c239da commit 593c5f2

File tree

9 files changed

+122
-103
lines changed

9 files changed

+122
-103
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ To build VMware Tools, do the following:
2323

2424
It is strongly suggested to use the [latest version](#tested-vmware-tools-versions) of VMware Tools. You can use [download-tools.sh](../../blob/master/download-tools.sh) to download the latest version.
2525

26-
4. Apply the patches, and then run the `vmware-install.pl` installer:
26+
4. Untar the tarball, and apply the patches:
2727
````bash
2828
$ cd vmware-tools-patches
29-
$ ./untar-and-patch-and-compile.sh
29+
$ ./untar-and-patch.sh
30+
````
31+
32+
5. Run the `vmware-install.pl` installer to install VMware Tools:
33+
````bash
34+
$ ./compile.sh
3035
````
3136

3237
## Tested Kernels

compile.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
# compile and install VMware Tools
4+
5+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
7+
if [[ ! -d vmware-tools-distrib ]]; then
8+
echo $0: Error: Directory not found: vmware-tools-distrib >&2
9+
exit 3
10+
fi
11+
12+
if hash vmware-uninstall-tools.pl >/dev/null 2>&1; then
13+
sudo vmware-uninstall-tools.pl
14+
fi
15+
16+
if [ -e /etc/redhat-release ]; then
17+
if hash yum >/dev/null 2>&1; then
18+
sudo yum -y install gcc glibc-headers kernel-devel kernel-headers make perl
19+
fi
20+
fi
21+
22+
if [[ -e /etc/debian_version ]]; then
23+
if hash apt-get >/dev/null 2>&1; then
24+
sudo apt-get install -y build-essential dkms linux-headers-$(uname -r) patch psmisc
25+
fi
26+
fi
27+
28+
VMWARE_INSTALL_OPTIONS="--clobber-kernel-modules=pvscsi,vmblock,vmci,vmhgfs,vmmemctl,vmsync,vmxnet,vmxnet3,vsock"
29+
30+
if [[ -n "$1" ]]; then
31+
VMWARE_INSTALL_OPTIONS="$1"
32+
fi
33+
34+
pushd vmware-tools-distrib >/dev/null
35+
36+
sudo ./vmware-install.pl -d ${VMWARE_INSTALL_OPTIONS}
37+
38+
popd >/dev/null

download-patches.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pushd patches
3333
${WGET} "${url}"
3434

3535
if [[ "${file}" = "vmware9.compat_mm.patch" ]]; then
36-
perl -pi.bak -e 's|(vmware9.compat_mm.patch)|shared/\1|;' "${file}"
36+
sed -i.bak -e 's/\(vmware9.compat_mm.patch\)/shared\/\1/;' "${file}"
3737
fi
3838

3939
popd

patch-module.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pushd lib/modules/source >/dev/null
6464
for patch in ${patches}; do
6565
base="$(basename ${patch})"
6666
dir="$(basename $(dirname ${patch}))"
67-
patch --batch --ignore-whitespace --strip=1 --dry-run < "${patch}" >/dev/null 2>&1
67+
patch --batch --ignore-whitespace --strip=1 --dry-run < "${patch}" >$base.patch.err 2>&1
6868
if [ $? -eq 0 ]; then
6969
echo "*** Applying ${dir}/${base} ..."
7070
patch --batch --ignore-whitespace --strip=1 --backup < "${patch}"
@@ -88,8 +88,4 @@ pushd lib/modules/source >/dev/null
8888

8989
tar -cf "${module}.tar" "${module}-only"
9090

91-
if [[ -z "${VMWARE_TOOLS_PATCHES_DEBUG}" ]]; then
92-
rm -rf "${module}-only"
93-
fi
94-
9591
popd >/dev/null

patch-modules.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

patch.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# apply patches for all modules
4+
5+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
7+
if [[ ! -d vmware-tools-distrib ]]; then
8+
echo $0: Error: Directory not found: vmware-tools-distrib >&2
9+
exit 3
10+
fi
11+
12+
if ! hash patch >/dev/null 2>&1; then
13+
if hash apt-get >/dev/null 2>&1; then
14+
sudo apt-get install -y patch
15+
else
16+
echo $0: Command not found: patch >&2
17+
exit 1
18+
fi
19+
fi
20+
21+
modules="$(find ${SCRIPT_DIR}/patches -mindepth 1 -maxdepth 1 -type d)"
22+
23+
pushd vmware-tools-distrib >/dev/null
24+
25+
if [[ -n "${modules}" ]]; then
26+
for module in ${modules}; do
27+
"${SCRIPT_DIR}/patch-module.sh" "${module}"
28+
done
29+
fi
30+
31+
popd >/dev/null
32+
33+
if [[ "${VMWARE_TOOLS_PATCHES_DEBUG-}" =~ (pause|PAUSE) ]]; then
34+
read -p "Press [Enter] to continue: "
35+
fi

untar-and-patch-and-compile.sh

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,11 @@
11
#!/usr/bin/env bash
22

3-
# untar a single VMwareTools .tar.gz file, and apply patches for all modules, and compile
3+
# untar a single VMwareTools .tar.gz file, apply patches for all modules, and compile and install VMware Tools
44

55
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66

7-
tool="$1"
7+
"${SCRIPT_DIR}/untar-and-patch.sh" "$1"
88

9-
if [[ -z "${tool}" ]]; then
10-
tool="$(find -type f -name 'VMwareTools-*.tar.gz' | sort -nr | head -n 1)"
11-
fi
9+
shift
1210

13-
if [[ -z "${tool}" ]]; then
14-
echo Usage: $0 tarname >&2
15-
exit 1
16-
fi
17-
18-
if [[ ! -f "${tool}" ]]; then
19-
echo $0: Error: File not found: ${tool} >&2
20-
exit 2
21-
fi
22-
23-
rm -fr vmware-tools-distrib
24-
25-
echo -e "=== Patching ${tool} ...\n"
26-
27-
tar xzf "${tool}"
28-
29-
if [[ ! -d vmware-tools-distrib ]]; then
30-
echo $0: Error: Directory not found: vmware-tools-distrib >&2
31-
exit 3
32-
fi
33-
34-
if hash vmware-uninstall-tools.pl >/dev/null 2>&1; then
35-
sudo vmware-uninstall-tools.pl
36-
fi
37-
38-
if hash apt-get >/dev/null 2>&1; then
39-
sudo apt-get install -y linux-headers-$(uname -r) build-essential dkms psmisc patch
40-
fi
41-
42-
pushd vmware-tools-distrib >/dev/null
43-
44-
"${SCRIPT_DIR}/patch-modules.sh"
45-
46-
sudo ./vmware-install.pl -d --clobber-kernel-modules=pvscsi,vmblock,vmci,vmhgfs,vmmemctl,vmsync,vmxnet,vmxnet3,vsock
47-
48-
popd >/dev/null
49-
50-
if [[ -z "${VMWARE_TOOLS_PATCHES_DEBUG}" ]]; then
51-
rm -fr vmware-tools-distrib
52-
fi
11+
"${SCRIPT_DIR}/compile.sh" $*

untar-and-patch.sh

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,6 @@
44

55
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66

7-
tool="$1"
7+
"${SCRIPT_DIR}/untar.sh" "$1"
88

9-
if [[ -z "${tool}" ]]; then
10-
tool="$(find -type f -name 'VMwareTools-*.tar.gz' | sort -nr | head -n 1)"
11-
fi
12-
13-
if [[ -z "${tool}" ]]; then
14-
echo Usage: $0 tarname >&2
15-
exit 1
16-
fi
17-
18-
if [[ ! -f "${tool}" ]]; then
19-
echo $0: Error: File not found: ${tool} >&2
20-
exit 2
21-
fi
22-
23-
rm -fr vmware-tools-distrib
24-
25-
echo -e "=== Patching ${tool} ...\n"
26-
27-
tar xzf "${tool}"
28-
29-
if [[ ! -d vmware-tools-distrib ]]; then
30-
echo $0: Error: Directory not found: vmware-tools-distrib >&2
31-
exit 3
32-
fi
33-
34-
pushd vmware-tools-distrib >/dev/null
35-
36-
"${SCRIPT_DIR}/patch-modules.sh"
37-
38-
popd >/dev/null
39-
40-
if [[ -z "${VMWARE_TOOLS_PATCHES_DEBUG}" ]]; then
41-
rm -fr vmware-tools-distrib
42-
fi
9+
"${SCRIPT_DIR}/patch.sh"

untar.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
# untar a single VMwareTools-*.tar.gz file
4+
5+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
7+
tool="$1"
8+
9+
if [[ -z "${tool}" ]]; then
10+
tool="$(find -type f -name 'VMwareTools-*.tar.gz' | sort -nr | head -n 1)"
11+
fi
12+
13+
if [[ -z "${tool}" ]]; then
14+
echo Usage: $0 tarname >&2
15+
exit 1
16+
fi
17+
18+
if [[ ! -f "${tool}" ]]; then
19+
echo $0: Error: File not found: ${tool} >&2
20+
exit 2
21+
fi
22+
23+
echo $(basename "$0"): Patching ${tool}
24+
25+
rm -fr vmware-tools-distrib
26+
27+
echo -e "=== Patching ${tool} ...\n"
28+
29+
tar xzf "${tool}"
30+
31+
if [[ ! -d vmware-tools-distrib ]]; then
32+
echo $0: Error: Directory not found: vmware-tools-distrib >&2
33+
exit 3
34+
fi

0 commit comments

Comments
 (0)