From dae03f367f5adb6339e17b98857547e50ce47fbc Mon Sep 17 00:00:00 2001 From: Eloston Date: Tue, 15 Dec 2015 23:19:08 -0800 Subject: [PATCH] Update to 47.0.2526.106 Create scripts for downloading source code and building Debian packages Updated README.md with new building instructions Update patch offsets --- README.md | 9 +- build_debian.sh | 225 ++++++++++++++++++ build_templates/debian/changelog | 2 +- build_templates/debian/rules | 5 - domain_patcher.sh | 2 + download_source.sh | 117 +++++++++ generate_debian.sh | 20 -- generate_debian_scripts.sh | 32 +++ patches/debian/fullscreen-ui.patch | 2 +- .../ungoogled-chromium/popups-to-tabs.patch | 2 +- source_cleaner.sh | 2 + 11 files changed, 384 insertions(+), 34 deletions(-) create mode 100755 build_debian.sh create mode 100755 download_source.sh delete mode 100755 generate_debian.sh create mode 100755 generate_debian_scripts.sh diff --git a/README.md b/README.md index 9a757dff..c666b843 100644 --- a/README.md +++ b/README.md @@ -52,15 +52,12 @@ Right now, only Debian build scripts are provided. git clone https://github.com/Eloston/ungoogled-chromium.git cd ungoogled-chromium # Run dpkg-checkbuilddeps to find packages needed for building - ./generate_debian.sh - cd build-sandbox - ./debian/rules download-source - ../source_cleaner.sh - ../domain_patcher.sh - dpkg-buildpackage -b -uc + ./build_debian.sh -A Debian packages will appear under `ungoogled-chromium/` +For more options, run `./build_debian.sh -h` to see the available options. This applies to `download_source.sh` as well. + ## Contributing Contributers are welcome! diff --git a/build_debian.sh b/build_debian.sh new file mode 100755 index 00000000..592b5925 --- /dev/null +++ b/build_debian.sh @@ -0,0 +1,225 @@ +#!/bin/bash + +# Script to build Debian packages + +SCRIPT_DIR=$(dirname $(readlink -f $0)); +CWD=$(pwd); + +SANDBOX_PATH="$SCRIPT_DIR/build-sandbox"; +DOWNLOAD_EXTRACT_TARBALL=; +CUSTOM_TARBALL=; +KEEP_TARBALL=; +RUN_SOURCE_CLEANER=; +RUN_DOMAIN_PATCHER=; +GENERATE_BUILD_SCRIPTS=; +RUN_BUILD_COMMAND=; + +print_usage() { + echo "Usage: $0 [-h] {-A | [-d | -x tarball] [-k] [-c] [-p] [-g] [-b]}"; + echo "Options:"; + echo " -h: Show this help message"; + echo " -s: (Default: $SANDBOX_PATH) Path to to the building sandbox"; + echo " -A: Same as -d -c -p -g -b"; + echo " -d: Download the source tarball and extract it into the building sandbox. Cannot be used with -x"; + echo " -x: Extract the provided tarball into the building sandbox. Cannot be used with -d"; + echo " -k: Keep the tarball after source extraction. Otherwise it will be deleted. Requires -d or -x to be present"; + echo " -c: Run source_cleaner.sh on the source code"; + echo " -p: Run domain_patcher.sh on the source code"; + echo " -g: Generate Debian build scripts and place them into the building sandbox, if they do not already exist"; + echo " -b: Run dpkg-buildpackage"; +} + +is_not_set() { + if [[ -n "$1" ]]; then + eval "local to_check=\$$1;" + if [[ -n "$to_check" ]]; then + MESSAGE="Variable $1 is already set"; + if [[ -n "$2" ]]; then + MESSAGE=$2; + fi + echo $MESSAGE >&2; + exit 1; + fi + else + echo "is_not_set() did not get an argument" >&2; + exit 1; + fi +} + +set_if_empty() { + if [[ -n "$1" ]] && [[ -n "$2" ]]; then + eval "local to_check=\$$1;" + if [[ -z "$to_check" ]]; then + eval "$1=$2"; + fi + else + echo "set_if_empty() did not get two arguments" >&2; + exit 1; + fi +} + +set_or_fail() { + if [[ -n "$1" ]] && [[ -n "$2" ]] && [[ -n "$3" ]]; then + is_not_set $1 "$3"; + set_if_empty $1 "$2"; + else + echo "set_or_fail() did not get three arguments" >&2; + exit 1; + fi +} + +check_exit_status() { + local exit_code=$?; + local exit_message="(No message)"; + if [[ -n $1 ]]; then + exit_message=$1; + fi + if [[ $exit_code -ne 0 ]]; then + echo "Exit status $exit_code: $exit_message"; + cd "$CWD"; + exit 1; + fi +} + +while getopts ":hs:Adx:kcpgb" opt; do + case $opt in + h) + print_usage; + exit 0; + ;; + s) + SANDBOX_PATH=$OPTARG; + ;; + A) + A_conflict="Argument -A cannot be used with any other argument except -s"; + set_or_fail "DOWNLOAD_EXTRACT_TARBALL" 1 "$A_conflict"; + set_or_fail "KEEP_TARBALL" 0 "$A_conflict"; + set_or_fail "RUN_SOURCE_CLEANER" 1 "$A_conflict"; + set_or_fail "RUN_DOMAIN_PATCHER" 1 "$A_conflict"; + set_or_fail "GENERATE_BUILD_SCRIPTS" 1 "$A_conflict"; + set_or_fail "RUN_BUILD_COMMAND" 1 "$A_conflict"; + unset A_conflict; + ;; + d) + is_not_set "CUSTOM_TARBALL" "Argument -d cannot be used with -x"; + DOWNLOAD_EXTRACT_TARBALL=1; + ;; + x) + is_not_set "DOWNLOAD_EXTRACT_TARBALL" "Argument -x cannot be used with -d"; + CUSTOM_TARBALL=$OPTARG; + ;; + k) + KEEP_TARBALL=1; + ;; + c) + RUN_SOURCE_CLEANER=1; + ;; + p) + RUN_DOMAIN_PATCHER=1; + ;; + g) + GENERATE_BUILD_SCRIPTS=1; + ;; + b) + RUN_BUILD_COMMAND=1; + ;; + \?) + echo "Invalid option: -$OPTARG" >&2; + print_usage; + exit 1; + ;; + :) + echo "Option -$OPTARG requires an argument." >&2; + print_usage; + exit 1; + ;; + esac +done + +set_if_empty "DOWNLOAD_EXTRACT_TARBALL" 0 +set_if_empty "KEEP_TARBALL" 0 +set_if_empty "RUN_SOURCE_CLEANER" 0 +set_if_empty "RUN_DOMAIN_PATCHER" 0 +set_if_empty "GENERATE_BUILD_SCRIPTS" 0 +set_if_empty "RUN_BUILD_COMMAND" 0 + +if [[ $DOWNLOAD_EXTRACT_TARBALL -eq 1 ]]; then + if [[ -e $SANDBOX_PATH ]]; then + echo "Build sandbox path $SANDBOX_PATH already exists" >&2; + exit 1; + else + mkdir $SANDBOX_PATH; + fi + echo "Downloading and extracting tarball..."; + if [[ $KEEP_TARBALL -eq 1 ]]; then + $SCRIPT_DIR/download_source.sh -x "$SANDBOX_PATH" + check_exit_status "Source downloading failed"; + else + $SCRIPT_DIR/download_source.sh -x "$SANDBOX_PATH" -R + check_exit_status "Source downloading failed"; + fi +fi + +if [[ -n "$CUSTOM_TARBALL" ]]; then + if [[ -e $SANDBOX_PATH ]]; then + echo "Build sandbox path $SANDBOX_PATH already exists" >&2; + exit 1; + else + mkdir $SANDBOX_PATH; + fi + if [[ -f "$CUSTOM_TARBALL" ]]; then + CUSTOM_TARBALL=$(readlink -f "$CUSTOM_TARBALL"); + else + echo "Custom tarball $CUSTOM_TARBALL is not a file"; + exit 1; + fi + echo "Unpacking tarball $CUSTOM_TARBALL ..."; + cd "$SANDBOX_PATH"; + tar -xf "$CUSTOM_TARBALL" --strip-components=1; + check_exit_status "Tarball extraction failed"; + cd "$CWD"; + if [[ $KEEP_TARBALL -eq 0 ]]; then + rm $CUSTOM_TARBALL; + check_exit_status "Could not remove custom tarball"; + fi +fi + +if [[ ! -d $SANDBOX_PATH ]]; then + echo "$SANDBOX_PATH is not a directory" >&2; + exit 1; +fi + +cd "$SANDBOX_PATH"; + +if [[ $RUN_SOURCE_CLEANER -eq 1 ]]; then + echo "Running source cleaner..."; + $SCRIPT_DIR/source_cleaner.sh + check_exit_status "Source cleaning encountered an error"; +fi + +if [[ $RUN_DOMAIN_PATCHER -eq 1 ]]; then + echo "Running domain patcher..."; + $SCRIPT_DIR/domain_patcher.sh + check_exit_status "Domain patching encountered an error"; +fi; + +if [[ $GENERATE_BUILD_SCRIPTS -eq 1 ]]; then + if [[ -e "$SANDBOX_PATH/debian" ]]; then + echo "Debian build scripts already exist. Skipping..."; + else + echo "Generating Debian build scripts..."; + $SCRIPT_DIR/generate_debian_scripts.sh $SANDBOX_PATH; + check_exit_status "Could not generate Debian build scripts"; + fi +fi + +if [[ $RUN_BUILD_COMMAND -eq 1 ]]; then + echo "Running build command..."; + dpkg-buildpackage -b -uc + check_exit_status "Build command encountered an error"; +fi + +cd "$CWD"; + +echo "Done"; + diff --git a/build_templates/debian/changelog b/build_templates/debian/changelog index ffcbaf93..4c95a12e 100644 --- a/build_templates/debian/changelog +++ b/build_templates/debian/changelog @@ -1,4 +1,4 @@ -chromium-browser (47.0.2526.80-2) stretch; urgency=low +chromium-browser (47.0.2526.106-1) stretch; urgency=low * New upstream version - Based off of Debian's 47.0.2526.80-2 diff --git a/build_templates/debian/rules b/build_templates/debian/rules index 283f50cf..168a421b 100755 --- a/build_templates/debian/rules +++ b/build_templates/debian/rules @@ -182,8 +182,3 @@ get-orig-source: tar tf ../$(tarball) | sort > ../chromium.upstream tar tf ../chromium-browser_$(version).orig.tar.xz | sort > ../chromium.orig diff -u ../chromium.upstream ../chromium.orig >> ../$(removed) || true - -download-source: - #@-wget -c $(url)/$(tarball) || ([ $$? -eq 8 ] && wget -c $(url_backup)/$(version)/$(tarball)) - wget -c $(url)/$(tarball) - tar -xf $(tarball) --strip-components=1 diff --git a/domain_patcher.sh b/domain_patcher.sh index 2addf313..fd700be6 100755 --- a/domain_patcher.sh +++ b/domain_patcher.sh @@ -1 +1,3 @@ find . -path ./debian -prune -o -type f \( -name "*.h" -o -name "*.hh" -o -name "*.hpp" -o -name "*.hxx" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" -o -name "*.c" -o -name "*.h" -o -name "*.json" -o -name "*.js" -o -name "*.html" -o -name "*.htm" -o -name "*.py*" -o -name "*.grd" -o -name "*.sql" -o -name "*.idl" -o -name "*.mk" -o -name "*.gyp*" -o -name "Makefile" -o -name "makefile" -o -name "*.txt" -o -name "*.xml" -o -name "*.mm" \) -print | xargs -L1 -I{} sed -i -r -e 's/google([A-Za-z\-]*)\.com/9oo91e\1\.qjz9zk/g' -e 's/gstatic([A-Za-z\-]*)\.com/95tat1c\1\.qjz9zk/g' -e 's/chrome([A-Za-z\-]*)\.com/ch40me\1\.qjz9zk/g' -e 's/chromium([A-Za-z\-]*)\.org/ch40m1um\1\.qjz9zk/g' -e 's/mozilla([A-Za-z\-]*)\.org/m0z111a\1\.qjz9zk/g' -e 's/facebook([A-Za-z\-]*)\.com/f8c3b00k\1\.qjz9zk/g' -e 's/appspot([A-Za-z\-]*)\.com/8pp2p8t\1\.qjz9zk/g' -e 's/youtube([A-Za-z\-]*)\.com/y0u1ub3\1\.qjz9zk/g' -e 's/ytimg([A-Za-z\-]*)\.com/yt1mg\1\.qjz9zk/g' -e 's/gmail([A-Za-z\-]*)\.com/9ma1l\1\.qjz9zk/g' -e 's/doubleclick([A-Za-z\-]*)\.net/60u613cl1c4\1\.qjz9zk/g' {} + +exit 0; diff --git a/download_source.sh b/download_source.sh new file mode 100755 index 00000000..73181c48 --- /dev/null +++ b/download_source.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +# A script that downloads the source tarball + +CURRENT_DIR=$(dirname $(readlink -f $0)); + +DOWNLOAD_VERSION=; +DEBIAN_CHANGELOG=; +TARBALL_DESTINATION=$CURRENT_DIR; +EXTRACT_DESTINATION=; +REMOVE_AFTER_EXTRACTION=0; + +print_usage() { + echo "Usage: $0 [-h] [-v version | -c debian_changelog] [-d tarball_directory] [-x extract_directory | -x extract_directory -R]"; + echo "Options:"; + echo " -h: Show this help message"; + echo " -v: (No default) Path to a Debian changelog file"; + echo " -c: (Default: $CURRENT_DIR/build_templates/debian/changelog) Path to a Debian changelog file"; + echo " -d: (Default: $CURRENT_DIR) Directory to store the sourcecode tarball"; + echo " -x: (Not enabled by default) Directory to extract the source tarball"; + echo " -R: Remove the tarball after source extraction. Requires -x to be present"; +} + +while getopts ":v:c:d:x:Rh" opt; do + case $opt in + v) + DOWNLOAD_VERSION=$OPTARG; + ;; + c) + DEBIAN_CHANGELOG=$OPTARG; + ;; + d) + TARBALL_DESTINATION=$OPTARG; + ;; + x) + EXTRACT_DESTINATION=$OPTARG; + ;; + R) + REMOVE_AFTER_EXTRACTION=1; + ;; + h) + print_usage; + exit 0; + ;; + \?) + echo "Invalid option: -$OPTARG" >&2; + print_usage; + exit 1; + ;; + :) + echo "Option -$OPTARG requires an argument." >&2; + print_usage; + exit 1; + ;; + esac +done + +if [[ -n "$DOWNLOAD_VERSION" ]] && [[ -n "$DEBIAN_CHANGELOG" ]]; then + echo "Arguments -v and -c cannot be used together" >&2; + exit 1; +elif [[ -z "$EXTRACT_DESTINATION" ]] && [[ "$REMOVE_AFTER_EXTRACTION" == "1" ]]; then + echo "Argument -R requires -x to be present" >&2; + exit 1; +fi + +if [[ -z "$DOWNLOAD_VERSION" ]] && [[ -z "$DEBIAN_CHANGELOG" ]]; then + DEBIAN_CHANGELOG="$CURRENT_DIR/build_templates/debian/changelog"; +fi + +if [[ -n "$DEBIAN_CHANGELOG" ]]; then + if [[ ! -f "$DEBIAN_CHANGELOG" ]]; then + echo "Debian changelog at $DEBIAN_CHANGELOG is not a regular file" >&2; + exit 1; + fi + echo "Reading version from $DEBIAN_CHANGELOG"; + DOWNLOAD_VERSION=$(dpkg-parsechangelog -l $DEBIAN_CHANGELOG -S Version | sed s/-.*//); + if [[ -z "$DOWNLOAD_VERSION" ]]; then + echo "Could not read the Debian changelog!" >&2; + exit 1; + fi +fi + +if [[ ! -d "$TARBALL_DESTINATION" ]]; then + echo "Tarball destination $TARBALL_DESTINATION is not a directory" >&2; + exit 1; +fi + +TARBALL="chromium-$DOWNLOAD_VERSION.tar.xz"; +URL="https://gsdview.appspot.com/chromium-browser-official/$TARBALL"; + +echo "Downloading version $DOWNLOAD_VERSION to $TARBALL_DESTINATION ..."; + +wget -c -P $TARBALL_DESTINATION $URL; +if [[ $? -ne 0 ]]; then + echo "Dowloading of source tarball failed!" >&2; + exit 1; +fi + +if [[ -n "$EXTRACT_DESTINATION" ]]; then + echo "Extracting $TARBALL to $EXTRACTION_DESTINATION ..."; + if [[ ! -d "$EXTRACT_DESTINATION" ]]; then + echo "Extraction destination $EXTRACT_DESTINATION is not a directory" >&2; + exit 1; + fi + CWD=$(pwd); + cd "$EXTRACTION_DESTINATION"; + tar -xf "$TARBALL_DESTINATION/$TARBALL" --strip-components=1; + cd "$CWD"; + if [[ "$REMOVE_AFTER_EXTRACTION" == "1" ]]; then + echo "Removing $TARBALL ..."; + rm $TARBALL + if [[ $? -ne 0 ]]; then + echo "Could not remove source tarball" >&2; + exit 1; + fi + fi +fi diff --git a/generate_debian.sh b/generate_debian.sh deleted file mode 100755 index 7d484c7c..00000000 --- a/generate_debian.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -SCRIPT_DIR=$(dirname $(readlink -f $0)) -BUILD_SANDBOX_PATH=$SCRIPT_DIR/build-sandbox -OLD_DIR=$(pwd) - -mkdir $BUILD_SANDBOX_PATH - -cd $BUILD_SANDBOX_PATH - -rm -r debian -cp -ri $SCRIPT_DIR/build_templates/debian ./ -cp -ri $SCRIPT_DIR/patches/. ./debian/patches -cat ./debian/patches/series >> ./debian/patches/patch_order -rm ./debian/patches/series -mv ./debian/patches/patch_order ./debian/patches/series - -cd $OLD_DIR - -echo "Done. Debian build scripts in $BUILD_SANDBOX_PATH" diff --git a/generate_debian_scripts.sh b/generate_debian_scripts.sh new file mode 100755 index 00000000..1865f630 --- /dev/null +++ b/generate_debian_scripts.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Script to generate Debian build scripts + +if [[ -z "$1" ]]; then + echo "Usage: $0 sandbox_directory" >&2; + exit 1; +fi + +SCRIPT_DIR=$(dirname $(readlink -f $0)); +BUILD_SANDBOX=$1; + +if [[ ! -d "$BUILD_SANDBOX" ]]; then + echo "Path $BUILD_SANDBOX is not a directory" >&2; + exit 1; +fi + +CWD=$(pwd); +cd "$BUILD_SANDBOX"; + +if [[ -e "debian" ]]; then + echo "Path $BUILD_SANDBOX/debian already exists" >&2; + cd "$CWD"; + exit 1; +fi +cp -ri $SCRIPT_DIR/build_templates/debian ./ +cp -ri $SCRIPT_DIR/patches/. ./debian/patches +cat ./debian/patches/series >> ./debian/patches/patch_order +rm ./debian/patches/series +mv ./debian/patches/patch_order ./debian/patches/series + +cd "$CWD"; diff --git a/patches/debian/fullscreen-ui.patch b/patches/debian/fullscreen-ui.patch index 98fa3634..3e2c8249 100644 --- a/patches/debian/fullscreen-ui.patch +++ b/patches/debian/fullscreen-ui.patch @@ -1,6 +1,6 @@ --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc -@@ -1009,6 +1009,8 @@ void BrowserView::UpdateExclusiveAccessE +@@ -1004,6 +1004,8 @@ void BrowserView::UpdateExclusiveAccessE } bool BrowserView::ShouldHideUIForFullscreen() const { diff --git a/patches/ungoogled-chromium/popups-to-tabs.patch b/patches/ungoogled-chromium/popups-to-tabs.patch index c7de98e6..ca55ea3d 100644 --- a/patches/ungoogled-chromium/popups-to-tabs.patch +++ b/patches/ungoogled-chromium/popups-to-tabs.patch @@ -13,7 +13,7 @@ description: Make popups go to tabs instead return IGNORE_ACTION; --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc -@@ -1541,7 +1541,7 @@ void BrowserView::Paste() { +@@ -1538,7 +1538,7 @@ void BrowserView::Paste() { WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( const gfx::Rect& bounds) { diff --git a/source_cleaner.sh b/source_cleaner.sh index db8d46ae..1a35a22e 100755 --- a/source_cleaner.sh +++ b/source_cleaner.sh @@ -5,3 +5,5 @@ find . -path ./debian -prune -o -path ./third_party/icu/source -prune -o -path . # Remove existing out/ directory rm -r ./out + +exit 0;