Clarify installer data directory and verify missing customsets creation
Cockatrice assets CI Checks passed and artifacts archived. Stable publication was skipped for this branch.
Gitea/cockatrice-custom-tokens/pipeline/head This commit looks good
Details
Cockatrice assets CI Checks passed and artifacts archived. Stable publication was skipped for this branch.
Gitea/cockatrice-custom-tokens/pipeline/head This commit looks good
Details
This commit is contained in:
parent
c0a2e2da61
commit
f03cd31f47
|
|
@ -340,7 +340,23 @@ Errors and cancellations return a nonzero installer exit status. The plain
|
|||
`curl ... | sh` pipeline has the separate download-status caveat described below.
|
||||
|
||||
For a portable or unusual data directory, specify the existing **data directory**,
|
||||
not its `customsets` subfolder:
|
||||
not its `customsets` subfolder. `--datadir` is also accepted. Choose the folder
|
||||
containing `cards.xml` or `settings/`, normally alongside `decks/`. For example:
|
||||
|
||||
```text
|
||||
/home/vky/.var/app/io.github.Cockatrice.cockatrice/data/Cockatrice/Cockatrice/
|
||||
cards.xml (or settings/ must exist)
|
||||
settings/
|
||||
decks/
|
||||
customsets/ (may be missing; created after confirmation)
|
||||
pics/ (may be missing; created after confirmation)
|
||||
```
|
||||
|
||||
Do not choose the outer `.../data/` or `.../data/Cockatrice/` directory.
|
||||
The installer creates missing destination folders only during the final installation
|
||||
step, after downloads validate and you approve the file list. `settings/paths.ini`
|
||||
overrides still apply. Use `--help` for the same directory guidance.
|
||||
|
||||
|
||||
```sh
|
||||
curl --fail --show-error --silent --proto '=https' https://assets.dandaedre.com/mtg/install.sh | sh -s -- --data-dir /absolute/path/to/Cockatrice/data
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ $ErrorActionPreference = 'Stop'
|
|||
Set-StrictMode -Version Latest
|
||||
if ($Help) {
|
||||
Write-Host 'Usage: .\install.ps1 [-DataDir C:\path\to\Cockatrice\data] [-Force]'
|
||||
Write-Host 'DataDir is the folder containing cards.xml or settings/, normally alongside decks/.'
|
||||
Write-Host 'Example: C:\Users\YourName\AppData\Local\Cockatrice\Cockatrice (not its parent or customsets folder). '
|
||||
Write-Host 'Missing customsets/pics folders are created only after confirmation and successful validation.'
|
||||
Write-Host 'Requires Windows, Python 3.8+, curl.exe, and an interactive console. Close Cockatrice first.'
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,10 @@ def select_install(home, environment, explicit=None):
|
|||
root = candidates[0]
|
||||
safe_path(root)
|
||||
if not root.is_dir() or not ((root / 'cards.xml').is_file() or (root / 'settings').is_dir()):
|
||||
raise ValueError(f'Not a recognized Cockatrice data directory: {root}. Launch Cockatrice first.')
|
||||
raise ValueError(f'Not a recognized Cockatrice data directory: {root}. '
|
||||
'Choose the folder containing cards.xml or settings/ (the parent of customsets/ and pics/). '
|
||||
'For Flatpak use ~/.var/app/io.github.Cockatrice.cockatrice/data/Cockatrice/Cockatrice/, '
|
||||
'not data/ or data/Cockatrice/. Launch Cockatrice once first.')
|
||||
for marker in (root / 'cards.xml', root / 'settings'):
|
||||
if marker.is_symlink():
|
||||
raise ValueError(f'Symlinked installation marker is not supported: {marker}')
|
||||
|
|
@ -365,8 +368,19 @@ def run(args):
|
|||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--data-dir', type=Path, help='Existing absolute Cockatrice data directory (not customsets)')
|
||||
parser = argparse.ArgumentParser(
|
||||
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
epilog="""Data directory example (Flatpak):
|
||||
--data-dir /home/vky/.var/app/io.github.Cockatrice.cockatrice/data/Cockatrice/Cockatrice/
|
||||
|
||||
Choose the folder containing cards.xml or settings/, normally alongside decks/.
|
||||
Its customsets/ and pics/ subfolders may be missing: creation requires confirmation
|
||||
and happens only after all downloads validate and you approve installation.
|
||||
Do NOT select the outer .../data/ or .../data/Cockatrice/ folders, or decks/ or
|
||||
customsets/ itself. Configured customsets/pics paths in settings/paths.ini win.
|
||||
""")
|
||||
parser.add_argument('--data-dir', '--datadir', type=Path,
|
||||
help='Existing absolute data root containing cards.xml or settings/; see example below')
|
||||
parser.add_argument('--force', action='store_true',
|
||||
help='Download and replace even files whose size and SHA-256 already match')
|
||||
args = parser.parse_args()
|
||||
|
|
|
|||
|
|
@ -285,6 +285,31 @@ class InstallerTests(unittest.TestCase):
|
|||
self.assertEqual(target.read_bytes(), XML)
|
||||
self.assertFalse((self.root / '.custom-tokens-install.lock').exists())
|
||||
|
||||
def test_full_run_creates_missing_customsets_after_confirmation(self):
|
||||
self.destinations['customsets'].rmdir()
|
||||
self.test_full_run_downloads_then_installs_and_cleans_up()
|
||||
self.assertTrue(self.destinations['customsets'].is_dir())
|
||||
|
||||
def test_failed_download_does_not_create_missing_customsets(self):
|
||||
self.destinations['customsets'].rmdir()
|
||||
class Args:
|
||||
data_dir = self.root
|
||||
with patch.object(installer.sys, 'platform', 'linux'), \
|
||||
patch.object(installer.shutil, 'which', return_value='/mock/curl'), \
|
||||
patch.object(installer.os, 'geteuid', return_value=1000, create=True), \
|
||||
patch.object(installer, 'prompt', return_value='yes'), \
|
||||
patch.object(installer, 'download', side_effect=ValueError('download failed')):
|
||||
with self.assertRaisesRegex(ValueError, 'download failed'):
|
||||
installer.run(Args())
|
||||
self.assertFalse(self.destinations['customsets'].exists())
|
||||
|
||||
def test_datadir_alias_and_help(self):
|
||||
result = subprocess.run([sys.executable, str(SPEC.origin), '--datadir', str(self.root), '--help'],
|
||||
capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, 0)
|
||||
self.assertIn('/data/Cockatrice/Cockatrice/', result.stdout)
|
||||
self.assertIn('cards.xml or settings/', result.stdout)
|
||||
|
||||
def test_full_run_downloads_then_installs_and_cleans_up(self):
|
||||
class Args:
|
||||
data_dir = self.root
|
||||
|
|
|
|||
Loading…
Reference in New Issue