forked from mer-hybris/droid-hal-device
-
Notifications
You must be signed in to change notification settings - Fork 0
/
droid-hal-device.inc
660 lines (553 loc) · 22.9 KB
/
droid-hal-device.inc
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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
# This file should be %%included into a device specific spec file
# where macros are defined:
# device: should be the CM codename
# vendor: determine the directory used for ./device/<vendor>/<device>
# device_pretty: User-visible model name of the device
# vendor_pretty: User-visible manufacturer name of the device
# hadk_make_target: the target used when running make in the HABUILD_SDK on the OBS. Defaults to "hybris-hal"
%define __provides_exclude_from ^%{_libexecdir}/droid-hybris/.*$
%define android_root .
%define rel_date %(date +'%%Y%%m%%d%%H%%M')
# On the OBS this package should be built in the i486 scheduler against
# mer/sailfish *_i486 targets.
# The prjconf should have an ExportFilter like this (mer/sailfish has this):
# ExportFilter: \.armv7hl\.rpm$ armv8el
# We lie about our architecture and allows OBS to cross-publish this 486 cross-built spec to the armv7hl repos
%define _target_cpu armv7hl
# Support build info extracted from OBS builds too
%if 0%{?_obs_build_project:1}
%define _build_flavour %(echo %{_obs_build_project} | awk -F : '{if (NF == 3) print $3; else if (NF == 2) print strdevel; else print strunknown}' strdevel=devel strunknown=unknown)
%else
%define _build_flavour unknown
%endif
%define _obs_build_count %(echo %{release} | awk -F . '{if (NF >= 3) print $3; else print $1 }')
%define _obs_commit_count %(echo %{release} | awk -F . '{if (NF >= 2) print $2; else print $1 }')
%if %{_build_flavour} == release
%define _version_appendix (%{_target_cpu})
%else
%define _version_appendix (%{_target_cpu},%{_build_flavour})
%endif
%define board_mapping_dir %{_datadir}/ssu/board-mappings.d
%define board_mapping_file %{board_mapping_dir}/05-%{vendor}-%{device}.ini
# Don't run strip
%define __strip /bin/true
Summary: Droid HAL package for %{device}
License: BSD-3-Clause
Name: droid-hal-%{device}
Version: 0.0.6
Release: %{rel_date}
Provides: droid-hal
Provides: flash-partition
# The repo sync service on OBS prepares a 'source tarball' of the rpm
# dir since we currently have a complex setup with subdirs which OBS
# doesn't like. This is not a problem for local builds.
Source0: rpm.tar.bzip2
Source1: makefstab
Source2: usergroupgen.c
Source3: makeudev
Source4: apply-permissions.c
Source5: makefile
Source7: device-%{vendor}-%{device}-configs
Source8: hybris.conf
Source10: droid-hal-device.inc
# This is copied from libhybris and should be kept in-sync:
Source11: extract-headers.sh
Source12: init-debug
# This is not copied from libhybris and should not be kept in-sync:
Source13: device-configs-all
Source14: droid.kmap
Source15: us.kmap
# Ths actual droid source from the repo service when run on OBS.
# local builds don't mind if this is missing
Source40: repo.tar.bzip2
# Reserve Source50 onwards
# Allow device specific sources to be defined using dhd_sources
%{?dhd_sources}
Group: System
#BuildArch: noarch
# Note that oneshot is not in mer-core (yet)
BuildRequires: oneshot
BuildRequires: systemd
BuildRequires: qt5-qttools-kmap2qmap >= 5.1.0+git5
BuildRequires: repomd-pattern-builder
# These are only required if building on OBS
%if 0%{?_obs_build_project:1}
BuildRequires: ubu-trusty
BuildRequires: sudo-for-abuild
%endif
%systemd_requires
%{_oneshot_requires_post}
%description
%{summary}.
################
%package devel
Group: Development/Tools
# Requires: %%{name} = %%{version}-%%{release}
Provides: droid-hal-devel
Summary: Development files for droid-hal device: %{device}
%description devel
Device specific droid headers for %{device}.
Needed by libhybris
################
%package sailfish-config
Provides: droid-hal-sailfish-config
Group: System
BuildArch: noarch
Requires: %{name} = %{version}-%{release}
Requires: oneshot
Requires: dconf
Summary: Per device configuration for sailfish for droid-hal device: %{device}
%description sailfish-config
Configure sailfish eg naturally landscape devices like mako
################
%package kernel
Provides: droid-hal-kernel
Group: System
Summary: Kernel for droid-hal device: %{device}
%description kernel
Just the kernel - mainly useful if you want to make a custom img
################
%package kernel-modules
Provides: droid-hal-kernel-modules
Requires: kmod
Group: System
Summary: Kernel modules for droid-hal device: %{device}
%description kernel-modules
Just the kernel modules
################
%package img-boot
Provides: droid-hal-img-boot
Group: System
Requires: flash-partition
Requires: oneshot
%{_oneshot_requires_post}
Summary: Boot img for droid-hal device: %{device}
%description img-boot
The boot.img for device
################
%package img-recovery
Provides: droid-hal-img-recovery
Group: System
BuildArch: noarch
Summary: Recovery image for droid-hal device: %{device}
%description img-recovery
The recovery.img for device
################
%package pulseaudio-settings
Summary: PulseAudio settings for %{device} hw
Requires: pulseaudio >= 4.0
Requires: pulseaudio-modules-nemo-parameters >= 4.0.11
Requires: pulseaudio-modules-nemo-stream-restore >= 4.0.11
Requires: pulseaudio-modules-nemo-mainvolume >= 4.0.11
Requires: pulseaudio-modules-droid >= 4.0.6
Requires: pulseaudio-policy-enforcement >= 4.0.8
Provides: pulseaudio-settings
%description pulseaudio-settings
%{summary}.
################
%package policy-settings
Summary: Policy settings for %{device} hw
Requires: ohm >= 1.1.16
Requires: ohm-plugins-misc
Requires: ohm-plugins-dbus
Requires: ohm-plugin-telephony
Requires: ohm-plugin-signaling
Requires: ohm-plugin-media
Requires: ohm-plugin-accessories
Requires: ohm-plugin-resolver
Requires: ohm-plugin-ruleengine
Requires: ohm-plugin-profile
Requires: pulseaudio-modules-nemo-common >= 4.0.11
Requires: pulseaudio-policy-enforcement >= 4.0.8
Requires: policy-settings-common >= 0.2.0
Obsoletes: ohm-config <= 1.1.15
# ohm-configs-default should not be installed ever, thus no version
# specification defined here.
Obsoletes: ohm-configs-default
Provides: ohm-configs > 1.1.15
Provides: policy-settings
%description policy-settings
%{summary}.
################
%package kickstart-configuration
Summary: Kickstart configuration for %{device}
Requires: ssu-kickstart-configuration-jolla
Provides: droid-hal-kickstart-configuration
%description kickstart-configuration
%{summary}.
################
%package preinit-plugin
Summary: Preinit plugins for %{device}
Provides: preinit-plugins
%description preinit-plugin
%{summary}.
################################################################
%package patterns
Summary: Repository patterns for %{device} hw
Provides: package-groups
%description patterns
%{summary}.
################################################################
# Begin prep/build section
%prep
# No %%setup macro !!
%if 0%{?_obs_build_project:1}
# The OBS does not have access to 'repo' so a service does the repo init/sync
# and provides a (huge) tarball with the checked-out tree in it.
# So now drop to android_root and pretend to do a repo sync
tar xf %{SOURCE40} -C %android_root
# Clean up the repo tarball to save space
rm -f %{SOURCE40}
# Make a dummy tarball for rpm checks
mkdir dummy;(cd dummy; touch dummy; tar cvf - . | bzip2 > %{SOURCE40}); rm -rf dummy
# unpack the directories to SOURCES ... this needs to change
tar xf %{SOURCE0} -C ../SOURCES
# Clean up the rpm tarball too
rm -f %{SOURCE0}
cp %{SOURCE40} %{SOURCE0}
# In OBS the repo service leaves the rpm/* files for OBS and they just ^^
# got unpacked to ../SOURCES ... but we're used to having an rpm/ dir
# So if rpm/ is missing then we use ../SOURCES :
[ -d rpm ] || ln -s ../SOURCES rpm
%endif
%build
%if 0%{?_obs_build_project:1}
# Hadk style build of android on OBS
echo Running droid build in HABUILD_SDK
ubu-chroot -r /srv/mer/sdks/ubu "cd %android_root; source build/envsetup.sh; breakfast %{device}; rm -f .repo/local_manifests/roomservice.xml; make %{?_smp_mflags} %{?hadk_make_target}%{!?hadk_make_target:hybris-hal}"
%endif
# Make a tmp location for built installables
rm -rf tmp
mkdir tmp
echo Verifying kernel config
hybris/mer-kernel-check/mer_verify_kernel_config \
%{android_root}/out/target/product/%{device}/obj/KERNEL_OBJ/.config
echo Building local tools
mkdir tmp/rpmsrc
cp %{SOURCE2} %{SOURCE4} tmp/rpmsrc/
ANDROID_ROOT=$(readlink -e %{android_root})
(cd tmp/rpmsrc; make ANDROID_ROOT=$ANDROID_ROOT -f %{SOURCE5})
echo Building uid scripts
tmp/rpmsrc/usergroupgen add > tmp/rpmsrc/droid-user-add.sh
tmp/rpmsrc/usergroupgen remove > tmp/rpmsrc/droid-user-remove.sh
echo Building udev rules
mkdir tmp/udev.rules
# Device specific ueventd rules is the "not goldfish" one
chmod 755 %{SOURCE3}
%{SOURCE3} \
%{android_root}/out/target/product/%{device}/root/ueventd.rc \
$(ls %{android_root}/out/target/product/%{device}/root/ueventd.*.rc | grep -v .goldfish.rc) \
> tmp/udev.rules/999-android-system.rules
echo Building mount units
mkdir tmp/units
# Use the makefstab and tell it what mountpoints to skip. It will
# generate .mount units which will be part of local-fs.target
# skip various mounts which are not wanted (This is just in case they creep in)
# First handle stupid spec quoting rules to get some args for makefstab
shopt -s nullglob
FSTAB_FILES="$(echo %{android_root}/out/target/product/%{device}/root/fstab.* %{android_root}/out/target/product/%{device}/root/*.rc)"
shopt -u nullglob
chmod 755 %{SOURCE1}
%{SOURCE1} --files $FSTAB_FILES --skip auto /acct /boot /cache /data /misc /recovery /staging /storage/usbdisk /sys/fs/cgroup /sys/fs/cgroup/memory /sys/kernel/debug /sys/kernel/config --outputdir tmp/units
echo Fixing up mount points
hybris/hybris-boot/fixup-mountpoints %{device} tmp/units/*
echo Creating hw-release
# based on http://www.freedesktop.org/software/systemd/man/os-release.html
cat > tmp/hw-release <<EOF
# This file is copied as both hw-release (analogous to os-release)
# and hw-release.vars for use at build time
MER_HA_DEVICE=%{device}
MER_HA_VENDOR=%{vendor}
MER_HA_VERSION="%{version}.%{_obs_build_count} %{_version_appendix}"
MER_HA_VERSION_ID=%{version}.%{_obs_build_count}
MER_HA_PRETTY_NAME="%{device} %{version}.%{_obs_build_count} %{_version_appendix}"
MER_HA_SAILFISH_BUILD=%{_obs_build_count}
MER_HA_SAILFISH_FLAVOUR=%{_build_flavour}
MER_HA_HOME_URL="https://sailfishos.org/"
EOF
# Grab a snapshot of the git state from repo
if [ -e ./repo_service_manifest.xml ] ; then
# The OBS service helpfully dropped a repo manifest file here:
mv ./repo_service_manifest.xml tmp/manifest.xml
else
./.repo/repo/repo manifest -r -o tmp/manifest.xml
fi
################
%install
echo install $(cat tmp/units/all-units.txt)
rm -rf $RPM_BUILD_ROOT
# Create dir structure
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/droid-hybris/lib-dev-alog/
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/droid-hybris/system
mkdir -p $RPM_BUILD_ROOT%{_libdir}/droid
mkdir -p $RPM_BUILD_ROOT%{_libdir}/droid-devel/
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
mkdir -p $RPM_BUILD_ROOT/lib/udev/rules.d
mkdir -p $RPM_BUILD_ROOT/etc/udev/rules.d
mkdir -p $RPM_BUILD_ROOT/%{_sharedstatedir}/environment/compositor
mkdir -p $RPM_BUILD_ROOT/%{_sharedstatedir}/environment/nemo
mkdir -p $RPM_BUILD_ROOT/%{_oneshotdir}
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/os-release.d
mkdir -p $RPM_BUILD_ROOT%{_libdir}/modules/
mkdir -p $RPM_BUILD_ROOT%{_libdir}/droid
mkdir -p $RPM_BUILD_ROOT/%{_bindir}/droid
mkdir -p $RPM_BUILD_ROOT/img
mkdir -p $RPM_BUILD_ROOT/boot
mkdir -p $RPM_BUILD_ROOT/lib/modules
mkdir -p $RPM_BUILD_ROOT%{_libdir}/startup/preinit
# Install
cp -a %{android_root}/out/target/product/%{device}/system/bin/updater $RPM_BUILD_ROOT/boot/update-binary
cp -a %{android_root}/out/target/product/%{device}/hybris-updater-script $RPM_BUILD_ROOT/boot
cp -a %{android_root}/out/target/product/%{device}/hybris-updater-unpack.sh $RPM_BUILD_ROOT/boot
cp -a %{android_root}/out/target/product/%{device}/root/. $RPM_BUILD_ROOT/
# Now remove the mount commands from any .rc files as they're included in .mount unit files now
sed -i -e '/^[[:space:]]*mount[[:space:]]/s/^/# Removed during droid-hal-device build : /' $RPM_BUILD_ROOT/*rc
cp -a %{android_root}/out/target/product/%{device}/system/{bin,lib} $RPM_BUILD_ROOT%{_libexecdir}/droid-hybris/system/.
cp -a %{android_root}/out/target/product/%{device}/obj/{lib,include} $RPM_BUILD_ROOT%{_libdir}/droid-devel/
cp -a %{android_root}/out/target/product/%{device}/symbols $RPM_BUILD_ROOT%{_libdir}/droid-devel/
HDRS=$RPM_BUILD_ROOT%{_libdir}/droid-devel/droid-headers
mkdir -p $HDRS
# Store the 'as built' manifest
cp tmp/manifest.xml $HDRS/repo-manifest.xml
# Run extract-headers.sh
echo "Extracting headers for hybris"
chmod 755 %SOURCE11
%SOURCE11 -p %{_libdir}/droid-devel/droid-headers . $HDRS/ > /dev/null
# Add our config into the default android-config.h
echo Making new $HDRS/android-config.h
sed '/CONFIG GOES HERE/,$d' $HDRS/android-config.h > $HDRS/android-config.h.new
cat <<EOF >> $HDRS/android-config.h.new
/* Added by Droid HAL packaging for %{device} */
%{?android_config}
EOF
sed '0,/CONFIG GOES HERE/d' $HDRS/android-config.h >> $HDRS/android-config.h.new
mv $HDRS/android-config.h.new $HDRS/android-config.h
# Move the pkgconfig .pc to the correct location
mkdir -p $RPM_BUILD_ROOT%{_libdir}/pkgconfig/
mv $HDRS/android-headers.pc $RPM_BUILD_ROOT%{_libdir}/pkgconfig/
# If this ever becomes unmanageable then
# grep -l dev/alog %%{android_root}/out/target/product/%{device}/system/lib/*
# libdsyscalls.so and libc.so are blacklisted
ln -s ../system/lib/{liblog.so,libcutils.so} $RPM_BUILD_ROOT%{_libexecdir}/droid-hybris/lib-dev-alog/.
cp -a tmp/units/*.mount $RPM_BUILD_ROOT/%{_unitdir}
cp -a rpm/dsp/systemd/* $RPM_BUILD_ROOT/%{_unitdir}
# Install the udev rules and supporting script
cp -a tmp/udev.rules/* $RPM_BUILD_ROOT/lib/udev/rules.d/
ln -s /dev/null $RPM_BUILD_ROOT/etc/udev/rules.d/60-persistent-v4l.rules
# Install init-debug which will provide usb access and non-blocking telnet
cp -a %{SOURCE12} $RPM_BUILD_ROOT/
# droid user support This may be better done by passing a list of
# users/groups and running 'ensure_usergroups_exist newlist oldlist'
# which would preserve oldlist in %%post and delete any users no longer
# needed (unlikely!). This avoids the transient removal of uids and
# group issues
install -D tmp/rpmsrc/droid-user-add.sh $RPM_BUILD_ROOT%{_libdir}/droid/droid-user-add.sh
install -D tmp/rpmsrc/droid-user-remove.sh $RPM_BUILD_ROOT%{_libdir}/droid/droid-user-remove.sh
# Add the dsp support binaries
cp rpm/dsp/bin/* $RPM_BUILD_ROOT/%{_bindir}/droid
# Preinit plugins
install -m 0744 rpm/dsp/preinit/* $RPM_BUILD_ROOT%{_libdir}/startup/preinit/
ln -s /bin/false $RPM_BUILD_ROOT%{_libdir}/startup/preinit/is_total_erase_supported
# droid permission fixer
install -D tmp/rpmsrc/apply-permissions $RPM_BUILD_ROOT%{_libdir}/droid/apply-permissions
# Remove cruft
rm -f $RPM_BUILD_ROOT/fstab.*
rm -f $RPM_BUILD_ROOT/*goldfish*
rm -rf $RPM_BUILD_ROOT/{proc,sys,dev,sepolicy} $RPM_BUILD_ROOT/{file,property,seapp}_contexts
rm -rf $RPM_BUILD_ROOT/{charger,res,data}
# Name this so droid-system-packager's droid-hal-startup.sh can find it
mkdir -p $RPM_BUILD_ROOT/sbin
mv $RPM_BUILD_ROOT/init $RPM_BUILD_ROOT/sbin/droid-hal-init
# Rename any symlinks to droid's /init
find $RPM_BUILD_ROOT/sbin/ -lname ../init -execdir echo rm {} \; -execdir echo "ln -s" ./droid-hal-init {} \;
#mv $RPM_BUILD_ROOT/charger $RPM_BUILD_ROOT/sbin/droid-hal-charger
# Amalgamate configs files from device-specific and all- trees
# Retain permissions:
echo "%defattr(-,root,root,-)" > tmp/rpmsrc/conf.files
# Add files that you will handle manually (per-device and/or per-package) to this | separated var:
EXCLUDES="/var/lib/platform-updates/flash-bootimg.sh"
# Prefer files from device-$VENDOR-$DEVICE-configs over device-configs-all
for config_dir in %{SOURCE13} %{SOURCE7}; do
if [ -d $config_dir ]; then
(cd $config_dir; find . \( -type f -or -type l \) -print ) | grep -vE "$EXCLUDES" | sed 's/^.//' >> tmp/rpmsrc/conf.files
cp -R $config_dir/* $RPM_BUILD_ROOT/
fi
done
cp %{SOURCE8} $RPM_BUILD_ROOT/%{_sharedstatedir}/environment/nemo/99-hybris.conf
# SSU board mapping for hardware adaptation
mkdir -p $RPM_BUILD_ROOT/%{board_mapping_dir}
sed -e 's|%DEVICE%|%{device}|g' \
-e 's|%VENDOR%|%{vendor}|g' \
-e "s|%DEVICE_PRETTY%|%{device_pretty}|g" \
-e "s|%VENDOR_PRETTY%|%{vendor_pretty}|g" \
-e "s|%ARCH%|%{__isa_name}|g" \
rpm/ssu/board-mappings.d/05-sfe.ini.in >$RPM_BUILD_ROOT/%{board_mapping_file}
# Copy kickstart packs (for %%{device}-kickstart-configuration)
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/ssu/kickstart/pack/%{device}
sed -e 's|@DEVICE@|%{device}|g' rpm/kickstart/pack/package-droid-updater > $RPM_BUILD_ROOT/%{_datadir}/ssu/kickstart/pack/%{device}/package-droid-updater
# and attachments
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/ssu/kickstart/attachment
cp rpm/kickstart/attachment/hybris $RPM_BUILD_ROOT/%{_datadir}/ssu/kickstart/attachment/%{device}
# Keyboard map file
/usr/lib/qt5/bin/kmap2qmap %{SOURCE14} %{SOURCE15} tmp/droid.qmap
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/qt5/keymaps
cp tmp/droid.qmap $RPM_BUILD_ROOT/%{_datadir}/qt5/keymaps/droid.qmap
# hw-release
cp tmp/hw-release %{buildroot}/%{_sysconfdir}/hw-release
# for use in the -devel package
cp tmp/hw-release %{buildroot}/%{_libdir}/droid-devel/hw-release.vars
# Screen rotation dconf configuration
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/dconf/db/vendor.d/locks
cp rpm/dconf/screen-rotation.txt $RPM_BUILD_ROOT/%{_sysconfdir}/dconf/db/vendor.d/screen-rotation.txt
cp rpm/dconf/locks-screen-rotation.txt $RPM_BUILD_ROOT/%{_sysconfdir}/dconf/db/vendor.d/locks/screen-rotation.txt
# This ghost file must exist in the installroot
touch $RPM_BUILD_ROOT/%{_libdir}/droid/droid-user-remove.sh.installed
# Kernel and module installation; to
# /boot and modules to /lib as normal
KERNEL_RELEASE=$(cat out/target/product/%{device}/obj/KERNEL_OBJ/include/config/kernel.release)
cp out/target/product/%{device}/kernel $RPM_BUILD_ROOT/boot/kernel-$KERNEL_RELEASE
MOD_DIR=$RPM_BUILD_ROOT/lib/modules/$KERNEL_RELEASE
mkdir -p $MOD_DIR
cp -a out/target/product/%{device}/system/lib/modules/. $MOD_DIR/.
cp -a out/target/product/%{device}/system/lib/modules/. $MOD_DIR/.
cp -a out/target/product/%{device}/obj/KERNEL_OBJ/modules.builtin $MOD_DIR/. || true
cp -a out/target/product/%{device}/obj/KERNEL_OBJ/modules.order $MOD_DIR/. || true
# Images are installed to /boot - they'll probably be unpacked using
# rpm2cpio mostly anyhow
cp out/target/product/%{device}/hybris-boot.img $RPM_BUILD_ROOT/boot/
cp out/target/product/%{device}/hybris-recovery.img $RPM_BUILD_ROOT/boot/
# Everything is installed; get a list of the units we installed to
# allow the systemd_post to work... and then install that:
echo "$(cd $RPM_BUILD_ROOT%{_unitdir}; echo *)" > tmp/units/all-units.txt
install -D tmp/units/all-units.txt $RPM_BUILD_ROOT%{_libdir}/droid/all-units.txt
/usr/bin/repomd-pattern-builder.py --patternxml -p ./rpm/patterns/%{device} -o %{buildroot}/usr/share/package-groups/ --version=%{version} --release=%{release}
################################################################
# Begin pre/post section
%preun
for u in $(cat %{_libdir}/droid/all-units.txt); do
%systemd_preun $u
done
# Only run this during final cleanup
if [ $1 -eq 0 ]; then
echo purging old droid users and groups
%{_libdir}/droid/droid-user-remove.sh.installed || :
fi
%post
for u in $(cat %{_libdir}/droid/all-units.txt); do
%systemd_post $u
done
cd %{_libdir}/droid
# Upgrade: remove users using stored file, then add new ones
if [ $1 -eq 2 ]; then
# Remove installed users (at this point droid-user-remove.sh
# refers to the new set of UIDs)
echo removing old droid users and groups
./droid-user-remove.sh.installed || :
fi
# Now for both install/update add the users and force-store a removal file
echo creating droid users and groups
./droid-user-add.sh || :
cp -f droid-user-remove.sh droid-user-remove.sh.installed
# Now ensure default user has access to various subsystems this HA provides
# These are the default android ones:
/usr/bin/groupadd-user audio || :
/usr/bin/groupadd-user graphics || :
/usr/bin/groupadd-user system || :
/usr/bin/groupadd-user input || :
/usr/bin/groupadd-user camera || :
# To add additional groups define a HA config macro like android_config
%post sailfish-config
%{_bindir}/add-oneshot dconf-update || :
%post kernel-modules
# This runs on the device at install or in mic chroot at img build
# in chroot the kernel version is not known.
for ver in $(cd /lib/modules; echo *); do
/sbin/depmod $ver || :
done
%if 0%{?enable_kernel_update:1}
%post img-boot
# This oneshot is enabled only during package upgrades, as initial
# installation is done when we flash device.
if [ $1 -ne 1 ] ; then
add-preinit-oneshot /var/lib/platform-updates/flash-bootimg.sh
fi
%endif
################################################################
# Begin files section
%files -f tmp/rpmsrc/conf.files
%defattr(-,root,root,-)
/sbin/*
%{_bindir}/droid/droid-init-done.sh
%{_bindir}/droid/kill-cgroup.sh
%{_bindir}/droid/droid-hal-startup.sh
# This binary should probably move to /sbin/
%{_libdir}/droid/droid-user-add.sh
%{_libdir}/droid/droid-user-remove.sh
%{_libdir}/droid/apply-permissions
%{_libdir}/droid/all-units.txt
%{board_mapping_file}
# Created in %%post
# init-debug
%attr(755,root,root) /init-debug
%ghost %attr(755, root, root) %{_libdir}/droid/droid-user-remove.sh.installed
# droid binaries
%{_libexecdir}/droid-hybris/system/bin/
# Non executable files
%defattr(644,root,root,-)
%{_unitdir}
# hybris and /dev/alog/ libraries
%{_libexecdir}/droid-hybris/system/lib/
# just /dev/alog/ libraries (for trying to run pure android apps)
%{_libexecdir}/droid-hybris/lib-dev-alog/.
/lib/udev/rules.d/*
/lib/udev/platform-device
# Droid config droppings
/*.rc
/default.prop
%{_sharedstatedir}/environment/compositor/droid-hal-device.conf
%{_sharedstatedir}/environment/nemo/99-hybris.conf
%{_datadir}/qt5/keymaps/droid.qmap
# Hardware and build info
%config %{_sysconfdir}/hw-release
# Disabling v4l.rules
%{_sysconfdir}/udev/rules.d/60-persistent-v4l.rules
%files devel
%defattr(644,root,root,-)
%{_libdir}/droid-devel/
%{_libdir}/pkgconfig/*pc
%files sailfish-config
%defattr(-,root,root,-)
%{_sysconfdir}/dconf/db/vendor.d/screen-rotation.txt
%{_sysconfdir}/dconf/db/vendor.d/locks/screen-rotation.txt
%files kernel
%defattr(644,root,root,-)
/boot/kernel*
%files kernel-modules
%defattr(644,root,root,-)
/lib/modules
%files img-boot
%defattr(644,root,root,-)
/boot/hybris-boot.img
/boot/update-binary
/boot/hybris-updater-script
/boot/hybris-updater-unpack.sh
%if 0%{?enable_kernel_update:1}
%attr(744, root, root) /var/lib/platform-updates/flash-bootimg.sh
%endif
%files img-recovery
%defattr(644,root,root,-)
/boot/hybris-recovery.img
%files pulseaudio-settings
%defattr(644,root,root,-)
%files policy-settings
%defattr(644,root,root,-)
%files kickstart-configuration
%defattr(644,root,root-)
%{_datadir}/ssu/kickstart/pack/%{device}/package-droid-updater
%{_datadir}/ssu/kickstart/attachment/%{device}
%files patterns
%defattr(-,root,root,-)
%{_datadir}/package-groups/*.xml
%files preinit-plugin
%defattr(-,root,root,-)
%{_libdir}/startup/preinit/*