Commit Graph

295 Commits

Author SHA1 Message Date
Jakub Čábera f552d40104 scoop-update.ps1: Download and verify files before update (#3148)
This is temporary solution for #2220 until whole install.ps1 refactor is done to make this tweak easily, in the best way one-liner.

- One step closer to #3149
- Closes #2220
- Closes #2343
- Closes #1605
2019-03-07 22:27:09 +01:00
Hsiao-nan Cheung f6a3819ac5 scoop-cleanup.ps1: Add param to cleanup outdated download cache (#3187)
* scoop-cleanup: Add param to cleanup outdated download cache

* Remove *.download when cleanup
2019-03-07 22:23:15 +01:00
Richard Kuhnt 38e346d380 install.ps1: replace raw.github.com with raw.githubusercontent.com
closes #3142
2019-02-19 22:08:11 +01:00
Jakub Čábera 94dd94e411 scoop-list: Identify failed installation (#3140) 2019-02-19 18:36:18 +01:00
Hsiao-nan Cheung 3324b03c98 scoop-info.ps1: Fix dual license error in "scoop info" (#3125) 2019-02-16 20:15:22 +01:00
Jakub Čábera aa949625fc Uninstall: Print purge step to console (#3123)
Uninstall: Print purge step to console
2019-02-14 06:05:02 +01:00
Jakub Čábera 030a48b51c scoop-update.ps1: Checkout SCOOP_BRANCH if configured (#3063) 2019-02-01 18:20:08 +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
Jakub Čábera cef2c6ec94 scoop-update.ps1: Use internal s/get_config function instead of scoop cmd (#3061)
This will prevent `Scoop is not recognized as internal command` when updating.
2019-02-01 18:08:56 +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
Chawye Hsu f1dbdc16d2 scoop-search: add config.ps1 to load proxy settings (#2911) 2018-12-17 05:57:41 -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
Chawye Hsu e4e76d3a32 scoop-cleanup: handle with junction better (#2882)
* scoop-cleanup: handle with junction better

* scoop-cleanup: only resolve directory symbolic link

* scoop-cleanup: stop removing when an error occurs.
2018-12-13 21:22:16 -08:00
Pakorn Vongseela ed6b10ac08 Fixed persisting bug when force update app with same version. (#2774) 2018-12-05 16:13:33 -08:00
Jakub Čábera 4da8e3df5f Persist data on reset (#2773)
- Closs #2765
2018-11-29 00:10:35 -08:00
Chawye Hsu 7697ba4ba8 feature(scoop-info): support url manifest (#2538) 2018-08-27 16:51:18 +02:00
Richard Kuhnt 936cf9cbb0 Prevent installing programs from JSON multiple times (See #2535) 2018-08-27 11:29:40 +02:00
Richard Kuhnt 8c77bf7676 Add warning about aria2 usage to install/update commands 2018-08-07 20:11:38 +02:00
Richard Kuhnt 23ae5e348e Add default value to get_config() 2018-08-07 20:11:38 +02:00
Richard Kuhnt 38bdaec440 Use aria2c to support multi-connection downloads 2018-08-07 20:11:38 +02:00
Richard Kuhnt e8af15cc06 Store last update time as String (fixes #2239)
Prevents problems with PowerShell 5 and 6 using different methods to store dates in JSON
2018-08-07 19:56:43 +02:00
Chawye Hsu 3294ef724f scoop-info: Make manifest file path looks better (#2439)
scoop-info: Make manifest file path looks better
2018-07-26 05:36:58 +02:00
Chawye Hsu bff9824cf4 Improve scoop-info license attributes output (#2397) 2018-07-16 18:39:13 +02:00
Richard Kuhnt f8f9b75f05 Option to skip hash validation and error message improvements (#2260)
* Add show_app() function for displaying `app/bucket@version`

* Add option to skip hash check on install/update

Allows users to install an app when the manifest provides an outdated hash

* Show filename instead of robocopy output when moving fails

* Add new_issue_msg() for nicer error messages (with link bucket repo)

- returns a message with a link to the buckets GitHub repository
- clicking on the link opens a new issues with a predefined title

* Use new_issue_msg() for errors while moving files

- this removes the unreadable robocopy error dumps

* Use new_issue_msg() error handling for check_hash()

* Show robocopy exit code
2018-06-14 18:30:05 +02:00
Richard Kuhnt 2c99d828e5 scoop-info: show correct name for shim aliases (fixes #2259) 2018-05-14 20:52:30 +02:00
Chawye Hsu f641f7c8ad Scoop-info: improve output (#2257) 2018-05-13 13:20:28 +02:00
Richard Kuhnt 8c668b7b4d scoop-info: show env_set and env_add_path values 2018-05-04 22:31:35 +02:00
Richard Kuhnt 8d85b58cf4 scoop-info: name app() to parse_app() (#2234) 2018-05-04 21:53:57 +02:00
Richard Kuhnt 70f64c8f4b Refactor app() to parse_app() for better "bucket/app@version" handling (#2234)
It now parses these app names:
- php-bucket/php71-amqp@1.8.0
- php-bucket/php71-amqp
- php71-amqp@1.8.0
- php71-amqp@1.9.0-rc2

Removed:
- is_app_with_specific_version()
- get_app_with_version()
2018-05-04 21:51:43 +02:00
Chawye Hsu cfb628fad2 Add scoop-info command (#2165)
Shows information about an installed app.
- name and description
- version and latest version
- license (with link to spdx.org)
- linked binaries
- shows install notes
- URL or path to manifest
2018-05-04 21:45:47 +02:00
Vladimir Chebotarev 8e1de57b36 Better error handling during uninstallation. (#2079) 2018-05-04 19:08:04 +02:00
Richard Kuhnt 8d8452f21e scoop-config: Small fix for Boolean config values (mentioned in #460)
- `scoop config test $true` (fixed by using `$args[0]` instead of `$args`)
- `scoop config test $false` (fixed by `$null -ne $value`)
2018-05-04 18:46:39 +02:00
Richard Kuhnt 7c427878ea Improve "scoop alias list" output (#2160) (#2163)
* Show command definition trough 'scoop alias list' (closes #2160)

* Add verbose flag to alias list command

* Update alias command help
2018-04-04 17:27:01 +02:00
Richard Kuhnt 942962b818 popd before abort on failed scoop update command 2018-03-30 16:19:35 +02:00
Chawye Hsu ae23c64d34 Resolve linting, fix appveyor tests error 2018-03-22 20:13:03 +08:00
Richard Kuhnt d68cb3ce52 Add config option "show_update_log" (#2133) 2018-03-21 17:10:42 +01:00
Richard Kuhnt f3f559c460 Improve is_scoop_outdated() and add last_scoop_update() 2018-03-21 17:09:11 +01:00
Richard Kuhnt 0daa25c630 Fix update log output 2018-03-21 16:30:49 +01:00
Richard Kuhnt 12962acfa8 Use consistent User-Agent Header on all webrequests 2018-03-18 16:35:01 +01:00
Philippe Crama 91a02ce03d Followup to PR #1918: scoop-virustotal.ps1 fixes (#1934)
* Fix interpretation of response's status code to detect redirections

* Improve documentation of virustotal subcommand

- usage & configuration of virustotal_api_key
- special parameter '*' to test all installed apps
- make necessity of having a virustotal_api_key for --scan explicit
- show that it's possible to check several packages at once

* Never use virustotal_api_key to query if a package is safe

The URL in the code wasn't an API end-point anyway.

* Refactor logic to warn user about apps unknown to VirusTotal

* Warn once when virustotal_api_key's absence prevents VirusTotal submission

This is preparation for changes to come in the package submission logic.

* Use API to submit download link to VirusTotal, rate limited in EAFP fashion

This is a roundabout way to get the file to be scanned without having
to download & upload it ourselves.

Rate limiting is implemented using EAFP: if submission fails, we wait
at least 60s before retrying at most once.

* Color undecided VirusTotal information the same way as `dangerous' files

If the scanning is still in progress, VirusTotal returns 0 malicious,
0 suspicious and 0 undetected.  Err on the safe side and color this
the same way as `dangerous' files.

* Remove requirement to only verify installed apps

The initial use case for this feature was to scan packages to avoid
installing dangerous apps.  Assuming they are infected, we want if
possible to avoid downloading them at all.

* Check dependencies with VirusTotal, too (by default)

* Manually apply `Lint: PSAvoidUsingCmdletAliases' (see e1bb1e91, #2075)

This is to avoid conflicts when merging lukesampson:master

* Explain applist's return value transformation: drop `global' flag for each app

* Move variable declarations and apps list generation to the top

* Reformat code and comply to linted function names

* Reduce nesting, remove hacky hash/url retrieval

* Remove $global variables

* Fix regression bug in Search-VirusTotal()

* Remove applist() because it's irrelevant if app is installed globally
2018-03-14 19:04:18 +01:00
Chawye Hsu 731247876d [Pending] Finally we add the code linting and its tests! (#2108)
* Lint: PSPossibleIncorrectComparisonWithNull

* Lint: PSUseLiteralInitializerForHashtable

* Lint: PSUseBOMForUnicodeEncodedFile

* Lint: PSUseApprovedVerbs

* Lint: PSAvoidGlobalVars

* Lint: PSAvoidUsingEmptyCatchBlock

* Lint: PSUseShouldProcessForStateChangingFunctions

* Lint helper: Add PSScriptAnalyzer integration for vscode

* Fix lint: PSUseBOMForUnicodeEncodedFile

* Tests: ignore previous TestResults.xml

* Tests: add PowerShell script linting into tests!

* Add PSScriptAnalyzer into appveyor ci

* Update Scoop-Linting.Tests.ps1
2018-03-13 14:26:55 +01:00
Vladimir Chebotarev 4d956c2e30 Checked if uninstaller removed its directory. (#2078) 2018-03-12 18:54:58 +01:00
Steve Baker 31075f6200 Clean up some error messages (#2032)
Removes extra 'ERROR' in text where the `error` method is used.
Converts some `write-host "error message"` to use the `error` method
Converts some `write-host "error message"; exit 1` to use the `abort`
method.
2018-03-12 18:32:57 +01:00
Richard Kuhnt 56c35f8f05 Show changelog after updating scoop and buckets 2018-03-11 23:01:06 +01:00
Tres Finocchiaro 16f59b4401 Add scoop prefix command (#2117) 2018-03-11 21:02:10 +01:00
Richard Kuhnt 79bf99c3c1 Also show other applications in PATH with 'scoop which' 2018-03-11 19:53:02 +01:00
Chawye Hsu e1bb1e91d0 Lint: PSAvoidUsingCmdletAliases (#2075) 2018-03-03 18:41:19 +01:00
Richard Kuhnt 7176719501 Improve reset command
Allow resetting:
* global apps
* multiple apps
* all apps by using * parameter (skips global apps if not admin)
2018-02-16 14:34:52 +01:00
Steve Baker eadba0116f Fix: scoop cache command not using $SCOOP_CACHE (#1990) 2018-01-28 23:52:04 +01:00
Richard Kuhnt 43a02b2a3b Add NTFS check to checkup command (#1944) 2018-01-08 14:56:39 +01:00