1#!/bin/bash 2# Generates Debian source and binary packages of libchrome. 3 4if [ -z "$1" ]; then 5 echo "Usage: gen-src-pkg.sh <output-dir>" 6 exit 1 7fi 8 9outdir="$1" 10pkgdir=libchrome-1094370 11origtar=libchrome_1094370.orig.tar.gz 12scriptdir="$( cd "$( dirname "$0" )" && pwd )" 13 14# Pin the libchrome branch + commit 15libchrome_branch=main 16libchrome_commit=0519670b5b553bdb42e22d05448358a312c5e78e 17 18# Pin the platform2 branch + commit 19platform2_branch=main 20platform2_commit=a50a38e57053510332e3fe2ba116c0a7952ad511 21 22tmpdir=$(mktemp -d) 23echo Generating source package in "${tmpdir}". 24 25# Download platform2 source. 26cd "${tmpdir}" 27git clone --branch "${platform2_branch}" https://chromium.googlesource.com/chromiumos/platform2 || exit 1 28(cd platform2 && git checkout "${platform2_commit}") 29mkdir "${pkgdir}" 30cd "${pkgdir}" 31# Trim platform2, only common-mk is needed. 32cp -a ../platform2/{common-mk,.gn} . 33 34# Download libchrome source and apply Chrome OS's patches. 35git clone --branch "${libchrome_branch}" https://chromium.googlesource.com/chromiumos/platform/libchrome || exit 1 36cd libchrome 37git checkout "${libchrome_commit}" 38rm -rf .git 39 40# Apply all patches (even conditional ones). 41# If this is problematic on a future revision, we may need to parse 42# "libchrome_tools/patches/patches.config" and exclude ones found 43# there. 44for patch in $(ls "libchrome_tools/patches/" | grep .patch); do 45 patch -p1 < "libchrome_tools/patches/${patch}" 46done 47 48# Clean up temporary platform2 checkout. 49cd ../.. 50rm -rf platform2 51 52# Debian requires creating .orig.tar.gz. 53tar czf "${origtar}" "${pkgdir}" 54 55# Debianize the source. 56cd "${pkgdir}" 57yes | debmake || exit 1 58cp -aT "${scriptdir}/debian/" "${tmpdir}/${pkgdir}/debian/" 59 60# If building for docker, use the right install script. 61if [ ! -z "${LIBCHROME_DOCKER}" ]; then 62 mv "${tmpdir}/${pkgdir}/debian/libchrome.install.docker" \ 63 "${tmpdir}/${pkgdir}/debian/libchrome.install" 64else 65 rm -f "${tmpdir}/${pkgdir}/debian/libchrome.install.docker" 66fi 67 68# Build source package and binary package. 69cd "${tmpdir}/${pkgdir}" 70dpkg-buildpackage --no-sign || exit 1 71 72# Copy the results to output dir. 73cd "${tmpdir}" 74mkdir -p "${outdir}/src" 75cp *.dsc *.orig.tar.gz *.debian.tar.xz "${outdir}/src" 76cp *.deb "${outdir}" 77cd / 78 79echo Removing temporary directory "${tmpdir}". 80rm -rf "${tmpdir}" 81 82echo Done. Check out Debian source package in "${outdir}". 83