summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7e353645102d11b92d82917e9cdd61b944a40914 (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Maintainer: Yu-Hsuan Tu <dobe0331 at gmail dot com>
_pkgname=metashape-pro
pkgname=agisoft-${_pkgname}
pkgver=2.1.3
pkgrel=1
pkgdesc="Photogrammetric processing of digital images and 3D spatial data generation software. Professional edition"
arch=('x86_64')
url="https://www.agisoft.com/"
license=('custom:Agisoft EULA' 'custom')
depends=('gcc')
makedepends=('imagemagick')
optdepends=('glu: mesa OpenGL lib'
            'nvidia-utils: nvidia proprietary OpenGL lib'
            'opencl-clover-mesa: mesa clover OpenCL runtime for GPU acceleration'
            'opencl-rusticl-mesa: mesa rusticl OpenCL runtime for GPU acceleration'
            'opencl-amd: AMDGPU PRO OpenCL runtime for GPU acceleration'
            'cuda: nvidia CUDA runtime for GPU acceleration'
            'intel-compute-runtime: Intel Neo OpenCL runtime for GPU acceleration'
            'libffi6: QT5 API support in console')
provides=('agisoft-metashape-pro' 'agisoft-network-monitor' 'agisoft-viewer')
options=('!strip')
install=${pkgname}.install
source=("https://download.agisoft.com/${_pkgname}_${pkgver//./_}_amd64.tar.gz"
        "agisoft-metashape-pro-icon-encoded.txt"
        "agisoft-network-monitor-icon-encoded.txt"
        "agisoft-viewer-icon-encoded.txt"
        "agisoft-psx-mime-icon-encoded.txt"
        "agisoft-psz-mime-icon-encoded.txt"
        "agisoft-3dv-mime-icon-encoded.txt")
sha256sums=('613c8bc961c8a345d8da6bf9a602639ea876e5e61e1494e979b554863df31a7c'
            '959eb21ce482a5b1f84a0e04ec6f0d53aaf679c84bce9f813b350afe5dd201ba'
            'ef484e2a60966a722d7989abdbb85464054c47dd56b2ce182b2c0c5602476599'
            'a5e29a00393d55a9b589e1fb30acb57a96ef26756507d2793e7f3494d5778ae3'
            '627df01b98f9f22b31d62ba039127b7809650990d1633e4190f1d9844830a0ff'
            'd44fb70962175505fd3bfc0e96670e5bf4092c80446e0142cc91a3e0033e1009'
            '047225857a8b30362bab61f916ab1ddb19c0906959bf57c4ab5e499b8a9c4fc8')

build() {
    # Create desktop entries
    echo "[Desktop Entry]
Type=Application
Name=Agisoft MetaShape Pro
Comment=Photogrammetric processing software
Exec=agisoft-metashape-pro
MimeType=application/agisoft.psx;application/agisoft.psz
Icon=agisoft-metashape-pro
Terminal=false
Categories=Science;ImageProcessing" > "$srcdir/agisoft-metashape-pro.desktop"

    echo "[Desktop Entry]
Type=Application
Name=Agisoft Network Monitor
Comment=Monitor the network cluster of MetaShape
Exec=agisoft-network-monitor
Icon=agisoft-network-monitor
Terminal=false
Categories=Science;ImageProcessing" > "$srcdir/agisoft-network-monitor.desktop"

    echo "[Desktop Entry]
Type=Application
Name=Agisoft Viewer
Comment=Visualise the MetaShape output 3D data
Exec=agisoft-viewer
MimeType=application/agisoft.3dv;application/agisoft.vpz
Icon=agisoft-viewer
Terminal=false
Categories=Science;ImageProcessing" > "$srcdir/agisoft-viewer.desktop"

    # Create MetaShape MIME type file
    echo '<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/agisoft.psx">
        <comment>MetaShape Project</comment>
        <icon name="application-agisoft-pro-psx"/>
        <glob-deleteall/>
        <glob pattern="*.psx"/>
    </mime-type>
    <mime-type type="application/agisoft.psz">
        <comment>MetaShape Archive</comment>
        <icon name="application-agisoft-pro-psz"/>
        <glob-deleteall/>
        <glob pattern="*.psz"/>
    </mime-type>
    <mime-type type="application/agisoft.vpz">
        <comment>Viewer Project</comment>
        <icon name="application-agisoft-viewer-vpz"/>
        <glob-deleteall/>
        <glob pattern="*.vpz"/>
    </mime-type>
    <mime-type type="application/agisoft.3dv">
        <comment>Viewer 1.6 Project</comment>
        <icon name="application-agisoft-viewer-3dv"/>
        <glob-deleteall/>
        <glob pattern="*.3dv"/>
    </mime-type>
</mime-info>' > "$srcdir/${pkgname}-mime.xml"

    # Create 128x128 application icons
    base64 -d "$srcdir/agisoft-metashape-pro-icon-encoded.txt" > "$srcdir/agisoft-metashape-pro_128.png"
    base64 -d "$srcdir/agisoft-network-monitor-icon-encoded.txt" > "$srcdir/agisoft-network-monitor_128.png"
    base64 -d "$srcdir/agisoft-viewer-icon-encoded.txt" > "$srcdir/agisoft-viewer_128.png"
    
    # Create 128x128 mime icons
    base64 -d "$srcdir/agisoft-psx-mime-icon-encoded.txt" > "$srcdir/application-agisoft-psx_128.png"
    base64 -d "$srcdir/agisoft-psz-mime-icon-encoded.txt" > "$srcdir/application-agisoft-psz_128.png"
    base64 -d "$srcdir/agisoft-3dv-mime-icon-encoded.txt" > "$srcdir/application-agisoft-3dv_128.png"
    
    # Create icons for other resolutions
    for _res in 16 32 48 64; do
        magick "$srcdir/agisoft-metashape-pro_128.png" -resize ${_res}x${_res} "$srcdir/agisoft-metashape-pro_${_res}.png"
        magick "$srcdir/agisoft-network-monitor_128.png" -resize ${_res}x${_res} "$srcdir/agisoft-network-monitor_${_res}.png"
        magick "$srcdir/agisoft-viewer_128.png" -resize ${_res}x${_res} "$srcdir/agisoft-viewer_${_res}.png"
        magick "$srcdir/application-agisoft-psx_128.png" -resize ${_res}x${_res} "$srcdir/application-agisoft-psx_${_res}.png"
        magick "$srcdir/application-agisoft-psz_128.png" -resize ${_res}x${_res} "$srcdir/application-agisoft-psz_${_res}.png"
        magick "$srcdir/application-agisoft-3dv_128.png" -resize ${_res}x${_res} "$srcdir/application-agisoft-3dv_${_res}.png"
    done
    
    # Create executables for /usr/bin
    echo "#!/bin/bash
/opt/agisoft/${_pkgname}/metashape.sh \$@" > "$srcdir/agisoft-metashape-pro"
    echo "#!/bin/bash
/opt/agisoft/${_pkgname}/monitor.sh \$@" > "$srcdir/agisoft-network-monitor"
    echo "#!/bin/bash
/opt/agisoft/${_pkgname}/viewer.sh \$@" > "$srcdir/agisoft-viewer"
}

package() {
    # Move extracted folder to opt
    cd "$pkgdir"
    mkdir -p "opt/agisoft"
    mv "${srcdir}/${_pkgname}" "${pkgdir}/opt/agisoft/"

    # Install licenses
    cd opt/agisoft/${_pkgname}
    install -Dm644 eula.txt "$pkgdir/usr/share/licenses/$pkgname/eula.txt"
    mv licenses "$pkgdir/usr/share/licenses/$pkgname"
    rm eula.txt

    # Move desktop entries
    mkdir -p "${pkgdir}/usr/share/applications/"
    mv "${srcdir}/agisoft-metashape-pro.desktop" "${pkgdir}/usr/share/applications/"
    mv "${srcdir}/agisoft-network-monitor.desktop" "${pkgdir}/usr/share/applications/"
    mv "${srcdir}/agisoft-viewer.desktop" "${pkgdir}/usr/share/applications/"

    # Create MIME type
    mkdir -p "${pkgdir}/usr/share/mime/packages"
    mv "${srcdir}/${pkgname}-mime.xml" "${pkgdir}/usr/share/mime/packages"

    # Move icons
    for _res in 16x16 32x32 48x48 64x64 128x128; do
        mkdir -p "${pkgdir}/usr/share/icons/hicolor/${_res}/apps/"
        mkdir -p "${pkgdir}/usr/share/icons/hicolor/${_res}/mimetypes/"
        mv "$srcdir/agisoft-metashape-pro_${_res/x*}.png" "${pkgdir}/usr/share/icons/hicolor/${_res}/apps/agisoft-metashape-pro.png"
        mv "$srcdir/agisoft-network-monitor_${_res/x*}.png" "${pkgdir}/usr/share/icons/hicolor/${_res}/apps/agisoft-network-monitor.png"
        cp "$srcdir/agisoft-viewer_${_res/x*}.png" "${pkgdir}/usr/share/icons/hicolor/${_res}/mimetypes/application-agisoft-viewer-vpz.png"
        mv "$srcdir/agisoft-viewer_${_res/x*}.png" "${pkgdir}/usr/share/icons/hicolor/${_res}/apps/agisoft-viewer.png"
        mv "$srcdir/application-agisoft-psx_${_res/x*}.png" "${pkgdir}/usr/share/icons/hicolor/${_res}/mimetypes/application-agisoft-pro-psx.png"
        mv "$srcdir/application-agisoft-psz_${_res/x*}.png" "${pkgdir}/usr/share/icons/hicolor/${_res}/mimetypes/application-agisoft-pro-psz.png"
        mv "$srcdir/application-agisoft-3dv_${_res/x*}.png" "${pkgdir}/usr/share/icons/hicolor/${_res}/mimetypes/application-agisoft-viewer-3dv.png"
    done
    
    # Create executables in /usr/bin
    install -Dm755 "$srcdir/agisoft-metashape-pro" "$pkgdir/usr/bin/agisoft-metashape-pro"
    install -Dm755 "$srcdir/agisoft-network-monitor" "$pkgdir/usr/bin/agisoft-network-monitor"
    install -Dm755 "$srcdir/agisoft-viewer" "$pkgdir/usr/bin/agisoft-viewer"

    # Set the rehostable directory and environment variables in executables for activation
    mkdir -p "${pkgdir}/opt/agisoft/${_pkgname}/licensing"
    sed -i '/export LD_LIBRARY_PATH/a\\nAGISOFT_LICENSING_DIR=\$dirname/licensing\nexport AGISOFT_LICENSING_DIR' "${pkgdir}/opt/agisoft/${_pkgname}/metashape.sh"
    sed -i '/export LD_LIBRARY_PATH/a\\nAGISOFT_LICENSING_DIR=\$dirname/licensing\nexport AGISOFT_LICENSING_DIR' "${pkgdir}/opt/agisoft/${_pkgname}/viewer.sh"
    sed -i '/export LD_LIBRARY_PATH/a\\nAGISOFT_LICENSING_DIR=\$dirname/licensing\nexport AGISOFT_LICENSING_DIR' "${pkgdir}/opt/agisoft/${_pkgname}/monitor.sh"

    # Set correct permission
    chmod -R g=u "$pkgdir/opt/agisoft/${_pkgname}"
    chmod -R o=u "$pkgdir/opt/agisoft/${_pkgname}"
    chmod -R g-w "$pkgdir/opt/agisoft/${_pkgname}"
    chmod -R o-w "$pkgdir/opt/agisoft/${_pkgname}"
    chmod -R g=u "$pkgdir/usr/share/licenses/$pkgname/licenses"
    chmod -R o=u "$pkgdir/usr/share/licenses/$pkgname/licenses"
    chmod -R g-w "$pkgdir/usr/share/licenses/$pkgname/licenses"
    chmod -R o-w "$pkgdir/usr/share/licenses/$pkgname/licenses"
}