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-780652 11origtar=libchrome_780652.orig.tar.gz 12scriptdir="$( cd "$( dirname "$0" )" && pwd )" 13branch=release-R90-13816.B 14 15tmpdir=$(mktemp -d) 16echo Generating source package in "${tmpdir}". 17 18# Download platform2 source. 19cd "${tmpdir}" 20git clone --branch "${branch}" https://chromium.googlesource.com/chromiumos/platform2 || exit 1 21mkdir "${pkgdir}" 22cd "${pkgdir}" 23# Trim platform2, only common-mk is needed. 24cp -a ../platform2/{common-mk,.gn} . 25 26# Download libchrome source and apply Chrome OS's patches. 27git clone --branch "${branch}" https://chromium.googlesource.com/aosp/platform/external/libchrome || exit 1 28cd libchrome 29rm -rf .git 30while read -r patch; do 31 patch -p1 < "libchrome_tools/patches/${patch}" 32done < <(grep -E '^[^#]' "libchrome_tools/patches/patches") 33 34# Clean up temporary platform2 checkout. 35cd ../.. 36rm -rf platform2 37 38# Debian requires creating .orig.tar.gz. 39tar czf "${origtar}" "${pkgdir}" 40 41# Debianize the source. 42cd "${pkgdir}" 43yes | debmake || exit 1 44cp -aT "${scriptdir}/debian/" "${tmpdir}/${pkgdir}/debian/" 45 46# Build source package and binary package. 47cd "${tmpdir}/${pkgdir}" 48dpkg-buildpackage --no-sign || exit 1 49 50# Copy the results to output dir. 51cd "${tmpdir}" 52mkdir -p "${outdir}/src" 53cp *.dsc *.orig.tar.gz *.debian.tar.xz "${outdir}/src" 54cp *.deb "${outdir}" 55cd / 56 57echo Removing temporary directory "${tmpdir}". 58rm -rf "${tmpdir}" 59 60echo Done. Check out Debian source package in "${outdir}". 61