-
Notifications
You must be signed in to change notification settings - Fork 2
/
bitwig-rpm.sh
executable file
·122 lines (102 loc) · 2.98 KB
/
bitwig-rpm.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
#!/bin/bash
SPEC=bitwig-studio.spec
function get_download_url()
{
echo "Determining latest stable version..." 1>&2
RELATIVE_URL=$(curl --silent -L bitwig.com | grep -Eo 'dl[^"]*installer_linux')
FULL_URL=https://www.bitwig.com/$RELATIVE_URL
curl -L --head -w '%{url_effective}' $FULL_URL 2>/dev/null | tail -n1
}
# Returns the path to the downloaded archive
function download_bitwig()
{
DOWNLOAD_URL=$(get_download_url)
TARGET_PATH=rpmbuild/SOURCES
FILENAME=$(basename $(echo $DOWNLOAD_URL | sed 's/?.*//'))
echo "Downloading $(echo $DOWNLOAD_URL | sed 's/?.*//')" 1>&2
curl --create-dirs --output-dir rpmbuild/SOURCES \
--remote-name -C - $DOWNLOAD_URL
echo $TARGET_PATH/$FILENAME
}
# Returns the filename of the created RPM
function rpm_basename()
{
base=$(basename -s .deb $DEBIAN_PKG)
fedora_release=$(cut -d ' ' -f 3 /etc/redhat-release)
arch=$(uname -m)
echo $base-1.fc$fedora_release.$arch.rpm
}
# Checks if the downloaded Debian package has already been converted to RPM
function check_if_already_built()
{
rpm=$(rpm_basename)
if [ -f $rpm ]; then
echo RPM package already built
echo Install using sudo dnf install $rpm
exit 0
fi
}
# Arguments: $1: path to debian package
function extract_deb()
{
echo Extracting $(basename $1)...
OUTPUT_DIRECTORY=rpmbuild/SOURCES
mkdir -p $OUTPUT_DIRECTORY
ar x --output $OUTPUT_DIRECTORY $1
}
function create_rpmspec()
{
CONTROL=$(mktemp)
tar axf $OUTPUT_DIRECTORY/control.tar.zst ./control -O > $CONTROL
echo "%global _topdir ./rpmbuild"
echo "%global __brp_mangle_shebangs %{nil}"
echo "%global __brp_check_rpaths %{nil}"
echo
echo "Name: bitwig-studio"
grep Version $CONTROL
echo "Release: 1%{?dist}"
echo "Summary: Digital Audio Workstation"
echo
echo "License: Proprietary"
echo "URL: $(grep Homepage $CONTROL | sed 's/Homepage: //')"
echo "SOURCE: rpmbuild/SOURCES/data.tar.zst"
echo
echo "%description"
grep Descript -A1 $CONTROL | sed 's/Description: //'
echo
echo "%install"
echo "tar axf %{SOURCE0} -C %{buildroot}"
echo "find %{buildroot} -name '*.css' -exec chmod 0644 {} \;"
echo "find %{buildroot} -name '*.html' -exec chmod 0644 {} \;"
echo "find %{buildroot} -name '*.js' -exec chmod 0644 {} \;"
echo "find %{buildroot} -name '*.nckk' -exec chmod 0644 {} \;"
echo "find %{buildroot} -name '*.txt' -exec chmod 0644 {} \;"
echo
echo "%files"
echo /opt/bitwig-studio
LIST=$(tar tf rpmbuild/SOURCES/data.tar.zst | grep /usr | sed s/^.//g)
for x in $LIST; do # Filter existing system directories
[ ! -d $x ] && echo $x;
done
rm $CONTROL
}
function build_rpm()
{
echo "Building RPM..."
QA_RPATHS=$(( 0x0001|0x0002 )) rpmbuild --build-in-place -bb $SPEC &&
RPM_FILE=rpmbuild/RPMS/x86_64/$(rpm_basename) &&
mv $RPM_FILE "$PWD" &&
echo &&
echo RPM created. &&
echo Install using sudo dnf install $(basename $RPM_FILE)
}
if [ $# -eq 0 ]
then
DEBIAN_PKG=$(download_bitwig)
else
DEBIAN_PKG=$1
fi
check_if_already_built $DEBIAN_PKG
extract_deb $DEBIAN_PKG
create_rpmspec $DEBIAN_PKG > $SPEC
build_rpm