From e6fdf8d18cba0e598dc81ad3ab3829676a16aa51 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Wed, 24 Sep 2014 12:41:04 +0100 Subject: [PATCH 1/9] [all] init-debug should come from hybris-boot git repo and lives in %{android_root}/hybris/hybris-boot/ --- droid-hal-device.inc | 3 +- init-debug | 134 ------------------------------------------- 2 files changed, 1 insertion(+), 136 deletions(-) delete mode 100755 init-debug diff --git a/droid-hal-device.inc b/droid-hal-device.inc index fced42d8..8d33491d 100644 --- a/droid-hal-device.inc +++ b/droid-hal-device.inc @@ -60,7 +60,6 @@ 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 @@ -400,7 +399,7 @@ 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/ +cp -a %{android_root}/hybris/hybris-boot/init-script $RPM_BUILD_ROOT/init-debug # droid user support This may be better done by passing a list of # users/groups and running 'ensure_usergroups_exist newlist oldlist' diff --git a/init-debug b/init-debug deleted file mode 100755 index 5adefeb9..00000000 --- a/init-debug +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/sh -# -# Hybris adaptation bootstrapping initramfs init script. -# -# Copyright (c) 2014 Jolla Oy -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License version 2 as published by the -# Free Software Foundation. -# -# Author: -# - Tom Swindell -# - David Greaves -# - -# General logging -set -x -exec > /init.log 2>&1 -echo "Running Mer Boat Loader" - -set_welcome_msg(){ -cat <> /etc/issue.net -Welcome to the Mer/SailfishOS Boat loader debug init system. - -Log so far is in /init.log - -EOF -} - -export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin - -# Default setting is rndis - add mass_storage for a debug boot -# enable using usb_setup -USB_FUNCTIONS=rndis - -ANDROID_USB=/sys/class/android_usb/android0 -LOCAL_IP=192.168.2.1 - -DONE_SWITCH=yes - -# Minimal mounts for initrd or pre-init debug session -do_mount_devprocsys() -{ - echo "########################## mounting devprocsys" - mkdir /dev - mount -t devtmpfs devtmpfs /dev - # telnetd needs /dev/pts/ entries - mkdir /dev/pts - mount -t devpts devpts /dev/pts - - mkdir /proc - mkdir /sys - mount -t sysfs sysfs /sys - mount -t proc proc /proc -} - -# Sugar for accessing usb config -write() { - echo -n "$2" > "$1" -} - -# This sets up the USB with whatever USB_FUNCTIONS are set to -usb_setup() { - write $ANDROID_USB/enable 0 - write $ANDROID_USB/functions "" - write $ANDROID_USB/enable 1 - usleep 500000 # 0.5 delay to attempt to remove rndis function - write $ANDROID_USB/enable 0 - write $ANDROID_USB/idVendor 18D1 - write $ANDROID_USB/idProduct D001 - write $ANDROID_USB/iManufacturer "Mer Boat Loader" - write $ANDROID_USB/iProduct "$CUSTOMPRODUCT" - write $ANDROID_USB/iSerial "$1" - write $ANDROID_USB/functions $USB_FUNCTIONS - write $ANDROID_USB/enable 1 -} -# This lets us communicate errors to host (if it needs disable/enable then that's a problem) -usb_info() { - # make sure USB is settled - echo "########################## usb_info: $1" - sleep 1 - write $ANDROID_USB/iSerial "$1" -} - - -run_debug_session() { - CUSTOMPRODUCT=$1 - echo "########################## Debug session : $1" - usb_setup "Mer Debug setting up (DONE_SWITCH=$DONE_SWITCH)" - - USB_IFACE=notfound - /sbin/ifconfig usb0 $LOCAL_IP && USB_IFACE=usb0 - /sbin/ifconfig rndis0 $LOCAL_IP && USB_IFACE=rndis0 - # Report for the logs - /sbin/ifconfig - - # Unable to set up USB interface? Reboot. - if [ x$USB_IFACE = xnotfound ]; then - usb_info "Mer Debug: ERROR: could not setup USB as usb0 or rndis0" - dmesg - sleep 60 # plenty long enough to check usb on host - reboot -f - fi - - echo "interface $USB_IFACE" >> /etc/udhcpd.conf - # Be explicit about busybox so this works in a rootfs too - echo "########################## starting dhcpd" - $EXPLICIT_BUSYBOX udhcpd - - set_welcome_msg - # Non-blocking telnetd - echo "########################## starting telnetd" - # We run telnetd on different ports pre/post-switch_root This - # avoids problems with an unterminated pre-switch_root telnetd - # hogging the port - $EXPLICIT_BUSYBOX telnetd -p $TELNET_DEBUG_PORT -l /bin/sh -} - - - -# We're in the real rootfs running as init-debug -EXPLICIT_BUSYBOX="/bin/busybox-static" -TELNET_DEBUG_PORT=2323 - -do_mount_devprocsys - -run_debug_session "Persistent telnetd" - -# If we don't do this then udev will not be able to create /dev/block/* -rm /dev/block - -# Now try to boot the real init -exec /sbin/init --log-level=debug --log-target=kmsg &> /boot/systemd_stdouterr - From 3053a8d3bfa1ebdc51d30612d452c654d886bfde Mon Sep 17 00:00:00 2001 From: David Greaves Date: Sat, 8 Nov 2014 16:32:47 +0000 Subject: [PATCH 2/9] [all] Add define: device_target_cpu: Used for native builds. Normally the nested droid build env will do an old-fashioned cross-compile and produce non-x86 binaries (default armv7hl). This can be set to tell OBS what arch the binaries are. Eg Android for Intel arch must set this. Signed-off-by: David Greaves --- droid-hal-device.inc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/droid-hal-device.inc b/droid-hal-device.inc index 8d33491d..e7add208 100644 --- a/droid-hal-device.inc +++ b/droid-hal-device.inc @@ -5,6 +5,7 @@ # 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" +# device_target_cpu: Used for native builds. Normally the nested droid build env will do an old-fashioned cross-compile and produce non-x86 binaries (default armv7hl). This can be set to tell OBS what arch the binaries are. Eg Android for Intel arch must set this. %define __provides_exclude_from ^%{_libexecdir}/droid-hybris/.*$ %define android_root . @@ -15,7 +16,11 @@ # 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 +%if 0%{?device_target_cpu:1} +%define my_target_cpu %{device_target_cpu} +%else %define _target_cpu armv7hl +%endif # Support build info extracted from OBS builds too %if 0%{?_obs_build_project:1} @@ -249,6 +254,8 @@ cp %{SOURCE40} %{SOURCE0} %build +echo _target_cpu is %{_target_cpu} + %if 0%{?_obs_build_project:1} # Hadk style build of android on OBS echo Running droid build in HABUILD_SDK From 1862bf89a9b1c1b20bd328cf3f682e5680cccc93 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Mon, 10 Nov 2014 14:31:30 +0000 Subject: [PATCH 3/9] [all] breakfast is CM specific; use lunch. See http://wiki.cyanogenmod.org/w/Envsetup_help#lunch Signed-off-by: David Greaves --- droid-hal-device.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/droid-hal-device.inc b/droid-hal-device.inc index e7add208..0fb3e00d 100644 --- a/droid-hal-device.inc +++ b/droid-hal-device.inc @@ -259,7 +259,7 @@ echo _target_cpu is %{_target_cpu} %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}" +ubu-chroot -r /srv/mer/sdks/ubu "cd %android_root; source build/envsetup.sh; lunch %{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 From 487a988ac48b6d4e4eb13cfac386c25a05749dab Mon Sep 17 00:00:00 2001 From: David Greaves Date: Mon, 10 Nov 2014 18:08:36 +0000 Subject: [PATCH 4/9] [all] Add support for %{device_variant} for AOSP --- droid-hal-device.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/droid-hal-device.inc b/droid-hal-device.inc index 0fb3e00d..14d7be58 100644 --- a/droid-hal-device.inc +++ b/droid-hal-device.inc @@ -1,11 +1,12 @@ # This file should be %%included into a device specific spec file # where macros are defined: -# device: should be the CM codename +# device: should be the CM codename or the AOSP TARGET_PRODUCT # vendor: determine the directory used for ./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" # device_target_cpu: Used for native builds. Normally the nested droid build env will do an old-fashioned cross-compile and produce non-x86 binaries (default armv7hl). This can be set to tell OBS what arch the binaries are. Eg Android for Intel arch must set this. +# device_variant: for AOSP this is used as the TARGET_BUILD_VARIANT for lunch %define __provides_exclude_from ^%{_libexecdir}/droid-hybris/.*$ %define android_root . @@ -259,7 +260,7 @@ echo _target_cpu is %{_target_cpu} %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; lunch %{device}; rm -f .repo/local_manifests/roomservice.xml; make %{?_smp_mflags} %{?hadk_make_target}%{!?hadk_make_target:hybris-hal}" +ubu-chroot -r /srv/mer/sdks/ubu "cd %android_root; source build/envsetup.sh; lunch %{device}%{?device_variant}; 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 From 301e98d246df00afc8158029f191a323dec6e8f6 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Tue, 11 Nov 2014 09:55:12 +0000 Subject: [PATCH 5/9] [all] AOSP seems to use .../obj/kernel/.config not obj/KERNEL_OBJ/.config so wildcard it --- droid-hal-device.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/droid-hal-device.inc b/droid-hal-device.inc index 14d7be58..09aa6399 100644 --- a/droid-hal-device.inc +++ b/droid-hal-device.inc @@ -268,8 +268,9 @@ rm -rf tmp mkdir tmp echo Verifying kernel config +# AOSP seems to use .../obj/kernel/.config not obj/KERNEL_OBJ/.config like CM : so wildcard it hybris/mer-kernel-check/mer_verify_kernel_config \ - %{android_root}/out/target/product/%{device}/obj/KERNEL_OBJ/.config + %{android_root}/out/target/product/%{device}/obj/*/.config echo Building local tools mkdir tmp/rpmsrc From db99f0f23801419b42b9845b5d6af769874064d7 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Fri, 14 Nov 2014 14:46:00 +0000 Subject: [PATCH 6/9] [all] More relaxation for KERNEL_OBJ/ ; Don't fail if modules are missing; remove duplicate line --- droid-hal-device.inc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/droid-hal-device.inc b/droid-hal-device.inc index 09aa6399..d2c0d52c 100644 --- a/droid-hal-device.inc +++ b/droid-hal-device.inc @@ -492,14 +492,13 @@ 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) +KERNEL_RELEASE=$(cat out/target/product/%{device}/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 +cp -a out/target/product/%{device}/system/lib/modules/. $MOD_DIR/. || true +cp -a out/target/product/%{device}/obj/*/modules.builtin $MOD_DIR/. || true +cp -a out/target/product/%{device}/obj/*/modules.order $MOD_DIR/. || true # Images are installed to /boot - they'll probably be unpacked using # rpm2cpio mostly anyhow From d0a3a6c420ad04ac4b0453c827de6af5afd528fd Mon Sep 17 00:00:00 2001 From: David Greaves Date: Tue, 18 Nov 2014 10:19:35 +0000 Subject: [PATCH 7/9] [all] Move apply-permissions.c to helpers and prepare an Android.mk to build it droid-side --- droid-hal-device.inc | 1 - helpers/Android.mk | 16 ++++++++++++++++ .../apply-permissions.c | 0 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 helpers/Android.mk rename apply-permissions.c => helpers/apply-permissions.c (100%) diff --git a/droid-hal-device.inc b/droid-hal-device.inc index d2c0d52c..83831e0d 100644 --- a/droid-hal-device.inc +++ b/droid-hal-device.inc @@ -59,7 +59,6 @@ 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 diff --git a/helpers/Android.mk b/helpers/Android.mk new file mode 100644 index 00000000..52c6587e --- /dev/null +++ b/helpers/Android.mk @@ -0,0 +1,16 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + apply-permissions.c + +LOCAL_C_INCLUDES += system/core/include/private/ + +LOCAL_SHARED_LIBRARIES := + +LOCAL_CFLAGS := -std=c99 + +LOCAL_MODULE:= apply-permissions + + +include $(BUILD_EXECUTABLE) diff --git a/apply-permissions.c b/helpers/apply-permissions.c similarity index 100% rename from apply-permissions.c rename to helpers/apply-permissions.c From 0e4a3e46644aa682047e21d7b2faece85b698b1e Mon Sep 17 00:00:00 2001 From: David Greaves Date: Thu, 27 Nov 2014 11:09:20 +0000 Subject: [PATCH 8/9] [all] apply-permissions resets permissions in /system. Support building apply-permissions in droid-space (ensures it is cross compiled properly). However it's not used at the moment so don't package it. --- droid-hal-device.inc | 3 --- 1 file changed, 3 deletions(-) diff --git a/droid-hal-device.inc b/droid-hal-device.inc index 83831e0d..0b099409 100644 --- a/droid-hal-device.inc +++ b/droid-hal-device.inc @@ -424,8 +424,6 @@ cp rpm/dsp/bin/* $RPM_BUILD_ROOT/%{_bindir}/droid 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.* @@ -583,7 +581,6 @@ fi # 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 From deefe92f327ff0b26261dfc797eef236df03dc53 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Mon, 1 Dec 2014 21:34:34 +0000 Subject: [PATCH 9/9] [all] Move usergroupgen to helpers --- droid-hal-device.inc | 14 +++++--------- makefile => helpers/makefile | 0 usergroupgen.c => helpers/usergroupgen.c | 0 3 files changed, 5 insertions(+), 9 deletions(-) rename makefile => helpers/makefile (100%) rename usergroupgen.c => helpers/usergroupgen.c (100%) diff --git a/droid-hal-device.inc b/droid-hal-device.inc index 0b099409..b43e9ab3 100644 --- a/droid-hal-device.inc +++ b/droid-hal-device.inc @@ -57,9 +57,7 @@ Provides: flash-partition # doesn't like. This is not a problem for local builds. Source0: rpm.tar.bzip2 Source1: makefstab -Source2: usergroupgen.c Source3: makeudev -Source5: makefile Source7: device-%{vendor}-%{device}-configs Source8: hybris.conf Source10: droid-hal-device.inc @@ -272,14 +270,12 @@ hybris/mer-kernel-check/mer_verify_kernel_config \ %{android_root}/out/target/product/%{device}/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}) +(cd helpers; make ANDROID_ROOT=$ANDROID_ROOT) echo Building uid scripts -tmp/rpmsrc/usergroupgen add > tmp/rpmsrc/droid-user-add.sh -tmp/rpmsrc/usergroupgen remove > tmp/rpmsrc/droid-user-remove.sh +helpers/usergroupgen add > helpers/droid-user-add.sh +helpers/usergroupgen remove > helpers/droid-user-remove.sh echo Building udev rules mkdir tmp/udev.rules @@ -414,8 +410,8 @@ cp -a %{android_root}/hybris/hybris-boot/init-script $RPM_BUILD_ROOT/init-debug # 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 +install -D helpers/droid-user-add.sh $RPM_BUILD_ROOT%{_libdir}/droid/droid-user-add.sh +install -D helpers/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 diff --git a/makefile b/helpers/makefile similarity index 100% rename from makefile rename to helpers/makefile diff --git a/usergroupgen.c b/helpers/usergroupgen.c similarity index 100% rename from usergroupgen.c rename to helpers/usergroupgen.c