summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 83de00b3d5c3295e576b0f7a416a18a5a7cf2219 (plain)
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
# Maintainer: Eugene Cherny <iam@oscii.ru>
pkgname=cabbage-git
pkgrel=1 
pkgver=1.0.0r1173
pkgdesc='A framework for audio software development'
arch=('x86_64')
url="http://cabbageaudio.com/"
license=('GPLv3')
makedepends=('freeglut' 'curl' 'jack' 'libxcomposite' 'libxrandr' 'libxcursor'
             'libx11' 'libxinerama' 'mesa' 'gtk3' 'vim')
depends=('csound' 'steinberg-vst36')
provides=('cabbage')
source=('git+https://github.com/rorywalsh/cabbage.git#branch=master'
        'git+https://github.com/WeAreROLI/JUCE.git#tag=5.2.0'
        'fix_paths.patch'
        'Cabbage.desktop'
        'CabbageLite.desktop')
md5sums=('SKIP'
         'SKIP'
         '0c2ddec78ea91ed5736bad0d81f21ea7'
         'c499a03801cf0e760c14759ab1927bef'
         '39992361c05babc4d12cbdcd2c3f6e04')

_projucer_dir="JUCE/extras/Projucer/Builds/LinuxMakefile/build/"
_projucer="${_projucer_dir}/Projucer"

function patch_strings_in_file() {
    # Source (Johan Hedin):
    # http://everydaywithlinux.blogspot.com/2012/11/patch-strings-in-binary-files-with-sed.html
    # Slight modification by Colin Wallace to force the pattern to capture the entire line
    # Usage: patch_strings_in_file <file> <pattern> <replacement>
    # replaces all occurances of <pattern> with <replacement> in <file>, padding
    # <replacement> with null characters to match the length
    # Unlike sed or patch, this works on binary files
    local FILE="$1"
    local PATTERN="$2"
    local REPLACEMENT="$3"

    # Find all unique strings in FILE that contain the pattern 
    STRINGS=$(strings ${FILE} | grep "^${PATTERN}$" | sort -u -r)

    if [ "${STRINGS}" != "" ] ; then
        echo "File '${FILE}' contains strings equal to '${PATTERN}':"

        for OLD_STRING in ${STRINGS} ; do
            # Create null terminated ASCII HEX representations of the strings
            OLD_STRING_HEX="$(echo -n ${OLD_STRING} | xxd -g 0 -u -ps -c 256)00"
            NEW_STRING_HEX="$(echo -n ${REPLACEMENT} | xxd -g 0 -u -ps -c 256)00"

            if [ ${#NEW_STRING_HEX} -le ${#OLD_STRING_HEX} ] ; then
                # Pad the replacement string with null terminations so the
                # length matches the original string
                while [ ${#NEW_STRING_HEX} -lt ${#OLD_STRING_HEX} ] ; do
                    NEW_STRING_HEX="${NEW_STRING_HEX}00"
                done

                # Now, replace every occurrence of OLD_STRING with NEW_STRING 
                echo -n "Replacing ${OLD_STRING} with ${REPLACEMENT}... "
                hexdump -ve '1/1 "%.2X"' ${FILE} | \
                sed "s/${OLD_STRING_HEX}/${NEW_STRING_HEX}/g" | \
                xxd -r -p > ${FILE}.tmp
                chmod --reference ${FILE} ${FILE}.tmp
                mv ${FILE}.tmp ${FILE}
                echo "Done!"
            else
                echo "New string '${NEW_STRING}' is longer than old" \
                     "string '${OLD_STRING}'. Skipping."
            fi
        done
    fi
}

prepare() {
  # Projucer - building here to use it in pkgver()

  sed -i -e "s/JUCER_ENABLE_GPL_MODE 0/JUCER_ENABLE_GPL_MODE 1/" \
            "${srcdir}/JUCE/extras/Projucer/JuceLibraryCode/AppConfig.h"
  cd "${srcdir}/JUCE/extras/Projucer/Builds/LinuxMakefile/"
  make -j4

  # a hack to make Projucer use the system's VST header path
  patch_strings_in_file "${srcdir}/${_projucer}" "~/SDKs/VST_SDK/VST3_SDK" "/usr/include/vst36"
  # will be replaced with the following once Cabbage is ported to JUCE 5.3.0
  # "${srcdir}/${_projucer_dir}" --set-global-search-path linux vst3Path /usr/include/vst36/

  # Cabbage

  cd "${srcdir}/cabbage"
  patch -p1 < ../../fix_paths.patch
}

pkgver() {
	cd "${srcdir}/cabbage"
	printf "1.0.0r%s" "$(git rev-list --count HEAD)"
}

build() {
  cd "${srcdir}/cabbage/Builds/LinuxMakefile"
  ./buildCabbage
}

package() {
  install -Dm644 Cabbage.desktop "${pkgdir}/usr/share/applications/Cabbage.desktop"
  install -Dm644 Cabbage.desktop "${pkgdir}/usr/share/applications/CabbageLite.desktop"

  cd "${srcdir}/cabbage/Builds/LinuxMakefile/CabbageBuild/"
  install -d "${pkgdir}/opt/Cabbage"
#  install -Dm644 Cabbage "${pkgdir}/opt/Cabbage/Cabbage"
#  install -Dm644 CabbageLite "${pkgdir}/opt/Cabbage/CabbageLite"
#  install -Dm644 CabbagePluginEffect.so "${pkgdir}/opt/Cabbage/CabbagePluginEffect.so"
#  install -Dm644 CabbagePluginSynth.so "${pkgdir}/opt/Cabbage/CabbagePluginSynth.so"
#  install -Dm644 cabbage.png "${pkgdir}/opt/Cabbage/cabbage.png"
#  install -Dm644 opcodes.txt "${pkgdir}/opt/Cabbage/opcodes.txt"
#  install -Dm644 Examples "${pkgdir}/opt/Cabbage/Examples"
  cp -R ./* "${pkgdir}/opt/Cabbage/"
  


  install -d "${pkgdir}/usr/bin"
  ln -s ../../opt/Cabbage/Cabbage "${pkgdir}/usr/bin/Cabbage"
  ln -s ../../opt/Cabbage/CabbageLite "${pkgdir}/usr/bin/CabbageLite"
}