summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Duarte <licorne@google.com> 2023-02-22 21:27:34 +0000
committer David Duarte <licorne@google.com> 2024-04-25 18:53:45 +0000
commitf11fe8898e9beef13f2827bbd169ccc16ce48505 (patch)
tree63e4403c591ab7b988c6fb694d71cc8a7800e5ab
parent50f0dd79bf1c87a3b12dcfb99c311f6b7507c6d9 (diff)
Add the sysprop_cpp tool inside floss docker image
Bug: 337064224 Test: ./container-build-image.py --use-docker Flag: EXEMPT, floss docker image Change-Id: I8d35ad407a36abca1b85e2f1158a6d945ff1d5ee
-rwxr-xr-xbuild.py1
-rwxr-xr-xfloss/build/container-build-image.py8
-rw-r--r--system/build/dpkg/sysprop/debian/README.Debian1
-rw-r--r--system/build/dpkg/sysprop/debian/changelog5
-rw-r--r--system/build/dpkg/sysprop/debian/compat1
-rw-r--r--system/build/dpkg/sysprop/debian/control17
-rw-r--r--system/build/dpkg/sysprop/debian/patches/series0
-rwxr-xr-xsystem/build/dpkg/sysprop/debian/rules25
-rw-r--r--system/build/dpkg/sysprop/debian/sysprop.install1
-rwxr-xr-xsystem/build/dpkg/sysprop/gen-src-pkg.sh57
10 files changed, 115 insertions, 1 deletions
diff --git a/build.py b/build.py
index d5ed30e76a..8c17ddd3a4 100755
--- a/build.py
+++ b/build.py
@@ -119,6 +119,7 @@ REQUIRED_APT_PACKAGES = [
'libevent-dev',
'libevent-dev',
'libflatbuffers-dev',
+ 'libfmt-dev',
'libgl1-mesa-dev',
'libglib2.0-dev',
'libgtest-dev',
diff --git a/floss/build/container-build-image.py b/floss/build/container-build-image.py
index 10aef68e10..b48d8e50ad 100755
--- a/floss/build/container-build-image.py
+++ b/floss/build/container-build-image.py
@@ -90,8 +90,14 @@ class ContainerImageBuilder:
# Install libchrome.
['find', '/tmp/libchrome', '-name', 'libchrome_*.deb', '-exec', 'dpkg', '-i', '{}', '+'],
+ # Run the dpkg builder for sysprop
+ [f'{SRC_MOUNT}/system/build/dpkg/sysprop/gen-src-pkg.sh', '/tmp/sysprop'],
+
+ # Install sysprop.
+ ['find', '/tmp/sysprop', '-name', 'sysprop_*.deb', '-exec', 'dpkg', '-i', '{}', '+'],
+
# Delete intermediate files
- ['rm', '-rf', '/tmp/libchrome', '/tmp/modpb64'],
+ ['rm', '-rf', '/tmp/libchrome', '/tmp/modpb64', '/tmp/sysprop'],
]
try:
diff --git a/system/build/dpkg/sysprop/debian/README.Debian b/system/build/dpkg/sysprop/debian/README.Debian
new file mode 100644
index 0000000000..f6a5421c09
--- /dev/null
+++ b/system/build/dpkg/sysprop/debian/README.Debian
@@ -0,0 +1 @@
+sysprop for Debian
diff --git a/system/build/dpkg/sysprop/debian/changelog b/system/build/dpkg/sysprop/debian/changelog
new file mode 100644
index 0000000000..da1b46332d
--- /dev/null
+++ b/system/build/dpkg/sysprop/debian/changelog
@@ -0,0 +1,5 @@
+sysprop (0.0.1-1) buster; urgency=low
+
+ * Initial release.
+
+ -- David Duarte <licorne@google.com> Tue, 21 Feb 2022 00:00:00 +0000
diff --git a/system/build/dpkg/sysprop/debian/compat b/system/build/dpkg/sysprop/debian/compat
new file mode 100644
index 0000000000..f599e28b8a
--- /dev/null
+++ b/system/build/dpkg/sysprop/debian/compat
@@ -0,0 +1 @@
+10
diff --git a/system/build/dpkg/sysprop/debian/control b/system/build/dpkg/sysprop/debian/control
new file mode 100644
index 0000000000..39fb0f23a0
--- /dev/null
+++ b/system/build/dpkg/sysprop/debian/control
@@ -0,0 +1,17 @@
+Source: sysprop
+Section: misc
+Priority: optional
+Maintainer: David Duarte <licorne@google.com>
+Standards-Version: 4.1.4
+Homepage: https://android.googlesource.com/platform/system/tools/sysprop
+Build-Depends:
+ debhelper (>=11~),
+ clang,
+ libfmt-dev,
+ protobuf-compiler
+
+Package: sysprop
+Architecture: any
+Multi-Arch: foreign
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Description: sysprop codegen tools
diff --git a/system/build/dpkg/sysprop/debian/patches/series b/system/build/dpkg/sysprop/debian/patches/series
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/system/build/dpkg/sysprop/debian/patches/series
diff --git a/system/build/dpkg/sysprop/debian/rules b/system/build/dpkg/sysprop/debian/rules
new file mode 100755
index 0000000000..7e5d507591
--- /dev/null
+++ b/system/build/dpkg/sysprop/debian/rules
@@ -0,0 +1,25 @@
+#!/usr/bin/make -f
+
+CC = clang
+CXX = clang++
+CPPFLAGS = -Iinclude -I.
+CXXFLAGS = -std=c++17
+LDFLAGS = -lprotobuf -lfmt -lstdc++
+
+%:
+ dh $@
+
+override_dh_auto_clean:
+ rm -rf sysprop_cpp
+
+override_dh_auto_build: sysprop_cpp
+
+posix_strerror_r.o: CPPFLAGS += -D_POSIX_C_SOURCE=200112L
+
+Common.o CppGen.o: sysprop.pb.h
+
+sysprop_cpp: CppMain.o CppGen.o Common.o CodeWriter.o sysprop.pb.o file.o strings.o stringprintf.o posix_strerror_r.o
+ $(LINK.o) $^ -o $@
+
+sysprop.pb.h sysprop.pb.cc: sysprop.proto
+ protoc --proto_path=. --cpp_out=. sysprop.proto
diff --git a/system/build/dpkg/sysprop/debian/sysprop.install b/system/build/dpkg/sysprop/debian/sysprop.install
new file mode 100644
index 0000000000..1ec30c7563
--- /dev/null
+++ b/system/build/dpkg/sysprop/debian/sysprop.install
@@ -0,0 +1 @@
+sysprop_cpp /usr/bin
diff --git a/system/build/dpkg/sysprop/gen-src-pkg.sh b/system/build/dpkg/sysprop/gen-src-pkg.sh
new file mode 100755
index 0000000000..effd0f6e41
--- /dev/null
+++ b/system/build/dpkg/sysprop/gen-src-pkg.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+# Generates Debian source and binary packages of android sysprop tool.
+
+if [ -z "$1" ]; then
+ echo "Usage: gen-src-pkg.sh <output-dir>"
+ exit 1
+fi
+
+outdir="$1"
+pkgdir=sysprop-0.0.1
+origtar=sysprop_0.0.1.orig.tar.gz
+scriptdir="$( cd "$( dirname "$0" )" && pwd )"
+branch=platform-tools-34.0.0
+
+tmpdir=$(mktemp -d)
+echo Generating source package in "${tmpdir}".
+
+cd "${tmpdir}"
+# Download libbase source.
+git clone --branch "${branch}" https://android.googlesource.com/platform/system/libbase || exit 1
+
+# Download sysprop source.
+git clone --branch "${branch}" https://android.googlesource.com/platform/system/tools/sysprop "${pkgdir}" || exit 1
+cd "${pkgdir}"
+rm -rf .git
+
+cp -ra ../libbase/include/android-base include
+echo "#include <iostream>" > include/android-base/logging.h
+echo "#define LOG(x) std::cerr" >> include/android-base/logging.h
+echo "#define PLOG(x) std::cerr" >> include/android-base/logging.h
+cp -ra ../libbase/{file,strings,stringprintf,posix_strerror_r}.cpp .
+
+cd ..
+
+# Debian requires creating .orig.tar.gz.
+tar czf "${origtar}" "${pkgdir}"
+
+# Debianize the source.
+cd "${pkgdir}"
+yes | debmake || exit 1
+cp -aT "${scriptdir}/debian/" "${tmpdir}/${pkgdir}/debian/"
+
+# Build source package and binary package.
+cd "${tmpdir}/${pkgdir}"
+dpkg-buildpackage --no-sign || exit 1
+
+# Copy the results to output dir.
+cd "${tmpdir}"
+mkdir -p "${outdir}/src"
+cp *.dsc *.orig.tar.gz *.debian.tar.xz "${outdir}/src"
+cp *.deb "${outdir}"
+cd /
+
+echo Removing temporary directory "${tmpdir}".
+rm -rf "${tmpdir}"
+
+echo Done. Check out Debian source package in "${outdir}".