summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md20
-rw-r--r--system/build/dpkg/README.txt25
-rw-r--r--system/build/dpkg/libchrome/debian/README.Debian1
-rw-r--r--system/build/dpkg/libchrome/debian/changelog5
-rw-r--r--system/build/dpkg/libchrome/debian/compat1
-rw-r--r--system/build/dpkg/libchrome/debian/control27
-rwxr-xr-xsystem/build/dpkg/libchrome/debian/install_headers.sh48
-rw-r--r--system/build/dpkg/libchrome/debian/libchrome.install4
-rw-r--r--system/build/dpkg/libchrome/debian/patches/0001-Add-missing-includes.patch37
-rw-r--r--system/build/dpkg/libchrome/debian/patches/0001-common-mk-rebase_path-output-location-of-generate-pc.patch36
-rw-r--r--system/build/dpkg/libchrome/debian/patches/0001-rebase_path-for-write_args.patch34
-rw-r--r--system/build/dpkg/libchrome/debian/patches/series3
-rwxr-xr-xsystem/build/dpkg/libchrome/debian/rules38
-rwxr-xr-xsystem/build/dpkg/libchrome/gen-src-pkg.sh60
-rw-r--r--system/build/dpkg/modp_b64/debian/README.Debian1
-rw-r--r--system/build/dpkg/modp_b64/debian/changelog5
-rw-r--r--system/build/dpkg/modp_b64/debian/compat1
-rw-r--r--system/build/dpkg/modp_b64/debian/control18
-rw-r--r--system/build/dpkg/modp_b64/debian/modp-b64.install3
-rw-r--r--system/build/dpkg/modp_b64/debian/patches/0001-common-mk-rebase_path-output-location-of-generate-pc.patch36
-rw-r--r--system/build/dpkg/modp_b64/debian/patches/series1
-rwxr-xr-xsystem/build/dpkg/modp_b64/debian/rules31
-rwxr-xr-xsystem/build/dpkg/modp_b64/gen-src-pkg.sh57
-rwxr-xr-xsystem/build/install_deps.sh17
24 files changed, 497 insertions, 12 deletions
diff --git a/README.md b/README.md
index 38d2e2ebc1..6b90075a91 100644
--- a/README.md
+++ b/README.md
@@ -49,12 +49,24 @@ The following third-party dependencies are necessary but currently unavailable
via a package manager. You may have to build these from source and install them
to your local environment.
-TODO(abhishekpandit) - Provide a pre-packaged option for these or proper build
-instructions from source.
-
* libchrome
* modp_b64
-* tinyxml2
+
+We provide a script to produce debian packages for those components, please
+follow the instructions in build/dpkg/README.txt.
+
+The googletest packages provided by Debian/Ubuntu (libgmock-dev and
+libgtest-dev) do not provide pkg-config files, so you can build your own
+googletest using the steps below:
+
+```
+$ git clone https://github.com/google/googletest.git -b release-1.10.0
+$ cd googletest # Main directory of the cloned repository.
+$ mkdir build # Create a directory to hold the build output.
+$ cd build
+$ cmake .. # Generate native build scripts for GoogleTest.
+$ sudo make install -DCMAKE_INSTALL_PREFIX=/usr
+```
### Stage your build environment
diff --git a/system/build/dpkg/README.txt b/system/build/dpkg/README.txt
new file mode 100644
index 0000000000..7850796024
--- /dev/null
+++ b/system/build/dpkg/README.txt
@@ -0,0 +1,25 @@
+This directory contains scripts to build Debian packages as dependencies for
+building Fluoride on Linux.
+
+To generate the Debian packages, you need:
+
+* Debian 10 (Buster)
+* gn, get binary from https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest
+* apt-get install git debmake
+* Other build dependencies are package dependent, you will get error message
+ mentioning the list of missing packages
+
+Steps to build debian packages (modp_b64 first):
+```
+$ cd build/dpkg/modp_b64
+$ ./gen-src-pkg /tmp/modp_b64
+```
+
+If the above succeeded, there will be a .deb file in /tmp/modp_b64. You can
+install this binary package locally like:
+```
+$ sudo dpkg -i /tmp/modp_b64/modp-b64_0.0.1-1_amd64.deb
+```
+
+After installing modp_b64, you can do the same steps with libchrome in
+build/dpkg/libchrome.
diff --git a/system/build/dpkg/libchrome/debian/README.Debian b/system/build/dpkg/libchrome/debian/README.Debian
new file mode 100644
index 0000000000..773bbf318e
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/README.Debian
@@ -0,0 +1 @@
+libchrome for Debian
diff --git a/system/build/dpkg/libchrome/debian/changelog b/system/build/dpkg/libchrome/debian/changelog
new file mode 100644
index 0000000000..3cdedf6890
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/changelog
@@ -0,0 +1,5 @@
+libchrome (780652-1) buster; urgency=low
+
+ * Initial release.
+
+ -- Sonny Sasaka <sonnysasaka@chromium.org> Fri, 19 Mar 2021 19:41:40 +0000
diff --git a/system/build/dpkg/libchrome/debian/compat b/system/build/dpkg/libchrome/debian/compat
new file mode 100644
index 0000000000..f599e28b8a
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/compat
@@ -0,0 +1 @@
+10
diff --git a/system/build/dpkg/libchrome/debian/control b/system/build/dpkg/libchrome/debian/control
new file mode 100644
index 0000000000..d804b4d88d
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/control
@@ -0,0 +1,27 @@
+Source: libchrome
+Section: libs
+Priority: optional
+Maintainer: Sonny Sasaka <sonnysasaka@chromium.org>
+Standards-Version: 4.1.4
+Homepage: https://chromium.googlesource.com/aosp/platform/external/libchrome/
+Build-Depends:
+ debhelper (>=11~),
+ clang,
+ python3,
+ pkg-config,
+ ninja-build,
+ libglib2.0-dev,
+ libevent-dev,
+ libnss3-dev,
+ libdbus-1-dev,
+ libprotobuf-dev,
+ googletest,
+ libre2-dev,
+ libdouble-conversion-dev,
+ libssl-dev
+
+Package: libchrome
+Architecture: any
+Multi-Arch: foreign
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Description: Chromium's base library
diff --git a/system/build/dpkg/libchrome/debian/install_headers.sh b/system/build/dpkg/libchrome/debian/install_headers.sh
new file mode 100755
index 0000000000..19cb5efa80
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/install_headers.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+destdir="$1"
+
+header_dirs=(
+ base
+ base/allocator
+ base/containers
+ base/debug
+ base/files
+ base/hash
+ base/i18n
+ base/json
+ base/memory
+ base/message_loop
+ base/metrics
+ base/numerics
+ base/posix
+ base/process
+ base/strings
+ base/synchronization
+ base/system
+ base/task
+ base/task/common
+ base/task/sequence_manager
+ base/task/thread_pool
+ base/test
+ base/third_party/icu
+ base/third_party/nspr
+ base/third_party/valgrind
+ base/threading
+ base/time
+ base/timer
+ base/trace_event
+ base/trace_event/common
+ build
+ components/policy
+ components/policy/core/common
+ testing/gmock/include/gmock
+ testing/gtest/include/gtest
+ dbus
+ )
+
+# Install header files.
+for d in "${header_dirs[@]}" ; do
+ mkdir -p "${destdir}/usr/include/libchrome/${d}"
+ cp libchrome/"${d}"/*.h "${destdir}/usr/include/libchrome/${d}"
+done
diff --git a/system/build/dpkg/libchrome/debian/libchrome.install b/system/build/dpkg/libchrome/debian/libchrome.install
new file mode 100644
index 0000000000..9d381c1e2b
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/libchrome.install
@@ -0,0 +1,4 @@
+out/Release/lib/libbase*.so /usr/lib
+out/Release/libbase*.a /usr/lib
+out/Release/obj/libchrome/libchrome*.pc /usr/lib/pkgconfig
+usr/include /usr
diff --git a/system/build/dpkg/libchrome/debian/patches/0001-Add-missing-includes.patch b/system/build/dpkg/libchrome/debian/patches/0001-Add-missing-includes.patch
new file mode 100644
index 0000000000..a2f2b4b9ad
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/patches/0001-Add-missing-includes.patch
@@ -0,0 +1,37 @@
+From 50a4636886c958717213856132fcbb57c3b8ea2a Mon Sep 17 00:00:00 2001
+From: Sonny Sasaka <sonnysasaka@chromium.org>
+Date: Fri, 19 Mar 2021 16:18:07 -0700
+Subject: [PATCH] Add missing includes
+
+---
+ base/hash/md5.cc | 1 +
+ crypto/p224_spake.cc | 1 +
+ 2 files changed, 2 insertions(+)
+
+diff --git a/libchrome/base/hash/md5.cc b/libchrome/base/hash/md5.cc
+index bdb9990a9..ef8954eaf 100644
+--- a/libchrome/base/hash/md5.cc
++++ b/libchrome/base/hash/md5.cc
+@@ -24,6 +24,7 @@
+ #include "base/hash/md5.h"
+
+ #include <stddef.h>
++#include <string.h>
+
+ namespace {
+
+diff --git a/libchrome/crypto/p224_spake.cc b/libchrome/crypto/p224_spake.cc
+index 157410537..de0af5466 100644
+--- a/libchrome/crypto/p224_spake.cc
++++ b/libchrome/crypto/p224_spake.cc
+@@ -8,6 +8,7 @@
+ #include <crypto/p224_spake.h>
+
+ #include <algorithm>
++#include <string.h>
+
+ #include <base/logging.h>
+ #include <crypto/p224.h>
+--
+2.20.1
+
diff --git a/system/build/dpkg/libchrome/debian/patches/0001-common-mk-rebase_path-output-location-of-generate-pc.patch b/system/build/dpkg/libchrome/debian/patches/0001-common-mk-rebase_path-output-location-of-generate-pc.patch
new file mode 100644
index 0000000000..418efcc475
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/patches/0001-common-mk-rebase_path-output-location-of-generate-pc.patch
@@ -0,0 +1,36 @@
+From 04fa5e1ade08696b5a2cc3b65bf0fd26c43251c7 Mon Sep 17 00:00:00 2001
+From: Sonny Sasaka <sonnysasaka@chromium.org>
+Date: Fri, 19 Mar 2021 11:17:43 -0700
+Subject: [PATCH] common-mk: rebase_path output location of generate-pc.py
+
+Without rebase_path, the generate-pc.py would be called like
+`generate-pc.py --output //out/Release` if the output is inside the
+source directory and this gn path isn't recognized as a generic
+filesystem path.
+
+BUG=b:183216216
+TEST=with modp_b64, call
+$ gn gen out/Release --args=...
+$ ninja
+
+Change-Id: Ic9d9b3d01d52d483e3d81ca2e8d514b47900f5bb
+---
+ common-mk/pkg_config.gni | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/common-mk/pkg_config.gni b/common-mk/pkg_config.gni
+index 24e2cf1401..b2c58845d4 100644
+--- a/common-mk/pkg_config.gni
++++ b/common-mk/pkg_config.gni
+@@ -84,7 +84,7 @@ template("generate_pkg_config") {
+ outputs = [ "${target_out_dir}/${output_name}.pc" ]
+
+ script = "//common-mk/generate-pc.py"
+- args = [ "--output" ] + outputs + [ "--name=" + name ]
++ args = [ "--output" ] + rebase_path(outputs) + [ "--name=" + name ]
+ if (defined(description)) {
+ args += [ "--description=" + description ]
+ }
+--
+2.29.2
+
diff --git a/system/build/dpkg/libchrome/debian/patches/0001-rebase_path-for-write_args.patch b/system/build/dpkg/libchrome/debian/patches/0001-rebase_path-for-write_args.patch
new file mode 100644
index 0000000000..9b359c0e8d
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/patches/0001-rebase_path-for-write_args.patch
@@ -0,0 +1,34 @@
+From 6875449497baf026fb8228668930a715ffcc7082 Mon Sep 17 00:00:00 2001
+From: Sonny Sasaka <sonnysasaka@chromium.org>
+Date: Fri, 19 Mar 2021 16:56:59 -0700
+Subject: [PATCH] rebase_path for write_args
+
+---
+ BUILD.gn | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libchrome/BUILD.gn b/libchrome/BUILD.gn
+index a846d8f52..66ac10a55 100644
+--- a/libchrome/BUILD.gn
++++ b/libchrome/BUILD.gn
+@@ -556,7 +556,7 @@ action("base") {
+
+ script = "//common-mk/write_args.py"
+ outputs = [ "${root_out_dir}/lib/lib${target_name}.so" ]
+- args = [ "--output" ] + outputs + [ "--" ] + [
++ args = [ "--output" ] + rebase_path(outputs) + [ "--" ] + [
+ "GROUP",
+ "(",
+ "AS_NEEDED",
+@@ -618,7 +618,7 @@ action("base-test") {
+
+ script = "//common-mk/write_args.py"
+ outputs = [ "${root_out_dir}/lib${target_name}.a" ]
+- args = [ "--output" ] + outputs + [ "--" ] + [
++ args = [ "--output" ] + rebase_path(outputs) + [ "--" ] + [
+ "GROUP",
+ "(",
+ "AS_NEEDED",
+--
+2.20.1
+
diff --git a/system/build/dpkg/libchrome/debian/patches/series b/system/build/dpkg/libchrome/debian/patches/series
new file mode 100644
index 0000000000..5a26f7be70
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/patches/series
@@ -0,0 +1,3 @@
+0001-common-mk-rebase_path-output-location-of-generate-pc.patch
+0001-Add-missing-includes.patch
+0001-rebase_path-for-write_args.patch
diff --git a/system/build/dpkg/libchrome/debian/rules b/system/build/dpkg/libchrome/debian/rules
new file mode 100755
index 0000000000..6ac17835c4
--- /dev/null
+++ b/system/build/dpkg/libchrome/debian/rules
@@ -0,0 +1,38 @@
+#!/usr/bin/make -f
+
+# gn args
+defines =
+defines += pkg_config=\"pkg-config\"
+defines += libbase_ver=\"780652\"
+defines += platform2_root=\"$(shell pwd)/\"
+defines += platform_subdir=\"libchrome\"
+defines += cxx=\"clang++\"
+defines += cc=\"clang\"
+defines += ar=\"ar\"
+defines += external_cxxflags=[\"-I/usr/src/googletest/googletest/include\", \"-I/usr/src/googletest/googlemock/include\"]
+defines += external_ldflags=[\"-latomic\"]
+defines += enable_werror=false
+defines += libdir=\"/usr/lib\"
+defines += use={mojo=false asan=false coverage=false crypto=true dbus=true fuzzer=false timers=true cros_host=false profiling=false tcmalloc=false}
+
+# handle parallel build options
+njobs=1
+ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+njobs=$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+endif
+
+%:
+ dh $@ --parallel
+
+override_dh_auto_build-arch:
+ gn gen out/Release --args="$(defines)"
+ ninja -j$(njobs) -C out/Release
+
+override_dh_auto_clean:
+ rm -rf out
+ find . -name \*.pyc -execdir rm -f {} \;
+ dh_auto_clean
+
+override_dh_auto_install-arch:
+ dh_auto_install
+ debian/install_headers.sh debian/tmp
diff --git a/system/build/dpkg/libchrome/gen-src-pkg.sh b/system/build/dpkg/libchrome/gen-src-pkg.sh
new file mode 100755
index 0000000000..3cee0e4612
--- /dev/null
+++ b/system/build/dpkg/libchrome/gen-src-pkg.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+# Generates Debian source and binary packages of libchrome.
+
+if [ -z "$1" ]; then
+ echo "Usage: gen-src-pkg.sh <output-dir>"
+ exit 1
+fi
+
+outdir="$1"
+pkgdir=libchrome-780652
+origtar=libchrome_780652.orig.tar.gz
+scriptdir="$( cd "$( dirname "$0" )" && pwd )"
+branch=release-R90-13816.B
+
+tmpdir=$(mktemp -d)
+echo Generating source package in "${tmpdir}".
+
+# Download platform2 source.
+cd "${tmpdir}"
+git clone --branch "${branch}" https://chromium.googlesource.com/chromiumos/platform2 || exit 1
+mkdir "${pkgdir}"
+cd "${pkgdir}"
+# Trim platform2, only common-mk is needed.
+cp -a ../platform2/{common-mk,.gn} .
+
+# Download libchrome source and apply Chrome OS's patches.
+git clone --branch "${branch}" https://chromium.googlesource.com/aosp/platform/external/libchrome || exit 1
+cd libchrome
+rm -rf .git
+while read -r patch; do
+ patch -p1 < "libchrome_tools/patches/${patch}"
+done < <(grep -E '^[^#]' "libchrome_tools/patches/patches")
+
+# Clean up temporary platform2 checkout.
+cd ../..
+rm -rf platform2
+
+# 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}".
diff --git a/system/build/dpkg/modp_b64/debian/README.Debian b/system/build/dpkg/modp_b64/debian/README.Debian
new file mode 100644
index 0000000000..2fb99bde8a
--- /dev/null
+++ b/system/build/dpkg/modp_b64/debian/README.Debian
@@ -0,0 +1 @@
+modp-b64 for Debian
diff --git a/system/build/dpkg/modp_b64/debian/changelog b/system/build/dpkg/modp_b64/debian/changelog
new file mode 100644
index 0000000000..034c8ef7ce
--- /dev/null
+++ b/system/build/dpkg/modp_b64/debian/changelog
@@ -0,0 +1,5 @@
+modp-b64 (0.0.1-1) buster; urgency=low
+
+ * Initial release.
+
+ -- Sonny Sasaka <sonnysasaka@chromium.org> Fri, 19 Mar 2021 19:41:40 +0000
diff --git a/system/build/dpkg/modp_b64/debian/compat b/system/build/dpkg/modp_b64/debian/compat
new file mode 100644
index 0000000000..f599e28b8a
--- /dev/null
+++ b/system/build/dpkg/modp_b64/debian/compat
@@ -0,0 +1 @@
+10
diff --git a/system/build/dpkg/modp_b64/debian/control b/system/build/dpkg/modp_b64/debian/control
new file mode 100644
index 0000000000..a1ef0d98f0
--- /dev/null
+++ b/system/build/dpkg/modp_b64/debian/control
@@ -0,0 +1,18 @@
+Source: modp-b64
+Section: libs
+Priority: optional
+Maintainer: Sonny Sasaka <sonnysasaka@chromium.org>
+Standards-Version: 4.1.4
+Homepage: https://chromium.googlesource.com/aosp/platform/external/modp_b64/
+Build-Depends:
+ debhelper (>=11~),
+ clang,
+ python3,
+ pkg-config,
+ ninja-build,
+
+Package: modp-b64
+Architecture: any
+Multi-Arch: foreign
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Description: modp base64 decoder
diff --git a/system/build/dpkg/modp_b64/debian/modp-b64.install b/system/build/dpkg/modp_b64/debian/modp-b64.install
new file mode 100644
index 0000000000..3bd28024ed
--- /dev/null
+++ b/system/build/dpkg/modp_b64/debian/modp-b64.install
@@ -0,0 +1,3 @@
+modp_b64/modp_b64 /usr/include
+out/Release/libmodp_b64.a /usr/lib
+out/Release/obj/modp_b64/libmodp_b64.pc /usr/lib/pkgconfig
diff --git a/system/build/dpkg/modp_b64/debian/patches/0001-common-mk-rebase_path-output-location-of-generate-pc.patch b/system/build/dpkg/modp_b64/debian/patches/0001-common-mk-rebase_path-output-location-of-generate-pc.patch
new file mode 100644
index 0000000000..418efcc475
--- /dev/null
+++ b/system/build/dpkg/modp_b64/debian/patches/0001-common-mk-rebase_path-output-location-of-generate-pc.patch
@@ -0,0 +1,36 @@
+From 04fa5e1ade08696b5a2cc3b65bf0fd26c43251c7 Mon Sep 17 00:00:00 2001
+From: Sonny Sasaka <sonnysasaka@chromium.org>
+Date: Fri, 19 Mar 2021 11:17:43 -0700
+Subject: [PATCH] common-mk: rebase_path output location of generate-pc.py
+
+Without rebase_path, the generate-pc.py would be called like
+`generate-pc.py --output //out/Release` if the output is inside the
+source directory and this gn path isn't recognized as a generic
+filesystem path.
+
+BUG=b:183216216
+TEST=with modp_b64, call
+$ gn gen out/Release --args=...
+$ ninja
+
+Change-Id: Ic9d9b3d01d52d483e3d81ca2e8d514b47900f5bb
+---
+ common-mk/pkg_config.gni | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/common-mk/pkg_config.gni b/common-mk/pkg_config.gni
+index 24e2cf1401..b2c58845d4 100644
+--- a/common-mk/pkg_config.gni
++++ b/common-mk/pkg_config.gni
+@@ -84,7 +84,7 @@ template("generate_pkg_config") {
+ outputs = [ "${target_out_dir}/${output_name}.pc" ]
+
+ script = "//common-mk/generate-pc.py"
+- args = [ "--output" ] + outputs + [ "--name=" + name ]
++ args = [ "--output" ] + rebase_path(outputs) + [ "--name=" + name ]
+ if (defined(description)) {
+ args += [ "--description=" + description ]
+ }
+--
+2.29.2
+
diff --git a/system/build/dpkg/modp_b64/debian/patches/series b/system/build/dpkg/modp_b64/debian/patches/series
new file mode 100644
index 0000000000..27086fc3b2
--- /dev/null
+++ b/system/build/dpkg/modp_b64/debian/patches/series
@@ -0,0 +1 @@
+0001-common-mk-rebase_path-output-location-of-generate-pc.patch
diff --git a/system/build/dpkg/modp_b64/debian/rules b/system/build/dpkg/modp_b64/debian/rules
new file mode 100755
index 0000000000..1bb93aee12
--- /dev/null
+++ b/system/build/dpkg/modp_b64/debian/rules
@@ -0,0 +1,31 @@
+#!/usr/bin/make -f
+
+# gn args
+defines =
+defines += pkg_config=\"pkg-config\"
+defines += platform2_root=\"$(shell pwd)/\"
+defines += platform_subdir=\"modp_b64\"
+defines += cxx=\"clang++\"
+defines += cc=\"clang\"
+defines += ar=\"ar\"
+defines += enable_werror=false
+defines += libdir=\"/usr/lib\"
+defines += use={mojo=false asan=false coverage=false crypto=true dbus=true fuzzer=false timers=true cros_host=false profiling=false tcmalloc=false}
+
+# handle parallel build options
+njobs=1
+ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+njobs=$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+endif
+
+%:
+ dh $@
+
+override_dh_auto_build-arch:
+ gn gen out/Release --args="$(defines)"
+ ninja -j$(njobs) -C out/Release
+
+override_dh_auto_clean:
+ rm -rf out
+ find . -name \*.pyc -execdir rm -f {} \;
+ dh_auto_clean
diff --git a/system/build/dpkg/modp_b64/gen-src-pkg.sh b/system/build/dpkg/modp_b64/gen-src-pkg.sh
new file mode 100755
index 0000000000..cc22f678f2
--- /dev/null
+++ b/system/build/dpkg/modp_b64/gen-src-pkg.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+# Generates Debian source and binary packages of modp_b64.
+
+if [ -z "$1" ]; then
+ echo "Usage: gen-src-pkg.sh <output-dir>"
+ exit 1
+fi
+
+outdir="$1"
+pkgdir=modp-b64-0.0.1
+origtar=modp-b64_0.0.1.orig.tar.gz
+scriptdir="$( cd "$( dirname "$0" )" && pwd )"
+branch=release-R90-13816.B
+
+tmpdir=$(mktemp -d)
+echo Generating source package in "${tmpdir}".
+
+# Download platform2 source.
+cd "${tmpdir}"
+git clone --branch "${branch}" https://chromium.googlesource.com/chromiumos/platform2 || exit 1
+mkdir "${pkgdir}"
+cd "${pkgdir}"
+# Trim platform2, only common-mk is needed.
+cp -a ../platform2/{common-mk,.gn} .
+
+# Download modp_b64 source.
+git clone --branch "${branch}" https://chromium.googlesource.com/aosp/platform/external/modp_b64 || exit 1
+cd modp_b64
+rm -rf .git
+
+# Clean up temporary platform2 checkout.
+cd ../..
+rm -rf platform2
+
+# 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}".
diff --git a/system/build/install_deps.sh b/system/build/install_deps.sh
index 2f994e1c23..4826b385f1 100755
--- a/system/build/install_deps.sh
+++ b/system/build/install_deps.sh
@@ -47,11 +47,12 @@ if [ ! -z "$CLANG_PACKAGE" ]; then
fi
sudo apt-get -y install $CLANG_PACKAGE libevent-dev libc++-dev libc++abi-dev \
- ninja-build
- gn_path=`which gn`
- if [ -z $gn_path ]; then
- gnsha1=$(curl $GNSHA1_URL | base64 -d)
- wget -O gn http://storage.googleapis.com/chromium-gn/$gnsha1
- chmod a+x ./gn
- sudo mv ./gn /usr/bin/
- fi
+ ninja-build libflatbuffers-dev libtinyxml2-dev
+
+gn_path=`which gn`
+if [ -z $gn_path ]; then
+ gnsha1=$(curl $GNSHA1_URL | base64 -d)
+ wget -O gn http://storage.googleapis.com/chromium-gn/$gnsha1
+ chmod a+x ./gn
+ sudo mv ./gn /usr/bin/
+fi