win: get GPODDER_HOME from registry
This commit is contained in:
parent
5a0a1c04b6
commit
fbc268be74
|
@ -176,16 +176,26 @@ def fixup_home(old_home):
|
|||
'Application Support', 'gPodder'))
|
||||
elif BUILD_TYPE == 'windows-portable':
|
||||
new_home = os.path.normpath(os.path.join(os.path.dirname(sys.executable), "..", "..", "config"))
|
||||
else: # ui.win32, not portable buildq
|
||||
# XXX: use registy key like in old launcher?
|
||||
# HKEY_CURRENT_USER\\Software\\gpodder.org\\gPodder"
|
||||
# https://github.com/gpodder/gpodder/blob/old/gtk2/tools/win32-launcher/folderselector.c
|
||||
old_home = new_home # force to config directory
|
||||
print("D: windows-portable build; forcing home to config directory %s" % new_home)
|
||||
else: # ui.win32, not portable build
|
||||
from gpodder.utilwin32ctypes import get_documents_folder, get_reg_current_user_string_value
|
||||
try:
|
||||
from gpodder.utilwin32ctypes import get_documents_folder
|
||||
new_home = os.path.join(get_documents_folder(), "gPodder")
|
||||
# from old launcher, see
|
||||
# https://github.com/gpodder/gpodder/blob/old/gtk2/tools/win32-launcher/folderselector.c
|
||||
new_home = get_reg_current_user_string_value("Software\\gpodder.org\\gPodder", "GPODDER_HOME")
|
||||
print("D: windows build; registry home = %s" % new_home)
|
||||
except Exception as e:
|
||||
print("E: can't get user's Documents folder: %s" % e)
|
||||
new_home = old_home
|
||||
print("E: can't get GPODDER_HOME from registry: %s" % e)
|
||||
new_home = None
|
||||
if new_home is None:
|
||||
try:
|
||||
new_home = os.path.join(get_documents_folder(), "gPodder")
|
||||
print("D: windows build; documents home = %s" % new_home)
|
||||
except Exception as e:
|
||||
print("E: can't get user's Documents folder: %s" % e)
|
||||
new_home = old_home
|
||||
|
||||
# Users who do not have the old home directory, or who have it but also
|
||||
# have the new home directory (to cater to situations where the user
|
||||
# might for some reason or the other have a ~/gPodder/ directory) get
|
||||
|
|
|
@ -141,3 +141,19 @@ def get_documents_folder():
|
|||
KNOWN_FOLDER_FLAG.KF_FLAG_CREATE | \
|
||||
KNOWN_FOLDER_FLAG.KF_FLAG_DONT_VERIFY
|
||||
return SHGetKnownFolderPath(KNOWNFOLDERID.FOLDERID_Documents, flags)
|
||||
|
||||
|
||||
def get_reg_current_user_string_value(subkey, value_name):
|
||||
import winreg
|
||||
try:
|
||||
my_key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, subkey)
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
try:
|
||||
value, type_ = winreg.QueryValueEx(my_key, value_name)
|
||||
if type_ == winreg.REG_SZ:
|
||||
return value
|
||||
else:
|
||||
raise WindowsError("Unexpected type for value %s in registry: %i" % (valueName, type_))
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
|
|
@ -122,10 +122,6 @@ function install_gpodder {
|
|||
|
||||
(cd "${REPO_CLONE}" && PYTHON="${BUILD_ROOT}"/"${MINGW}"/bin/python3.exe mingw32-make install-win)
|
||||
|
||||
# Create launchers
|
||||
python3 "${MISC}"/create-launcher.py \
|
||||
"${GPO_VERSION}" "${MINGW_ROOT}"/bin
|
||||
|
||||
GPO_VERSION=$(MSYSTEM= build_python -c \
|
||||
"import gpodder; import sys; sys.stdout.write(gpodder.__version__)")
|
||||
GPO_VERSION_DESC="$GPO_VERSION"
|
||||
|
@ -135,6 +131,11 @@ function install_gpodder {
|
|||
local GIT_HASH=$(git rev-parse --short HEAD)
|
||||
GPO_VERSION_DESC="$GPO_VERSION-rev$GIT_REV-$GIT_HASH"
|
||||
fi
|
||||
|
||||
# Create launchers
|
||||
python3 "${MISC}"/create-launcher.py \
|
||||
"${GPO_VERSION}" "${MINGW_ROOT}"/bin
|
||||
|
||||
# install fake dbus
|
||||
rsync -arv --delete "${REPO_CLONE}"/tools/fake-dbus-module/dbus "${BUILD_ROOT}"/"${MINGW}"/lib/python3.6/site-packages/
|
||||
|
||||
|
@ -309,7 +310,7 @@ function build_installer {
|
|||
function build_portable_installer {
|
||||
BUILDPY=$(echo "${MINGW_ROOT}"/lib/python3.*/site-packages/gpodder)/build_info.py
|
||||
cp "${REPO_CLONE}"/src/gpodder/build_info.py "$BUILDPY"
|
||||
echo 'BUILD_TYPE = u"windows"' >> "$BUILDPY"
|
||||
echo 'BUILD_TYPE = u"windows-portable"' >> "$BUILDPY"
|
||||
echo "BUILD_VERSION = $BUILD_VERSION" >> "$BUILDPY"
|
||||
(cd "$REPO_CLONE" && echo "BUILD_INFO = u\"$(git rev-parse --short HEAD)\"" >> "$BUILDPY")
|
||||
(cd $(dirname "$BUILDPY") && build_compileall -d "" -q -f -l .)
|
||||
|
|
Loading…
Reference in New Issue