forked from OpenHD/OpenHD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.sh
executable file
·132 lines (118 loc) · 4.42 KB
/
package.sh
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
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
################################################################################
# OpenHD
#
# Licensed under the GNU General Public License (GPL) Version 3.
#
# This software is provided "as-is," without warranty of any kind, express or
# implied, including but not limited to the warranties of merchantability,
# fitness for a particular purpose, and non-infringement. For details, see the
# full license in the LICENSE file provided with this source code.
#
# Non-Military Use Only:
# This software and its associated components are explicitly intended for
# civilian and non-military purposes. Use in any military or defense
# applications is strictly prohibited unless explicitly and individually
# licensed otherwise by the OpenHD Team.
#
# Contributors:
# A full list of contributors can be found at the OpenHD GitHub repository:
# https://github.com/OpenHD
#
# © OpenHD, All Rights Reserved.
################################################################################
set -euo pipefail # Enable strict error handling
CUSTOM="${1:-}"
PACKAGE_ARCH="${2:-}"
OS="${3:-}"
PKGDIR="/out/openhd-installdir/"
VERSION="2.6.2-$(date '+%Y%m%d%H%M')-$(git rev-parse --short HEAD)"
# Function to create the package directory structure
create_package_directory() {
echo "Creating package directory structure..."
rm -rf /tmp/openhd-installdir
mkdir -p \
"${PKGDIR}usr/local/bin" \
"${PKGDIR}tmp" \
"${PKGDIR}settings" \
"${PKGDIR}etc/systemd/system"
if [[ "${PACKAGE_ARCH}" != "x86_64" ]]; then
echo "Non-x86 architecture detected"
if [[ "${CUSTOM}" == "standard" ]]; then
cp systemd/openhd.service "${PKGDIR}etc/systemd/system/openhd.service"
else
cp systemd/openhd-x20.service "${PKGDIR}etc/systemd/system/openhd.service"
fi
else
mkdir -p "${PKGDIR}usr/share/applications/"
cp shortcuts/* "${PKGDIR}usr/share/applications/"
mkdir -p "${PKGDIR}usr/local/share/openhd_misc/"
cp shortcuts/OpenHD.ico "${PKGDIR}usr/local/share/openhd_misc/"
mkdir -p "${PKGDIR}etc/profile.d/"
cp desktop-truster.sh "${PKGDIR}etc/profile.d/"
chmod 777 "${PKGDIR}etc/profile.d/desktop-truster.sh"
fi
# Copy hardware.config based on architecture and custom type
echo "Copying hardware.config..."
if [[ "${PACKAGE_ARCH}" == "armhf" ]]; then
local config_dir
if [[ "${CUSTOM}" == "standard" ]]; then
config_dir="${PKGDIR}/boot/openhd/"
else
config_dir="${PKGDIR}/config/openhd/"
fi
mkdir -p "${config_dir}"
cp OpenHD/ohd_common/config/hardware.config "${config_dir}hardware.config"
else
echo "Skipping hardware.config copy for non-armhf architecture"
fi
}
# Function to build the package
build_package() {
echo "Building package..."
local package_name="openhd"
local packages=()
if [[ "${PACKAGE_ARCH}" == "armhf" ]]; then
if [[ "${CUSTOM}" == "standard" ]]; then
package_name="openhd"
packages+=(
libpoco-dev libcamera-openhd gst-openhd-plugins iw nmap aircrack-ng
i2c-tools libv4l-dev libusb-1.0-0 libpcap-dev libnl-3-dev libnl-genl-3-dev
libsdl2-2.0-0 libsodium-dev gstreamer1.0-plugins-{base,good,bad,ugly}
gstreamer1.0-{tools,alsa,pulseaudio}
)
else
package_name="openhd-x20"
packages+=(
libpoco-dev iw i2c-tools libv4l-dev libusb-1.0-0 libpcap-dev
libnl-3-dev libnl-genl-3-dev libsdl2-2.0-0 libsodium-dev
gstreamer1.0-plugins-{base,good,bad} gstreamer1.0-tools
)
fi
elif [[ "${PACKAGE_ARCH}" == "x86_64" ]]; then
packages+=(
libpoco-dev dkms qopenhd git iw nmap aircrack-ng i2c-tools libv4l-dev
libusb-1.0-0 libpcap-dev libnl-3-dev libnl-genl-3-dev libsdl2-2.0-0
libsodium-dev gstreamer1.0-plugins-{base,good,bad,ugly}
gstreamer1.0-{tools,alsa,pulseaudio}
)
fi
if dpkg -l | grep -q "qti-gstreamer1.0-plugins-bad-waylandsink"; then
package_name="${package_name}-QCom"
fi
rm -f "${package_name}_${VERSION}_${PACKAGE_ARCH}.deb"
cmake OpenHD/
make -j$(nproc)
mkdir -p "${PKGDIR}usr/local/bin/"
cp openhd "${PKGDIR}usr/local/bin/"
# Build the package using fpm
fpm -a "${PACKAGE_ARCH}" -s dir -t deb -n "${package_name}" -v "${VERSION}" -C "${PKGDIR}" \
-p "${package_name}_${VERSION}_${PACKAGE_ARCH}.deb" \
--after-install after-install.sh \
--before-install before-install.sh \
-d "$(IFS=','; echo "${packages[*]}")"
cp *.deb /out/
}
# Main execution
create_package_directory
build_package