summaryrefslogtreecommitdiff
path: root/opt/udevd/MAKEPKG
blob: 6a55b06be046428f282e91e4891c3788dff311d1 (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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
#!/bin/mkpkg
# description: Device manager for the Linux kernel (extracted from systemd)
# url: https://systemd.io/

name=udevd
version=262
release=1
depends=(util-linux libcap2 kmod acl libucontext)
makedeps=(meson ninja py-jinja2 py-lxml gperf patchelf docbook-xsl libxslt gettext)
services=(udevd)

source=(https://github.com/systemd/systemd/archive/refs/tags/v${version}.tar.gz
        40-rawnix.rules
        udev-trigger)
renames=($name-$version.tar.gz)

sha256sums=(
    "6aa77506c0644aa67f940a48e3d3a7368601f787e4f249139516d353f107bcab"
    "981a54db9f163aaa60c85886589df97f8af1374c52f816ab2cb9e7ae79b84bae"
    "e9cbff4bc98e56d0d1802720da6382937794ffc25d5d6e10293a844d114dff86"
)

build() {
    cd systemd-$version

    mkdir -p test/fuzz/fuzz-unit-file
    touch test/fuzz/fuzz-unit-file/dm-back-slash.swap

    meson setup build \
        --prefix=/usr \
        --sysconfdir=/etc \
        --libdir=/usr/lib \
        --buildtype=release \
        -Dmode=release \
        -Dlibc=musl \
        -Dsplit-bin=false \
        -Dhwdb=true \
        -Dtests=false \
        -Dfuzz-tests=false \
        -Dstatic-libudev=false \
        -Dstandalone-binaries=false \
        \
        -Dacl=enabled \
        -Dkmod=enabled \
        -Dselinux=disabled \
        \
        -Dbootloader=disabled \
        -Dkernel-install=false \
        -Dsysusers=false \
        -Dtmpfiles=false \
        -Dukify=disabled \
        \
        -Dadm-group=false \
        -Danalyze=false \
        -Dapparmor=disabled \
        -Daudit=disabled \
        -Dbacklight=false \
        -Dbinfmt=false \
        -Dbpf-framework=disabled \
        -Dbzip2=disabled \
        -Dcoredump=false \
        -Ddbus=disabled \
        -Delfutils=disabled \
        -Denvironment-d=false \
        -Dfdisk=disabled \
        -Dgcrypt=disabled \
        -Dglib=disabled \
        -Dgshadow=false \
        -Dgnutls=disabled \
        -Dhibernate=false \
        -Dhostnamed=false \
        -Didn=false \
        -Dima=false \
        -Dinitrd=false \
        -Dfirstboot=false \
        -Dldconfig=false \
        -Dlibcryptsetup=disabled \
        -Dlibcurl=disabled \
        -Dlibfido2=disabled \
        -Dlibidn2=disabled \
        -Dlocaled=false \
        -Dlogind=false \
        -Dlz4=disabled \
        -Dmachined=false \
        -Dmicrohttpd=disabled \
        -Dnetworkd=false \
        -Dnss-myhostname=false \
        -Dnss-resolve=disabled \
        -Dnss-systemd=false \
        -Doomd=false \
        -Dopenssl=disabled \
        -Dp11kit=disabled \
        -Dpam=disabled \
        -Dpcre2=disabled \
        -Dpolkit=disabled \
        -Dportabled=false \
        -Dpstore=false \
        -Dpwquality=disabled \
        -Drandomseed=false \
        -Dresolve=false \
        -Drfkill=false \
        -Dseccomp=disabled \
        -Dsmack=false \
        -Dsysext=false \
        -Dtimedated=false \
        -Dtimesyncd=false \
        -Dtpm=false \
        -Dqrencode=disabled \
        -Dquotacheck=false \
        -Duserdb=false \
        -Dutmp=false \
        -Dvconsole=false \
        -Dwheel-group=false \
        -Dxdg-autostart=false \
        -Dxkbcommon=disabled \
        -Dxz=disabled \
        -Dzlib=disabled \
        -Dzstd=disabled

    cd build

    ninja \
        udevadm \
        systemd-hwdb \
        ata_id \
        cdrom_id \
        iocost \
        mtd_probe \
        scsi_id \
        v4l_id \
        src/udev/udev.pc \
        man/udev.conf.5 \
        man/systemd.link.5 \
        man/hwdb.7 \
        man/udev.7 \
        man/systemd-hwdb.8 \
        man/systemd-udevd.service.8 \
        man/udevadm.8 \
        man/libudev.3 \
        man/udev_device_get_syspath.3 \
        man/udev_device_has_tag.3 \
        man/udev_device_new_from_syspath.3 \
        man/udev_enumerate_add_match_subsystem.3 \
        man/udev_enumerate_new.3 \
        man/udev_enumerate_scan_devices.3 \
        man/udev_list_entry.3 \
        man/udev_monitor_filter_update.3 \
        man/udev_monitor_new_from_netlink.3 \
        man/udev_monitor_receive_device.3 \
        man/udev_new.3 \
        hwdb.d/60-autosuspend-chromiumos.hwdb \
        rules.d/50-udev-default.rules \
        rules.d/60-persistent-storage.rules \
        rules.d/64-btrfs.rules \
        libudev \
        src/libudev/libudev.pc

    case $(uname -m) in
        aarch64|arm*|ia64|i?86|loongarch64|mips*|x86_64)
            ninja dmi_memory_id
            ;;
    esac

    cd ..

    # Install
    major_ver=${version%%.*}

    mkdir -p "$PKG/usr/bin" \
             "$PKG/usr/lib/systemd" \
             "$PKG/usr/lib/udev" \
             "$PKG/usr/lib/udev/rules.d" \
             "$PKG/usr/lib/udev/hwdb.d" \
             "$PKG/usr/lib/pkgconfig" \
             "$PKG/usr/lib/systemd/network" \
             "$PKG/usr/share/man/man3" \
             "$PKG/usr/share/man/man5" \
             "$PKG/usr/share/man/man7" \
             "$PKG/usr/share/man/man8" \
             "$PKG/usr/share/pkgconfig" \
             "$PKG/usr/include" \
             "$PKG/etc/udev/rules.d" \
             "$PKG/etc/udev/hwdb.d"

    # Shared library
    install -m755 build/src/shared/libsystemd-shared-${major_ver}.so "$PKG/usr/lib/systemd/"

    # Main binaries with rpath
    patchelf --set-rpath "/usr/lib/systemd" build/udevadm
    patchelf --set-rpath "/usr/lib/systemd" build/systemd-hwdb
    install -m755 build/udevadm "$PKG/usr/bin/"
    install -m755 build/systemd-hwdb "$PKG/usr/bin/"

    # systemd-udevd symlink (expected by some software)
    ln -s ../../bin/udevadm "$PKG/usr/lib/systemd/systemd-udevd"

    # udevd symlink so runit and scripts can find it by name
    ln -s ../lib/systemd/systemd-udevd "$PKG/usr/bin/udevd"

    # udev helper binaries
    for h in ata_id cdrom_id iocost mtd_probe scsi_id v4l_id; do
        patchelf --set-rpath "/usr/lib/systemd" "build/$h"
        install -m755 "build/$h" "$PKG/usr/lib/udev/"
    done

    # dmi_memory_id on supported architectures
    case $(uname -m) in
        aarch64|arm*|ia64|i?86|loongarch64|mips*|x86_64)
            patchelf --set-rpath "/usr/lib/systemd" build/dmi_memory_id
            install -m755 build/dmi_memory_id "$PKG/usr/lib/udev/"
            ;;
    esac

    # libudev
    libudev_full=$(ls build/libudev.so.1.* 2>/dev/null | head -1)
    if [ -n "$libudev_full" ]; then
        libudev_name=$(basename "$libudev_full")
        install -m755 "$libudev_full" "$PKG/usr/lib/"
        ln -s "$libudev_name" "$PKG/usr/lib/libudev.so.1"
        ln -s libudev.so.1 "$PKG/usr/lib/libudev.so"
    else
        install -m755 build/libudev.so.1 "$PKG/usr/lib/"
        ln -s libudev.so.1 "$PKG/usr/lib/libudev.so"
    fi

    # Headers
    install -m644 src/libudev/libudev.h "$PKG/usr/include/"

    # Pkgconfig
    install -m644 build/src/libudev/libudev.pc "$PKG/usr/lib/pkgconfig/"
    install -m644 build/src/udev/udev.pc "$PKG/usr/share/pkgconfig/"

    # Rules (skip systemd-specific)
    for f in build/rules.d/*.rules; do
        fname=$(basename "$f")
        case "$fname" in
            99-systemd.rules|70-power-switch.rules) continue ;;
        esac
        install -m644 "$f" "$PKG/usr/lib/udev/rules.d/"
    done

    for f in rules.d/*.rules; do
        fname=$(basename "$f")
        [ -f "$PKG/usr/lib/udev/rules.d/$fname" ] && continue
        case "$fname" in
            99-systemd.rules|70-power-switch.rules) continue ;;
        esac
        install -m644 "$f" "$PKG/usr/lib/udev/rules.d/"
    done

    # rawnix-specific rules
    install -m644 "$SRC/40-rawnix.rules" "$PKG/usr/lib/udev/rules.d/"

    # hwdb files
    for f in build/hwdb.d/*.hwdb; do
        install -m644 "$f" "$PKG/usr/lib/udev/hwdb.d/"
    done
    for f in hwdb.d/*.hwdb; do
        fname=$(basename "$f")
        [ -f "$PKG/usr/lib/udev/hwdb.d/$fname" ] && continue
        install -m644 "$f" "$PKG/usr/lib/udev/hwdb.d/"
    done

    # Configuration
    install -m644 src/udev/udev.conf "$PKG/etc/udev/"

    # Network link file
    install -m644 network/99-default.link "$PKG/usr/lib/systemd/network/"

    # Man pages
    install -m644 build/man/udev.conf.5 "$PKG/usr/share/man/man5/"
    install -m644 build/man/systemd.link.5 "$PKG/usr/share/man/man5/"
    install -m644 build/man/hwdb.7 "$PKG/usr/share/man/man7/"
    install -m644 build/man/udev.7 "$PKG/usr/share/man/man7/"
    install -m644 build/man/systemd-hwdb.8 "$PKG/usr/share/man/man8/"
    install -m644 build/man/udevadm.8 "$PKG/usr/share/man/man8/"
    install -m644 build/man/systemd-udevd.service.8 "$PKG/usr/share/man/man8/systemd-udevd.8"

    install -m644 build/man/libudev.3 "$PKG/usr/share/man/man3/"
    for f in build/man/udev_*.3; do
        install -m644 "$f" "$PKG/usr/share/man/man3/"
    done

    # Helper script
    install -m755 "$SRC/udev-trigger" "$PKG/usr/bin/"
}

post_build() {
    # runit service
    install -d $PKG/etc/sv/udevd/log

    printf '%s\n' \
        '#!/bin/sh' \
        'exec 2>&1' \
        'mkdir -p /run/udev' \
        'udevadm control --exit 2>/dev/null' \
        'exec udevd' \
        > $PKG/etc/sv/udevd/run

    printf '%s\n' \
        '#!/bin/sh' \
        'udevadm control --exit 2>/dev/null' \
        'rm -f /run/udev/control' \
        > $PKG/etc/sv/udevd/finish

    printf '%s\n' \
        '#!/bin/sh' \
        'mkdir -p /var/log/udevd' \
        'exec svlogd -tt /var/log/udevd' \
        > $PKG/etc/sv/udevd/log/run

    chmod 755 $PKG/etc/sv/udevd/run
    chmod 755 $PKG/etc/sv/udevd/finish
    chmod 755 $PKG/etc/sv/udevd/log/run
}

signify() {
    untrusted comment: public key
    RWTZ9IduCSQ/mL8337TEUinPwT92xFEUpD92hkS7IxcOnzTt9QdpohT3
}

# vim: filetype=sh