diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-09-20 13:41:49 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-10-01 11:27:20 +0000 |
commit | e1e2b00c990c73253606a9e2cb5e290724b6fa16 (patch) | |
tree | 891ea653051f24a8dc564ee8d735008cbdc7d0f5 /util | |
parent | 05029ec45d0952e484b772553223a8bab1eafa70 (diff) |
Add a script for updating from publicsuffix/list.git
Upstream changes every few days, so make this as easy as possible.
Older branches have a different way to update the list. The idea of
this script is to paper over the these differences.
Pick-to: 6.5 6.2 5.15
Task-number: QTBUG-117138
Task-number: QTBUG-116236
Change-Id: Ib7c6187e4b9c09de715a014d22af9c20d4783086
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit fd89295562919358eeaa514114366fc9d9d27960)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'util')
-rwxr-xr-x | util/update_public_suffix_list.sh | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/util/update_public_suffix_list.sh b/util/update_public_suffix_list.sh new file mode 100755 index 0000000000..53c76938be --- /dev/null +++ b/util/update_public_suffix_list.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +PICK_TO_BRANCHES="6.6 6.5 6.2 5.15" +#UPSTREAM=github.com:publicsuffix/list.git # use this if you have a github account +UPSTREAM=https://github.com/publicsuffix/list.git # and this if you don't + +THIS="util/update_public_suffix_list.sh" +PUBLIC_SUFFIX_LIST_DAT_DIR="$1" +MAKE_DAFSA=src/3rdparty/libpsl/src/psl-make-dafsa +PSL_DATA_CPP=src/3rdparty/libpsl/psl_data.cpp +PUBLIC_SUFFIX_LIST_DAFSA=tests/auto/network/access/qnetworkcookiejar/testdata/publicsuffix/public_suffix_list.dafsa +ATTRIBUTION_JSON=src/3rdparty/libpsl/qt_attribution.json + +function msg() { + echo "$@" 1>&2 +} + +function die() { + msg "$@" + exit 1 +} + +function check_or_die() { + TYPE=$1 + OP=$2 + FILE="$3" + test $OP "$FILE" || die "$TYPE \"$FILE\" not found (test $OP \"$FILE\" failed). Please run $THIS from \$SRCDIR/qtbase and pass the directory containing a checkout of $UPSTEAM on the command line." +} + +function run_or_die() { + msg -n "Running \"$@\"..." + "$@" || die "Failed" + msg "Done" +} + +INPUT="$PUBLIC_SUFFIX_LIST_DAT_DIR/public_suffix_list.dat" + +check_or_die tool -x "$MAKE_DAFSA" +if [ ! -d "$PUBLIC_SUFFIX_LIST_DAT_DIR" ]; then + msg -n "$PUBLIC_SUFFIX_LIST_DAT_DIR does not exist; Clone $UPSTREAM there? [y/N]" + read -N1 -t60 + msg + if [ "x$REPLY" = "xy" -o "x$REPLY" = "xY" ]; then + run_or_die git clone "$UPSTREAM" "$PUBLIC_SUFFIX_LIST_DAT_DIR" + else + check_or_die publicsuffix/list.git -d "$PUBLIC_SUFFIX_LIST_DAT_DIR" # reuse error message + fi +fi +check_or_die publicsuffix/list.git -d "$PUBLIC_SUFFIX_LIST_DAT_DIR" +check_or_die input -r "$INPUT" +check_or_die output -w "$PSL_DATA_CPP" +check_or_die binary-output -w "$PUBLIC_SUFFIX_LIST_DAFSA" + +GITSHA1=$(cd "$PUBLIC_SUFFIX_LIST_DAT_DIR" && git log -1 --format=format:%H) +TODAY=$(date +%Y-%m-%d) +msg "Using $INPUT @ $GITSHA1, fetched on $TODAY" + +run_or_die "$MAKE_DAFSA" "$INPUT" "$PSL_DATA_CPP" +run_or_die "$MAKE_DAFSA" --output-format=binary "$INPUT" "$PUBLIC_SUFFIX_LIST_DAFSA" + +# update the first Version line in qt_attribution.json with the new SHA1 and date: +run_or_die sed -i -e "1,/\"Version\":/{ /\"Version\":/ { s/[0-9a-fA-F]\{40\}/$GITSHA1/; s/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/$TODAY/ } }" "$ATTRIBUTION_JSON" + +run_or_die git add "$PSL_DATA_CPP" +run_or_die git add "$PUBLIC_SUFFIX_LIST_DAFSA" +run_or_die git add "$ATTRIBUTION_JSON" + +run_or_die git commit -m "Update public suffix list + +Version $GITSHA1, fetched on +$TODAY. + +Pick-to: $PICK_TO_BRANCHES +" --edit |