Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added simplistic nightly support #314

Merged
merged 1 commit into from
Mar 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions lib/install.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
function nightly_version($date) {
$date_str = $date.tostring("yyyyMMdd")
warn "this is a nightly version: downloaded files won't be verified"
"nightly-$date_str"
}

function install_app($app, $architecture, $global) {
$app, $manifest, $bucket, $url = locate $app
$use_cache = $true
$check_hash = $true

if(!$manifest) {
abort "couldn't find manifest for $app$(if($url) { " at the URL $url" })"
Expand All @@ -11,11 +19,17 @@ function install_app($app, $architecture, $global) {
abort "manifest version has unsupported character '$($matches[0])'"
}

$is_nightly = $version -eq 'nightly'
if ($is_nightly) {
$version = nightly_version $(get-date)
$check_hash = $false
}

echo "installing $app ($version)"

$dir = ensure (versiondir $app $version $global)

$fname = dl_urls $app $version $manifest $architecture $dir
$fname = dl_urls $app $version $manifest $architecture $dir $use_cache $check_hash
unpack_inno $fname $manifest $dir
pre_install $manifest
run_installer $fname $manifest $architecture $dir
Expand Down Expand Up @@ -146,7 +160,7 @@ function dl_progress($url, $to, $cookies) {
[console]::setcursorposition($left, $top)
}

function dl_urls($app, $version, $manifest, $architecture, $dir, $use_cache = $true) {
function dl_urls($app, $version, $manifest, $architecture, $dir, $use_cache = $true, $check_hash = $true) {
# can be multiple urls: if there are, then msi or installer should go last,
# so that $fname is set properly
$urls = @(url $manifest $architecture)
Expand All @@ -167,12 +181,14 @@ function dl_urls($app, $version, $manifest, $architecture, $dir, $use_cache = $t

dl_with_cache $app $version $url "$dir\$fname" $cookies $use_cache

$ok, $err = check_hash "$dir\$fname" $url $manifest $architecture
if(!$ok) {
# rm cached
$cached = cache_path $app $version $url
if(test-path $cached) { rm -force $cached }
abort $err
if($check_hash) {
$ok, $err = check_hash "$dir\$fname" $url $manifest $architecture
if(!$ok) {
# rm cached
$cached = cache_path $app $version $url
if(test-path $cached) { rm -force $cached }
abort $err
}
}

$extract_dir = $extract_dirs[$extracted]
Expand Down
8 changes: 7 additions & 1 deletion libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function update($app, $global) {
$old_version = current_version $app $global
$old_manifest = installed_manifest $app $old_version $global
$install = install_info $app $old_version $global
$check_hash = $true

# re-use architecture, bucket and url from first install
$architecture = $install.architecture
Expand All @@ -81,6 +82,11 @@ function update($app, $global) {
$deps | % { install_app $_ $architecture $global }

$version = latest_version $app $bucket $url
$is_nightly = $version -eq 'nightly'
if($is_nightly) {
$version = nightly_version $(get-date)
$check_hash = $false
}

if(!$force -and ($old_version -eq $version)) {
warn "the latest version of $app ($version) is already installed."
Expand Down Expand Up @@ -109,7 +115,7 @@ function update($app, $global) {
save_installed_manifest $app $bucket $dir $url
save_install_info @{ 'architecture' = $architecture; 'url' = $url; 'bucket' = $bucket } $dir

$fname = dl_urls $app $version $manifest $architecture $dir $use_cache
$fname = dl_urls $app $version $manifest $architecture $dir $use_cache $check_hash
unpack_inno $fname $manifest $dir
pre_install $manifest
run_installer $fname $manifest $architecture $dir
Expand Down