Commit Graph
668 Commits
Author SHA1 Message Date
Jakub Čábera f8c4d174a8 [buckets] Get back to if (#3351) 2019-04-21 20:48:26 +02:00
Jakub Čábera 4a2f3bbfe8 fix (#3350)
[Regression] Fix search after buckets optimize
2019-04-21 20:14:34 +02:00
Jakub Čábera 4463514948 [buckets] Optimize buckets function (#3341)
* Optimize buckets function
* Use Verb-Noun naming
* Add Show-DeprecatedWarning function to core
2019-04-21 13:02:19 +02:00
Edgard Lorraine Messias 79d7af971f install.ps1: Fixed cache copy with aria2 (#3318) 2019-04-10 14:20:23 +02:00
Hsiao-nan Cheung 6d7fafb145 autoupdate.ps1: Add $base64 hash template 2019-04-04 12:30:18 +02:00
Richard Kuhnt 10d191a4b1 git.ps1: Don't use proxy if it's set to "none" 2019-03-18 15:16:10 +01:00
Jakub Čábera 54235efe59 Fix buckets.ps1: regression from bucket folder structure (#3218)
- Closes lukesampson/scoop-extras#1794
2019-03-18 11:39:40 +01:00
Chawye Hsu 17cb68fca0 refactor(core): move default_aliases into the scoped function (#3233) 2019-03-18 11:29:27 +01:00
Jakub Čábera ad01bff667 Add bin\checkhashes.ps1 (#2766)
- Checks if all URLs inside manifest have correct hashes
2019-03-11 10:39:37 +01:00
Hsiao-nan Cheung 5d14db6786 core.ps1: Fix url_remote_filename (edited) (#3022)
EDITED: No WebRequest, Local URL Treatment

Current `url_remote_filename()` cannot handle redirected urls like "https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-9/v9.0.14/bin/apache-tomcat-9.0.14-windows-x64.zip", this modified one works in most cases.

- Get filename from PathAndQuery instead of AbsolutePath
- Throw away leading `?=`
- If got `vxx.xx.xx`, fallback to AbsolutePath
- Use fragment name if all above failed
2019-03-11 10:07:53 +01:00
Ross Smith II 8b7f3fc218 install.ps1: Allow persist dirs to have trailing slash (#3203) 2019-03-10 12:47:23 +01:00
Hsiao-nan Cheung 5f91682a79 decompress.ps1: Refactored (w/ install.ps1, core.ps1) (edited) (#3169)
* decompress.ps1: Refactored (w/ install.ps1, core.ps1)

* fix install.ps1
2019-03-07 22:14:06 +01:00
Jakub Čábera bc8985402a [Schema] Add metalink mode to hashmode (#3170)
* [Schema] Add metalink mode

Schema is missing property for metalink

See: https://github.com/lukesampson/scoop/blob/57b0b0e1eb2c946ca74541b2464d3e61e195e979/lib/autoupdate.ps1#L213-L218

* Make fosshub and sourceforge same as other methods
2019-03-04 14:00:16 +01:00
kiennq ef97f0875a Invoke powershell with -noprofile flag from bash shims (#3165) 2019-02-24 11:30:08 +01:00
Vladimir Chebotarev da64301b8b [core] Allowed underscores in package names. (#2930)
* Allowed underscores in package names.

* Added tests for underscores in package names.
2019-02-22 19:12:48 +01:00
Jakub Čábera 1113b3b049 buckets.ps1: Correct bucket URL for new issues (#3141)
- support for ssh and https remotes
2019-02-19 19:43:55 +01:00
Hsiao-nan Cheung 03ebcc2984 supporting: Update Newtonsoft.Json to 11.0.2, Newtonsoft.Json.Schema to 3.0.10 (#3043)
- Update supporting\validator\bin\Newtonsoft.Json to 11.0.2
  - **HIGHLIGHT**: support for regex operator in JSON Paths
  - Latest Newtonsoft.Json version is 12.0.1, which has some compatibility issues with Json.Schema 3.0.10 and PowerShell Core 6.1.12 (On my PC)
- Update supporting\validator\bin\Newtonsoft.Json.Schema to 3.0.10
- Use .NET 4.5 instead of .NET 4.0, since Scoop's requirements is [.NET Framework 4.5+](https://github.com/lukesampson/scoop#requirements)
- Modify `json_path()` to escape `$version` substitutions when `$jsonpath` has regex

**EXAMPLE OF JPATH REGEX**
```json
"checkver": {
    "url": "https://dist.nuget.org/index.json",
    "jp": "$..versions[?(@.displayName =~ /.*recommended.*/)].version"
}
```
2019-02-16 22:20:37 +01:00
Hsiao-nan Cheung 0696ec52f8 Fix fosshub.com url handler and add fosshub hash mode (#3126)
- Fix broken fosshub.com url handle function. It can handle urls like `https://www.fosshub.com/Calibre.html/calibre-64bit-3.39.1.msi` or `https://www.fosshub.com/Audacity.html?dwl=audacity-win-2.3.0.zip` and get the right download link.
- Add `fosshub` hash extraction mode.
2019-02-16 19:47:13 +01:00
Richard Kuhnt a305535b0e core.ps1: Allow SCOOP_DEBUG environment variable in debug() function 2019-02-09 19:13:30 +01:00
Richard Kuhnt 8213fa3d69 core.ps1: Handle $null values in debug() 2019-02-04 10:09:25 +01:00
Richard Kuhnt 146e309df8 core.ps1: Use "debug" config value instead of $env:SCOOP_DEBUG 2019-02-03 17:54:58 +01:00
Richard Kuhnt 9ce2fda854 install.ps1: show aria2 output as error instead of debug 2019-02-03 17:05:33 +01:00
Richard Kuhnt 9133206acd autoupdate.ps1: Add regex substitutions for all hash functions 2019-02-03 16:54:27 +01:00
Richard Kuhnt 122877620d autoupdate.ps1: Add debug functions calls to find_hash_in_textfile()
- This can be useful for debugging regex issues
2019-02-03 16:49:46 +01:00
Richard Kuhnt 6da4ce9000 core.ps1: Improve debug() function
- Enable output by setting $env:SCOOP_DEBUG to true (disabled by default)
- Converts objects to string output
- Shows calling position for clickable links in VSCode
2019-02-03 16:48:20 +01:00
Richard Kuhnt 39136fc6fe core.ps1: Rename unzip() to extract_zip() 2019-02-03 13:07:02 +01:00
Jakub Čábera 030a48b51c scoop-update.ps1: Checkout SCOOP_BRANCH if configured (#3063) 2019-02-01 18:20:08 +01:00
Chawye Hsu e5addb9487 Refactor: Tweak SecurityProtocol usage (#3065)
reopen #3051 
Now the code logic: if `SecurityProtocol` is `SystemDefault`, don't change, else change it to `Tls1.2,Tls1.1,Tls1.0`,  never support `Ssl3` anymore.
2019-02-01 18:17:40 +01:00
Jakub Čábera ec23179623 buckets: Move function into lib from lib-exec (#3062)
* buckets: Move function into lib from lib-exec

There is no reason to have it inside lib-exec since, it's all internal functions, which could be used inside other code

lib-exec scripts should be slimmed as possible, as they are only code runners with some validation

* Fix whitespace
2019-02-01 18:10:36 +01:00
Hsiao-nan Cheung ef343d7f75 autoupdate.ps1: Fixes bug for single line hash extraction (#3015)
Fix a bug introduced in #2996 that single line hash extraction is broken.

When `find_hash_in_textfile()` is called in `get_hash_for_app()`, `$null` is used as `$regex` value for default single line hash extraction and the default value (`'^([a-fA-F0-9]+)$'`) is overriden, which leads a error of "hash not found".
2019-01-21 11:42:49 +01:00
Richard Kuhnt 8dd09661b1 Revert changes from #2931 to fix PS6 conversion problem 2019-01-21 01:40:06 +01:00
Hsiao-nan Cheung 034103fb0e Add JArray::Parse() to json_path in lib/json.ps1 (#3011)
Some JSON file ([example](https://mranapi.azurewebsites.net/api/download)) is surrounded by brackets ("[", "]") and cannot be parsed using `[Newtonsoft.Json.Linq.JObject]::Parse()` in `json_path()`. Instead, they could be parsed by `[Newtonsoft.Json.Linq.JArray]::Parse()` and then be treated as normal, e.g., applies a filter (script) expression.

- Add `[Newtonsoft.Json.Linq.JArray]::Parse()` after `[Newtonsoft.Json.Linq.JObject]::Parse()` failed
- Some JArray are handled by `json_path_legacy()` when `json_path()` throw error before, and the JSONPath is illegal when parsed with `JArray::Parse()`. To keep compatibility, add try-catch in this situation and let `json_path_legacy()` handle them still.
- In the above situation, manifest maintainer should use double dots after `$`, i.e., use `$..NODE` instead of `$.NODE` since it is a JArray contained the JObject.
2019-01-20 12:52:57 +01:00
Chawye Hsu 945a0c64c4 fix(persist): fix the target didn't be created (#3008)
fix(persist): fix the target didn't be created
2019-01-18 05:51:48 +01:00
Richard Kuhnt 3a22526554 Merge pull request #2996 from niheaven/add-version-variables-to-regex-in-hash-extract
Add version variables to autoupdate.hash.regex
2019-01-17 18:40:48 +01:00
Chawye Hsu d23552a5a5 Rewritten data persisting feature (#2897)
**Data matters, please review**

This is a rework of #2891 #2890 and #2882 . This will also fix #2724 and fix #2900 , close #2779 

**Introduction**

I add a function called `unlink_persist_data($dir)`, which recursively unlink all junction/hard link in the given directory. This affects some sub-commands which have interaction with junction/hard link:

- `scoop-install`: the persisting logic has been improved as follow:
  1. if there are data in the `persist` folder, also in app(`source`) folder, rename that one located in app folder (e.g. app's default setting files) with a `original` suffix, then create link from `persist` to  app
  2. if there are data in the `persist` folder, but no in app(`source`) folder, just create link from `persist` to  app
  3. if there is no data in the `persist` folder (e.g. fresh install), but there are data in app(`source`) folder (e.g. app's default setting files), we will just use that default setting files as the first-time persisting. So move that files from app folder to `persist` folder, then create link from `persist` to  app
  4. But what if if there is neither data in the `persist` folder (e.g. fresh install), nor in the app(`source`) folder (e.g. setting files will be created after first startup, like `Everthing.db`). We need to create empty persisting target in the `persist` folder. But by default we can't know if a persisting target is a file or a directory (e.g. `conf.d`). So we create a directory by default, and to avoid this, manifest maintainers should use `pre_install` to manually create the source file before persisting.
- `scoop-reset`: `reset` command uses the logic of `install`, but there is a problem: before re-persisting data, there have been `junction/hard link` in the app(`source`) folder. It will throw an exception of file exists #2724 . To fix this, we should unlink all old link before re-persisting, using `unlink_persist_data`.
- `scoop-uninstall`: `Remove-Item` can not remove `NTFS junction`, we need to unlink all persistting data, before uninstalling/deleting an app, but keeping persisting data.
- `scoop-cleanup`: like `uninstall`, `Remove-Item` can not remove `NTFS junction`, we need to unlink all persistting data, before deleting old versions of an app. Before PR #2882 , it use `fsutil.exe` to unlink junction, which is not friendly to restricted users (#2832 and #2881 ).

Beyond the logic improvement, there is a new feature now: it supports sub-folder data persisting, like:

```json
{
    "homepage": "https://scoop.sh",
    "description": "A dummy manifest for scoop tests.",
    "license": "Freeware",
    "version": "1.1.0",
    "url": "https://get.scoop.sh",
    "pre_install": [
        "if (!(test-path \"$dir\\dummy.txt\")) { new-item -force \"$dir\\dummy.txt\" -itemtype file | out-null }",
        "if (!(test-path \"$dir\\dummydir\")) { new-item \"$dir\\dummydir\" -itemtype directory | out-null }",
        "if (!(test-path \"$dir\\subdir\")) { new-item \"$dir\\subdir\" -itemtype directory | out-null }",
        "if (!(test-path \"$dir\\subdir\\subdummydir\")) { new-item \"$dir\\subdir\\subdummydir\" -itemtype directory | out-null }",
        "if (!(test-path \"$dir\\subdir\\subdummy.txt\")) { new-item -force \"$dir\\subdir\\subdummy.txt\" -itemtype file | out-null }",
    ],
    "persist": [
        "dummy.txt",
        "dummydir",
        "subdir\\subdummydir",
        "subdir\\subdummy.txt"
    ]
}
```
So no need to strip directories of source for target anymore.

To participate in the code review and tests, go visit https://github.com/h404bi/scoop-persist-test for test cases.
2019-01-17 18:00:29 +01:00
Hsiao-nan Cheung dfe846aca0 Add version variables to JSONPath 2019-01-17 16:14:10 +08:00
Hsiao-nan Cheung c3ee407197 Use substitute to replace version variables 2019-01-17 15:11:16 +08:00
Hsiao-nan Cheung c6de3b7c98 Add version variables to autoupdate.hash.regex 2019-01-16 15:20:41 +08:00
Vladimir Chebotarev b925b8ede5 Simplified last_scoop_update(). (#2931) 2019-01-11 16:46:43 +01:00
Retia 3d8d5e84c3 Improvements for the reset command to deal with empty current alias dir correctly (#2896) 2018-12-16 07:45:59 -08:00
Jun Ueoka 79a0d3b768 core/update: Scoop updates itself automatically for the first time after fresh install (#2907)
Fixes #2906
2018-12-16 13:16:48 +01:00
Jakub Čábera 0029f0b29d Fix regression from #2878 (#2899)
Fix regression from #2878
2018-12-14 12:51:17 +01:00
Jakub Čábera 000f1a7473 Support nested bucket folder in external buckets (#2878)
- Closes #2531 

Actual behaviour is kept and nothing is broken.

If external bucket contains `bucket` folder it's used for finding manifests.

How to test:

1. Create folder `TestBucket` in `$env:SCOOP\buckets`
1. Create manifest `CosiTest.json` with hello manifest # Or some other name which definetely cannot exists❗
1. execute `.\bin\scoop.ps1 install CosiTest` within this branch
1. Installing done
1. `.\bin\scoop.ps1 uninstall CosiTest`
1. Create folder `bucket` in `TestBucket` directory and copy CosiTest.json as `bucket\CosiTestBucket.json`
1. `.\bin\scoop.ps1 install CosiTest`
1. Installation will failed with `Couldn't find manifest for 'CosiTest'.`
1. `.\bin\scoop.ps1 install CosiTestBucket`
1. Installation Done
1. `.\bin\scoop.ps1 uninstall CosiTestBucket`
1. Unnstallation Done
2018-12-13 21:10:08 -08:00
Jakub Čábera 614b3279ba [autoupdate] base64 hash extraction fix (#2852) 2018-12-06 20:54:47 +01:00
Jakub Čábera a20b2e99e2 Fix empty bucket name (#2827) 2018-12-01 07:08:19 -08:00
Jakub Čábera 87df537f8c [json] Apparently I cannot use variable (#2768)
json.ps1: Fix a variable Problem introduced with the last changes
2018-11-14 05:41:04 +01:00
Jakub Čábera 3e1649553d formatjson.ps1: Format single value Arrays into String (#2642)
- Automatically convert single value arrays and recursively normalize PSObjects values
- Add tests
- Add .yml .editorconfig settings
2018-11-13 20:49:20 +01:00
Pakorn Vongseela f284dba5d7 install.ps1: Fix persisting bug with already existing folder (#2732)
closes https://github.com/lukesampson/scoop-extras/issues/1300
closes https://github.com/lukesampson/scoop-extras/issues/1370
closes #2724
closes #2671
2018-11-12 10:26:16 +01:00
krokofant 5a51098df5 Fix #2745 Workaround Microsofts syntactic PSModulePath (#2748)
* Workaround Microsofts syntactic PSModulePath

The default user PSModulePath is "$env:USERPROFILE\Documents\WindowsPowerShell\Modules". I the user env variable PSModulePath actually exists the default path is omitted - so we need to explicitly add it.
2018-11-08 19:35:02 +01:00
Ishan Arora 98e0721bb9 core.ps1: Fixed sh shims (path escaping in MSYS2 and Git bash) (#2742)
#2741 broke sh shims in MSYS2 environments (includes Git bash).
2018-11-05 20:27:55 +01:00