summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 81da86779ffc42c64d50045bbe95e154c44e775f (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
184
185
186
187
188
# Maintainer: Gökçe Aydos (leuko) <aydos.de>
# Maintainer: VitalyR <vr@vitalyr.com>
# Former Maintainer: phanium <$(echo bnhoc2R1QHFxLmNvbQo= | base64 -d)>
# Former Maintainer: xiretza <aur@xiretza.xyz>
# Contributor: Darren Wu <$(base64 --decode <<<'ZGFycmVuMTk5NzA4MTBAZ21haWwuY29tCg==')>

# This PKGBUILD can also be used to install *Vitis Unified Software Platform*
# or a subset of components like specific device support etc. See `package()`
# for details.

# BUILD INSTRUCTIONS:
#
# 1. Go to https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/vivado-design-tools.html
# 2. Download "AMD Unified Installer for FPGAs & Adaptive SoCs SFD" - WARNING:
#   (1) This file is >100GB in size  (2) You need an account for US export
#   controls.
# 3. Place the .tar.gz in the same directory as the PKGBUILD
# 4. If you want to install a subset of the features, refer to `package()` below
# 5. Build!
#
# No refunds for broken AUR helpers, just use make(chroot)pkg.
#
# SOME MORE NOTES:
#
# This package is huge. The download alone is a barely-compressed >100GB
# .tar.gz (extracts to ~100GB) and the final zstd-compressed package is another
# 20GB. Reserve at least 200GB in total for building.
#
# It can also take up to two hours to build, being mostly limited by I/O and
# single-thread performance. `namcap` takes another 30 minutes, make sure
# you're not running that automatically.
#
# It *also* requires a reasonably ugly hack to build: since package() is run
# under fakeroot, and the installer tries to access the home directory no
# matter what `--location` is set to, it fails during "Running post-install
# tasks" because it tries to access `/root`. To fix this, a tiny shared library
# (see spoof_homedir.c) is LD_PRELOADed. Its only job is to wrap the
# `getpwuid()` function and modify the original return value for uid==0.
#
# TROUBLESHOOTING
#
# - Installations hangs after `Installing files, ... completed. (Done)`:
#
#   After installation some scripts are executed, e.g., getting a list of
#   installed devices for Vivado or installing Python wheels for Vitis. If a
#   library is missing, Vivado may stay in its shell forever. To debug these
#   problems, refer to the log: `~/.Xilinx/xinstall/xinstall-*.log`.


# CONFIGURATION
#
INSTALL_DIR="/opt/Xilinx"
# Change this to another directory if you want to install two versions on the same root.
# As a result:
# 1. `pkgname` is renamed
# 2. `package()` skips installing udev rules and desktop files to avoid clash
#    between two vivado versions


pkgname=vivado
if [[ $INSTALL_DIR != /opt/Xilinx ]]; then
    pkgname=vivado2
fi
_srcname=FPGAs_AdaptiveSoCs_Unified
pkgver=2024.1
_more_ver=0522_2023
pkgrel=1
pkgdesc="FPGA/CPLD design suite for AMD devices"
url="https://www.xilinx.com/products/design-tools/vivado.html"
arch=('x86_64')
license=('custom')
depends=('ncurses5-compat-libs'
    'libxcrypt-compat'
    'libpng12'
    'lib32-libpng12'
    'gtk3'
    'inetutils'
    'xorg-xlsclients'
    'cpio'
)
optdepends=('fxload'
    'digilent.adept.runtime'
    'digilent.adept.utilities'
    'matlab: Model Composer'
    'qt4: Model Composer'
)
source=(
    "file:///${_srcname}_${pkgver}_${_more_ver}.tar.gz"
    "spoof_homedir.c"
    #"install_config.txt"
)

# Checksum from https://www.xilinx.com/support/download.html
md5sums=(
    '372c0b184e32001137424e395823de3c'
    '69d14ad64f6ec44e041eaa8ffcb6f87c'
    #SKIP
)

# Takes forever for probably minimal gain
options=('!strip')

prepare() {
    rm -rf "$srcdir/installer_temp"
    # If not removed, may lead to `Program group entry already exists` in
    # future makepkg packagings.

    mkdir -p "$srcdir/installer_temp"
}

build() {
    # Build our getpwuid() wrapper library
    gcc -shared -fPIC -D "FAKE_HOME=\"$srcdir/installer_temp\"" spoof_homedir.c -o spoof_homedir.so -ldl
}

package() {
    cd "${_srcname}_${pkgver}_${_more_ver}"

    # If you only need support for a subset of devices and would like to save
    # space:
    # 1. tar xf *.tar.gz
    # 2. ./xsetup -b ConfigGen
    # 3. edit the generated config file.
    #    You don't have to modify `Destination`. It is overridden by the
    #    `--location` argument 
    # 4. move the generated `install_config.txt` to the PKGBUILD folder
    # 5. append the file to `source`
    # 6. append `SKIP` to md5sums
    # 7. Then use instead the following arguments for `./xsetup`
    #
    #    --batch Install \
    #    --agree XilinxEULA,3rdPartyEULA \
    #    --location "$pkgdir/opt/Xilinx" \
    #    --config ../install_config.txt

    # For *Vitis Unified Software Platform*, use:
    # ```
    #    --product Vitis \
    #    --edition 'Vitis Unified Software Platform' \
    # ```
    # The unified installer that you downloaded includes all Vivado and Vitis
    # editions.

        # LD_PRELOAD already contains libfakeroot.so, add our own library before that
    LD_PRELOAD="$srcdir/spoof_homedir.so:$LD_PRELOAD" ./xsetup \
        --batch Install \
        --agree XilinxEULA,3rdPartyEULA \
        --location "$pkgdir$INSTALL_DIR" \
        --product Vivado \
        --edition 'Vivado ML Standard'

        #--config ../install_config.txt

    if [[ $INSTALL_DIR == /opt/Xilinx ]]; then
        # Install udev rules
        install -Dm644 "$pkgdir$INSTALL_DIR/Vivado/${pkgver}/data/xicom/cable_drivers/lin64/install_script/install_drivers/52-xilinx-digilent-usb.rules" -t "$pkgdir/usr/lib/udev/rules.d/"
        install -Dm644 "$pkgdir$INSTALL_DIR/Vivado/${pkgver}/data/xicom/cable_drivers/lin64/install_script/install_drivers/52-xilinx-ftdi-usb.rules" -t "$pkgdir/usr/lib/udev/rules.d/"
        install -Dm644 "$pkgdir$INSTALL_DIR/Vivado/${pkgver}/data/xicom/cable_drivers/lin64/install_script/install_drivers/52-xilinx-pcusb.rules" -t "$pkgdir/usr/lib/udev/rules.d/"

        # Install desktop files
        for deskfile in "$srcdir"/installer_temp/Desktop/*.desktop; do
            sed -i -e "s|$pkgdir||g" "$deskfile"
            install -Dm644 -t "$pkgdir/usr/share/applications/" "$deskfile"
        done
    fi

    # Clean up artifacts, remove leading $pkgdir from paths
    rm -rf "$pkgdir$INSTALL_DIR/.xinstall/"
    find "$pkgdir$INSTALL_DIR" -name '*settings64*' -exec sed -i -e "s|$pkgdir||g" '{}' \+

    # If you want to save space for subsequent packaging, then remove the
    # extracted installation archive files. The following lines are executed
    # before the pacman package is created and will free >100G of space.
    #cd ..
    #rm -rf "${_srcname}_${pkgver}_${_more_ver}"

    # Consuming less time for repackaging
    #
    # If you did not remove the extracted installation archive files and save
    # the time for checksum and extraction for repackaging, then follow these
    # steps on your shell:
    #
    # 1. Remove `installer_temp`, e.g., `rm -rf src/installer_temp`
    # 1a. Only if you used `install_config.txt`: copy it to `src` manually,
    #     because `--noextract` option that we will use in the next step skips
    #     this step.
    # 2. makepkg --skipchecksums --noextract -f
}