blob: 71319d3c3b80d22ef8df96c7e84575259eb7c585 (
plain) (
blame)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
fetch_source() {
[ -e "${MODULE_DIR}/src" -a -d "${MODULE_DIR}/src" ] && \
{ rm -r "${MODULE_DIR}/src" || perror "Could not delete old src dir."; }
mkdir -p "${MODULE_DIR}/src" || perror "Could not mkdir src"
cd "${MODULE_DIR}/src" || perror "cd fail."
# Get directory listing
wget -O "index.html" "$REQUIRED_DOWNLOAD_BASE" || perror "Could not download vmware dir index"
VMWARE_BUNDLE_FILE=$(grep -E -o -i "href=\"VMware-$REQUIRED_TYPE-[^\"]+[\._\-]$ARCHREGEX[\._\-][^\"]+\"" "index.html" | head -n 1 | awk -F '"' '{printf $2}')
[ -z "$VMWARE_BUNDLE_FILE" ] && perror "Could not determine vmware $REQUIRED_TYPE bundle file for current arch from $MODULE_DIR/src/index.html"
# Download file
wget -O "$VMWARE_BUNDLE_FILE" "$REQUIRED_DOWNLOAD_BASE/$VMWARE_BUNDLE_FILE" || perror "Could not download $VMWARE_BUNDLE_FILE from $REQUIRED_DOWNLOAD_BASE"
if [[ "$VMWARE_BUNDLE_FILE" == *.tar ]]; then
tar -x "${VMWARE_BUNDLE_FILE%.tar}" -f "$VMWARE_BUNDLE_FILE" || perror "Could not untar downloaded $VMWARE_BUNDLE_FILE"
unlink "$VMWARE_BUNDLE_FILE"
VMWARE_BUNDLE_FILE="${VMWARE_BUNDLE_FILE%.tar}"
fi
cd - >/dev/null
}
build() {
local DELETE_FILES
DELETE_FILES=$(for LINE in $REQUIRED_VMWARE_DELETIONS;do echo rm -rf $LINE; done)
# prepare the build directory with the files needed during the chroot
cp "${MODULE_DIR}/src/$VMWARE_BUNDLE_FILE" "${MODULE_BUILD_DIR}/$VMWARE_BUNDLE_FILE"
cp -r "${MODULE_DIR}/patches" "${MODULE_BUILD_DIR}"
# sanity check to see if KERNEL_HEADERS_DIR is set and exists
[ -z "${KERNEL_HEADERS_DIR}" -o ! -e "${KERNEL_HEADERS_DIR}" ] && perror "KERNEL_HEADERS_DIR ('"${KERNEL_HEADERS_DIR}"') not found. Was the kernel module built?"
# build in two steps, to be able to use mltk function while patching modules
pinfo "Installing vmware per chroot..."
chroot_run "${MODULE_BUILD_DIR}" <<-EOF
# PS1='\[\e[1;33m\](chroot) \u@\h:\w\$ \[\e[1;32m\]' /bin/bash -norc # un-comment for debugging within chroot
$DELETE_FILES
yes | sh /"${VMWARE_BUNDLE_FILE}" --eulas-agreed --console --required
EOF
# check if we need to patch modules
cd "${MODULE_BUILD_DIR}/usr/lib/vmware/modules/source" \
|| perror "Could not cd to '${MODULE_BUILD_DIR}/usr/lib/vmware/modules/source'"
local KMOD SHORT PATCH MIN_KERN MAX_KERN
for KMOD in *.tar; do
SHORT="${KMOD%%.tar}"
[ -e ".${SHORT}.patched" ] && continue
for PATCH in $(find "${MODULE_DIR}/patches/" -name "${SHORT}__*__*.patch"); do
parse_patch_name "$PATCH"
[ -z "${MIN_KERN}" -o -z "${MAX_KERN}" ] && perror "Could not parse patch filename"
if version_lt "$TARGET_KERNEL_SHORT" "$MIN_KERN" || version_gt "$TARGET_KERNEL_SHORT" "$MAX_KERN"; then
pinfo "*NOT* applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$TARGET_KERNEL_SHORT)"
continue # Not suitable for our kernel
fi
pinfo "Applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$TARGET_KERNEL_SHORT)"
[ ! -d "${SHORT}-only" ] && tar xf "$KMOD"
[ ! -d "${SHORT}-only" ] && perror "untar of $KMOD failed."
cd "${SHORT}-only" || perror "Where is ${SHORT}-only?"
if ! patch -p1 < "$PATCH"; then
cd ..
rm -rf -- "${SHORT}-only"
perror "Applying $PATCH failed."
fi
cd ..
done
if [ -d "${SHORT}-only" ]; then
tar cf "$KMOD" "${SHORT}-only/" || perror "repacking of $KMOD failed."
rm -rf -- "${SHORT}-only"
touch ".${SHORT}.patched"
fi
done
cd "${MODULE_DIR}" || perror "Could not cd to '${MODULE_DIR}'"
# now build modules inside the chroot
chroot_run "${MODULE_BUILD_DIR}" <<-EOF
vmware-modconfig --console --build-mod -k "${TARGET_KERNEL_LONG}" vmnet $(which gcc) "${KERNEL_HEADERS_DIR}/include" vmplayer vmnet
vmware-modconfig --console --build-mod -k "${TARGET_KERNEL_LONG}" vmmon $(which gcc) "${KERNEL_HEADERS_DIR}/include" vmplayer vmmon
EOF
# cleanup unneeded files
rm -rf -- "${MODULE_BUILD_DIR}/etc/vmware-installer"
rm -rf -- "${MODULE_BUILD_DIR}/usr/lib/vmware-installer"
rm -rf -- "${MODULE_BUILD_DIR}/usr/lib/vmware-ovftool"
unlink "${MODULE_BUILD_DIR}/$VMWARE_BUNDLE_FILE"
}
post_copy() {
# FIXME: gconftool is copied without dependencies
tarcopy "$(find /usr/lib/ /usr/lib64 -name gconv -type d)" "$TARGET_BUILD_DIR"
# Update Icon cache for vmplayer
gtk-update-icon-cache-3.0 "${TARGET_BUILD_DIR}/usr/share/icons/hicolor/" || pwarning "update-icon-cache-3.0 failed."
# fix vmware-usbarbitrator bug
date +'%Y.%m.%d' >"${TARGET_BUILD_DIR}/etc/arch-release"
mkdir -p "$TARGET_BUILD_DIR/lib/modules/vmware/"
cp "${MODULE_BUILD_DIR}/lib/modules/$TARGET_KERNEL_LONG/vmplayer/"* "$TARGET_BUILD_DIR/lib/modules/vmware/" || perror "Could not cp vmware modules to target!"
}
parse_patch_name() {
[ $# -ne 1 ] && perror "parse_patch_name: Wrong parameter count."
local PATCH="$1"
# Kernel restriction
MIN_KERN=$(echo "$PATCH" | sed -r 's/^[^_]+__([0-9\.]+)-[0-9\.]+__[^_]+\.patch$/\1/g')
[[ "$MIN_KERN" == /* ]] && MIN_KERN=$(echo "$PATCH" | sed -r 's/^[^_]+__([0-9\.]+)__[^_]+\.patch$/\1/g')
MAX_KERN=$(echo "$PATCH" | sed -r 's/^[^_]+__[0-9\.]+-([0-9\.]+)__[^_]+\.patch$/\1/g')
[[ "$MAX_KERN" == /* ]] && MAX_KERN=$(echo "$PATCH" | sed -r 's/^[^_]+__([0-9\.]+)__[^_]+\.patch$/\1/g')
[[ "$MIN_KERN" == /* ]] && MIN_KERN=
[[ "$MAX_KERN" == /* ]] && MAX_KERN=
# TODO: Parse min and max vmplayer/workstation version
# vmware restriction
MIN_VMWARE=$(echo "$PATCH" | sed -r 's/^[^_]+__[^_]+__([0-9\.]+)-[^_]+\.patch$/\1/g')
[[ "$MIN_VMWARE" == /* ]] && MIN_VMWARE=$(echo "$PATCH" | sed -r 's/^[^_]+__[^_]+__([0-9\.]+)\.patch$/\1/g')
MAX_VMWARE=$(echo "$PATCH" | sed -r 's/^[^_]+__[^_]+__[^_]+-([0-9\.]+)\.patch$/\1/g')
[[ "$MAX_VMWARE" == /* ]] && MAX_VMWARE=$(echo "$PATCH" | sed -r 's/^[^_]+__[^_]+__([0-9\.]+)\.patch$/\1/g')
[[ "$MIN_VMWARE" == /* ]] && MIN_VMWARE=
[[ "$MAX_VMWARE" == /* ]] && MAX_VMWARE=
}
|