From 8e333b3f49d8dbada3cd62a337d3d7bcf4a9603c Mon Sep 17 00:00:00 2001 From: Greg Pfeil Date: Thu, 20 Oct 2022 12:19:23 -0600 Subject: [PATCH] updatecheck: support XDG-based token location Have updatecheck look in $XDG_DATA_HOME/zcash/updatecheck/token for the GH token. Having one in the repo will still take precedence (for pre-existing users, as well as if you want to override the token used in a particular case). The new location is standardized, exists at the user level (as the token logically does), and means that you don't need to copy files around if you get a new clone or worktree to do a release. --- doc/release-process.md | 11 +++++------ qa/zcash/updatecheck.py | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/release-process.md b/doc/release-process.md index cd345bc1d..99fe4a1fd 100644 --- a/doc/release-process.md +++ b/doc/release-process.md @@ -28,9 +28,9 @@ Check that dependencies are up-to-date or have been postponed: $ ./qa/zcash/updatecheck.py ``` -You can optionally create an `.updatecheck-token` file in the root of the -repository to avoid running into GitHub rate limiting. Create an unprivileged -personal access token on GitHub and copy the value into the file. +You can optionally create an `$XDG_DATA_HOME/zcash/updatecheck/token` file to +avoid running into GitHub rate limiting. Create an unprivileged personal access +token on GitHub and copy the value into the file. If there are updates that have not been postponed, review their changelogs for urgent security fixes, and if there aren't any, postpone the update by @@ -58,9 +58,8 @@ The release script has the following dependencies: - `help2man` - `debchange` (part of the devscripts Debian package) - -You can optionally install the `progressbar2` Python module with pip to have a -progress bar displayed during the build process. +- the python modules `progressbar2` (optional - displays a progress bar), + `requests` and `xdg` ## Versioning diff --git a/qa/zcash/updatecheck.py b/qa/zcash/updatecheck.py index 7b8d9dbd6..978df88d8 100755 --- a/qa/zcash/updatecheck.py +++ b/qa/zcash/updatecheck.py @@ -35,6 +35,7 @@ import requests import os import re import sys +import xdg import datetime SOURCE_ROOT = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..") @@ -113,6 +114,8 @@ def get_dependency_list(): def parse_token(): token_path = os.path.realpath(os.path.join(SOURCE_ROOT, ".updatecheck-token")) + if not os.path.exists(token_path): + token_path = os.path.join(xdg.xdg_data_home(), "zcash/updatecheck/token") try: with open(token_path, encoding='utf8') as f: token = f.read().strip()