Skip to content
Snippets Groups Projects
Commit 44a69f1b authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

Add scripts to generate Debian packages of Fluoride dependencies

To build Fluoride on Linux, there are dependencies that are not usually
provided by Linux package managers. This patch adds libchrome and
modp_b64 package generators to make building them easier on Debian-based
distros.

Bug: 179821440
Tag: #floss
Test: None
Change-Id: I93c6583d58635c65dbfbeea2ff556f09585225d5
parent a244f820
No related branches found
No related tags found
No related merge requests found
Showing
with 399 additions and 4 deletions
......@@ -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
......
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.
libchrome for Debian
libchrome (780652-1) buster; urgency=low
* Initial release.
-- Sonny Sasaka <sonnysasaka@chromium.org> Fri, 19 Mar 2021 19:41:40 +0000
10
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
#!/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
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
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
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
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
0001-common-mk-rebase_path-output-location-of-generate-pc.patch
0001-Add-missing-includes.patch
0001-rebase_path-for-write_args.patch
#!/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
#!/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}".
modp-b64 for Debian
modp-b64 (0.0.1-1) buster; urgency=low
* Initial release.
-- Sonny Sasaka <sonnysasaka@chromium.org> Fri, 19 Mar 2021 19:41:40 +0000
10
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
modp_b64/modp_b64 /usr/include
out/Release/libmodp_b64.a /usr/lib
out/Release/obj/modp_b64/libmodp_b64.pc /usr/lib/pkgconfig
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment