Skip to content

Commit

Permalink
Revert beeware#777 (OS-native data dir) in light of beeware#789 (no w…
Browse files Browse the repository at this point in the history
…hitespace in Android SDK path)
  • Loading branch information
rmartin16 committed Jul 14, 2022
1 parent 4bdfdc1 commit 363da56
Show file tree
Hide file tree
Showing 28 changed files with 59 additions and 274 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,12 @@ jobs:
framework: ['toga', 'pyside2', 'pyside6', 'ppb']
include:
- platform: macos-latest
briefcase-data-dir: ~/Library/Application Support/briefcase
pip-cache-dir: ~/Library/Caches/pip
docker-cache-dir: ~/Library/Containers/com.docker.docker/Data/vms/0/
- platform: windows-latest
briefcase-data-dir: ~\AppData\Local\BeeWare\briefcase
pip-cache-dir: ~\AppData\Local\pip\Cache
docker-cache-dir: C:\ProgramData\DockerDesktop
- platform: ubuntu-latest
briefcase-data-dir: ~/.local/share/briefcase
pip-cache-dir: ~/.cache/pip
# cache action cannot cache docker images (actions/cache#31)
# docker-cache-dir: /var/lib/docker
Expand All @@ -160,8 +157,8 @@ jobs:
with:
key: briefcase-${{ matrix.platform }}
path: |
~/.briefcase
~/.cookiecutters
${{ matrix.briefcase-data-dir }}
${{ matrix.pip-cache-dir }}
${{ matrix.docker-cache-dir }}
- uses: actions/checkout@v3
Expand Down
1 change: 0 additions & 1 deletion changes/374.feature.rst

This file was deleted.

1 change: 0 additions & 1 deletion changes/783.misc.rst

This file was deleted.

1 change: 0 additions & 1 deletion changes/784.doc.rst

This file was deleted.

1 change: 1 addition & 0 deletions changes/790.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Revert implementation of OS-native data directories due to issues with whitespace in Android SDK path.
8 changes: 4 additions & 4 deletions docs/how-to/code-signing/android.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,28 @@ Google Play.
.. code-block:: bash
$ mkdir -p ~/.android
$ ~/Library/Application\ Support/briefcase/tools/java/Contents/Home/bin/keytool -keyalg RSA -deststoretype pkcs12 -genkey -v -storepass android -keystore ~/.android/upload-key-helloworld.jks -keysize 2048 -dname "cn=Upload Key" -alias upload-key -validity 10000
$ ~/.briefcase/tools/java/Contents/Home/bin/keytool -keyalg RSA -deststoretype pkcs12 -genkey -v -storepass android -keystore ~/.android/upload-key-helloworld.jks -keysize 2048 -dname "cn=Upload Key" -alias upload-key -validity 10000
.. group-tab:: Linux

.. code-block:: bash
$ mkdir -p ~/.android
$ ~/.local/share/briefcase/tools/java/bin/keytool -keyalg RSA -deststoretype pkcs12 -genkey -v -storepass android -keystore ~/.android/upload-key-helloworld.jks -keysize 2048 -dname "cn=Upload Key" -alias upload-key -validity 10000
$ ~/.briefcase/tools/java/bin/keytool -keyalg RSA -deststoretype pkcs12 -genkey -v -storepass android -keystore ~/.android/upload-key-helloworld.jks -keysize 2048 -dname "cn=Upload Key" -alias upload-key -validity 10000
.. group-tab:: Windows (PowerShell)

.. code-block:: powershell
C:\...>If (-Not (Test-Path "$env:HOMEPATH/.android")) { New-Item -Path "$env:HOMEPATH\.android" -ItemType Directory }
C:\...>& "$env:LOCALAPPDATA\BeeWare\briefcase\tools\java\bin\keytool.exe" -keyalg RSA -deststoretype pkcs12 -genkey -v -storepass android -keystore "$env:HOMEPATH\.android\upload-key-helloworld.jks" -keysize 2048 -dname "cn=Upload Key" -alias upload-key -validity 10000
C:\...>& "$env:HOMEPATH\.briefcase\tools\java\bin\keytool.exe" -keyalg RSA -deststoretype pkcs12 -genkey -v -storepass android -keystore "$env:HOMEPATH\.android\upload-key-helloworld.jks" -keysize 2048 -dname "cn=Upload Key" -alias upload-key -validity 10000
.. group-tab:: Windows (cmd)

.. code-block:: doscon
C:\...>IF not exist %HOMEPATH%\.android mkdir %HOMEPATH%\.android
C:\...>%LOCALAPPDATA%\BeeWare\briefcase\tools\java\bin\keytool.exe -keyalg RSA -deststoretype pkcs12 -genkey -v -storepass android -keystore %HOMEPATH%\.android\upload-key-helloworld.jks -keysize 2048 -dname "cn=Upload Key" -alias upload-key -validity 10000
C:\...>%HOMEPATH%\.briefcase\tools\java\bin\keytool.exe -keyalg RSA -deststoretype pkcs12 -genkey -v -storepass android -keystore %HOMEPATH%\.android\upload-key-helloworld.jks -keysize 2048 -dname "cn=Upload Key" -alias upload-key -validity 10000
This creates a 2048-bit key and stores it in a Java keystore located in the
Expand Down
8 changes: 4 additions & 4 deletions docs/how-to/publishing/android.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ name.

.. code-block::
$ ~/Library/Application\ Support/briefcase/tools/java/Contents/Home/bin/jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/.android/upload-key-helloworld.jks "android/gradle/Hello World/app/build/outputs/bundle/release/app-release.aab" upload-key -storepass android
$ ~/.briefcase/tools/java/Contents/Home/bin/jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/.android/upload-key-helloworld.jks "android/gradle/Hello World/app/build/outputs/bundle/release/app-release.aab" upload-key -storepass android
adding: META-INF/MANIFEST.MF
adding: META-INF/UPLOAD-K.SF
adding: META-INF/UPLOAD-K.RSA
Expand All @@ -101,7 +101,7 @@ name.

.. code-block::
$ ~/.local/share/briefcase/tools/java/bin/jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/.android/upload-key-helloworld.jks "android/gradle/Hello World/app/build/outputs/bundle/release/app-release.aab" upload-key -storepass android
$ ~/.briefcase/tools/java/bin/jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/.android/upload-key-helloworld.jks "android/gradle/Hello World/app/build/outputs/bundle/release/app-release.aab" upload-key -storepass android
adding: META-INF/MANIFEST.MF
adding: META-INF/UPLOAD-K.SF
adding: META-INF/UPLOAD-K.RSA
Expand All @@ -126,7 +126,7 @@ name.

.. code-block::
C:\...>& "$env:LOCALAPPDATA\BeeWare\briefcase\tools\java\bin\jarsigner.exe" -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore "$env:HOMEPATH\.android\upload-key-helloworld.jks" "android\gradle\Hello World\app\build\outputs\bundle\release\app-release.aab" upload-key -storepass android
C:\...>& "$env:HOMEPATH\.briefcase\tools\java\bin\jarsigner.exe" -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore "$env:HOMEPATH\.android\upload-key-helloworld.jks" "android\gradle\Hello World\app\build\outputs\bundle\release\app-release.aab" upload-key -storepass android
adding: META-INF/MANIFEST.MF
adding: META-INF/UPLOAD-K.SF
adding: META-INF/UPLOAD-K.RSA
Expand All @@ -151,7 +151,7 @@ name.

.. code-block:: doscon
C:\...>%LOCALAPPDATA%\BeeWare\briefcase\tools\java\bin\jarsigner.exe -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore %HOMEPATH%\.android\upload-key-helloworld.jks "android\gradle\Hello World\app\build\outputs\bundle\release\app-release.aab" upload-key -storepass android
C:\...>%HOMEPATH%\.briefcase\tools\java\bin\jarsigner.exe -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore %HOMEPATH%\.android\upload-key-helloworld.jks "android\gradle\Hello World\app\build\outputs\bundle\release\app-release.aab" upload-key -storepass android
adding: META-INF/MANIFEST.MF
adding: META-INF/UPLOAD-K.SF
adding: META-INF/UPLOAD-K.RSA
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ install_requires =
dmgbuild >= 1.3.3; sys_platform == "darwin"
psutil >= 5.9.0
rich >= 12.4.1
platformdirs >= 2.5.2

[options.packages.find]
where = src
Expand Down
1 change: 0 additions & 1 deletion src/briefcase/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def main():
command = None
try:
command, options = parse_cmdline(sys.argv[1:])
command.check_obsolete_data_dir()
command.parse_config("pyproject.toml")
command(**options)
result = 0
Expand Down
90 changes: 3 additions & 87 deletions src/briefcase/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import requests
from cookiecutter.main import cookiecutter
from cookiecutter.repository import is_repo_url
from platformdirs import PlatformDirs

try:
import tomllib
Expand All @@ -27,7 +26,6 @@
BadNetworkResourceError,
BriefcaseCommandError,
BriefcaseConfigError,
InfoHelpText,
MissingNetworkResourceError,
)
from briefcase.integrations.subprocess import Subprocess
Expand Down Expand Up @@ -114,18 +112,11 @@ class BaseCommand(ABC):
GLOBAL_CONFIG_CLASS = GlobalConfig
APP_CONFIG_CLASS = AppConfig

def __init__(
self,
base_path,
home_path=Path.home(),
data_path=PlatformDirs(appname="briefcase", appauthor="BeeWare").user_data_path,
apps=None,
input_enabled=True,
):
def __init__(self, base_path, home_path=Path.home(), apps=None, input_enabled=True):
self.base_path = base_path
self.home_path = home_path
self.data_path = data_path
self.tools_path = self.data_path / "tools"
self.dot_briefcase_path = home_path / ".briefcase"
self.tools_path = self.dot_briefcase_path / "tools"

self.global_config = None
self.apps = {} if apps is None else apps
Expand All @@ -152,81 +143,6 @@ def __init__(
self.logger = Log()
self.save_log = False

def check_obsolete_data_dir(self):
"""Inform user if obsolete data directory exists.
TODO: Remove this check after 1 JAN 2023 since most users will have transitioned by then
Previous versions used the ~/.briefcase directory to store
downloads, tools, etc. This check lets users know the old
directory still exists and their options to migrate or clean up.
"""
dot_briefcase_path = self.home_path / ".briefcase"

if not dot_briefcase_path.exists():
return

if self.data_path.exists():
self.logger.warning(
f"""\
Briefcase is no longer using the data directory:
{dot_briefcase_path}
This directory can be safely deleted.
"""
)
else:
self.logger.warning(
f"""\
*************************************************************************
** NOTICE: Briefcase is changing its data directory **
*************************************************************************
Briefcase is moving its data directory from:
{dot_briefcase_path}
to:
{self.data_path}
If you continue, Briefcase will re-download the tools and data it
uses to build and package applications.
To avoid potentially large downloads and long installations, you
can manually move the old data directory to the new location.
If you continue and allow Briefcase to re-download its tools, the
old data directory can be safely deleted.
*************************************************************************
"""
)
self.input.prompt()
if not self.input.boolean_input(
"Do you want to re-download the Briefcase support tools",
# Default to continuing for non-interactive runs
default=not self.input.enabled,
):
raise InfoHelpText(
f"""\
Move the Briefcase data directory from:
{dot_briefcase_path}
to:
{self.data_path}
or delete the old data directory, and re-run Briefcase.
"""
)

# Create data directory to prevent full notice showing again.
self.data_path.mkdir(parents=True, exist_ok=True)

@property
def create_command(self):
"""Factory property; return an instance of a create command for the
Expand Down
2 changes: 1 addition & 1 deletion src/briefcase/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def install_app_support_package(self, app: BaseConfig):
# in the user's briefcase support cache directory.
support_filename = self.download_url(
url=support_package_url,
download_path=self.data_path / "support",
download_path=self.dot_briefcase_path / "support",
)
else:
support_filename = Path(support_package_url)
Expand Down
23 changes: 9 additions & 14 deletions src/briefcase/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ class HelpText(BriefcaseError):
an error."""


class InfoHelpText(HelpText):
def __init__(self, msg):
super().__init__(0)
self.msg = msg

def __str__(self):
return self.msg


class NoCommandError(HelpText):
def __init__(self, msg):
super().__init__(-10)
Expand All @@ -26,16 +17,20 @@ def __str__(self):
return self.msg


class ShowOutputFormats(InfoHelpText):
class ShowOutputFormats(HelpText):
def __init__(self, platform, default, choices):
super().__init__(
f"Available formats for {platform}: {', '.join(sorted(choices))}\n"
f"Default format: {default}"
)
super().__init__(0)
self.platform = platform
self.default = default
self.choices = choices

def __str__(self):
choices = ", ".join(sorted(self.choices))
return (
f"Available formats for {self.platform}: {choices}\n"
f"Default format: {self.default}"
)


class InvalidFormatError(BriefcaseError):
def __init__(self, requested, choices):
Expand Down
15 changes: 8 additions & 7 deletions src/briefcase/integrations/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,9 @@ def prepare(self):

def run(self, args, env=None, **kwargs):
"""Run a process inside a Docker container."""
# briefcase data directory used inside container
docker_data_path = "/home/brutus/.local/share/briefcase"
# Set up the `docker run` with volume mounts for the platform &
# briefcase data and tools directories and to delete the
# temporary container after running the command.
# .briefcase directories and to delete the temporary container
# after running the command.
# The :z suffix allows SELinux to modify the host mount; it is
# ignored on non-SELinux platforms.
docker_args = [
Expand All @@ -256,7 +254,7 @@ def run(self, args, env=None, **kwargs):
"--volume",
f"{self.command.platform_path}:/app:z",
"--volume",
f"{self.command.data_path}:{docker_data_path}:z",
f"{self.command.dot_briefcase_path}:/home/brutus/.briefcase:z",
"--rm",
]

Expand All @@ -277,9 +275,12 @@ def run(self, args, env=None, **kwargs):
docker_args.append(
arg.replace(os.fsdecode(self.command.platform_path), "/app")
)
elif os.fsdecode(self.command.data_path) in arg:
elif os.fsdecode(self.command.dot_briefcase_path) in arg:
docker_args.append(
arg.replace(os.fsdecode(self.command.data_path), docker_data_path)
arg.replace(
os.fsdecode(self.command.dot_briefcase_path),
"/home/brutus/.briefcase",
)
)
else:
docker_args.append(arg)
Expand Down
8 changes: 4 additions & 4 deletions src/briefcase/integrations/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def verify(cls, command, install=True):
points to a Java 8 JDK, use it.
Otherwise, download a JDK from AdoptOpenJDK and unpack it into the
briefcase data directory.
``~.briefcase`` path.
:param command: The command that needs to perform the verification
check.
Expand Down Expand Up @@ -223,7 +223,7 @@ def exists(self):
@property
def managed_install(self):
try:
# Determine if java_home is relative to the briefcase data directory.
# Determine if java_home is relative to the .briefcase directory.
# If java_home isn't inside this directory, this will raise a ValueError,
# indicating it is a non-managed install.
self.java_home.relative_to(self.command.tools_path)
Expand Down Expand Up @@ -260,9 +260,9 @@ def install(self):

jdk_zip_path.unlink() # Zip file no longer needed once unpacked.

# The tarball will unpack into <briefcase data dir>/tools/jdk8u242-b08
# The tarball will unpack into ~/.briefcase/tools/jdk8u242-b08
# (or whatever name matches the current release).
# We turn this into <briefcase data dir>/tools/java so we have a consistent name.
# We turn this into ~/.briefcase/tools/java so we have a consistent name.
java_unpack_path = (
self.command.tools_path / f"jdk{self.release}-{self.build}"
)
Expand Down
2 changes: 1 addition & 1 deletion src/briefcase/integrations/wix.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def exists(self):
@property
def managed_install(self):
try:
# Determine if wix_home is relative to the briefcase data directory.
# Determine if wix_home is relative to the .briefcase directory.
# If wix_home isn't inside this directory, this will raise a ValueError,
# indicating it is a non-managed install.
self.wix_home.relative_to(self.command.tools_path)
Expand Down
Loading

0 comments on commit 363da56

Please sign in to comment.