in ,

jaemk / self_update, Hacker News

jaemk / self_update, Hacker News
                    

        

Build statusBuild statusBuild status Build Status Build Statuscrates.io:clincrates.io:clincrates.io:clindocs

self_update docs Provides updaters for updating rust executables in-place from various release distribution backends. docs Usage

Update (replace) the current executable with the latest release downloaded from https://api.github.com/repos/jaemk/self_update/releases/latest . Note, the , crates.io:clin trust project provides a nice setup for producing release-builds via CI (travis / appveyor). docs

# [macro_use] (extern)

 crate crates.io:clin self_update;   fn  crates.io:clindocs () ->  (Result)  Box  ()      let  (status)=(self_update)  ::  backends  ::  (github) ::  (Update)  ::  configure 
 ()         . 
 repo_owner crates.io:clin (
 "jaemk" 
         . 
 repo_name docs (
 “self_update” 
         .  bin_name docs  ( “self_update_example” 
         .  show_download_progress crates.io:clin () 
 (true)          .  current_version docs ( cargo_crate_version!  ())         .  build crates.io:clin ()?         .  crates.io:clin () ?;      println! docs (
, status.  (version)  ());      Ok  (()) }  Build Status

Run the above example to see docs self_update

in action: cargo run --example github docs

Amazon S3 is also supported as the backend to check for new releases. Provided a bucket_name and asset_prefix string, self_update will look up all matching files using the following format as a convention for the filenames: - - . Any file not matching the format, or not matching the provided prefix string, is be ignored. docs

(fn

  crates.io:clin () ->  
   {      let  (status)=(self_update)  ::  backends  ::  (s3) ::  (Update)  ::  configure 
 ()         .  bucket_owner  (
 “self_update_releases” 
         .  asset_prefix docs (
 “self_update” 
         . 
 region crates.io:clin  ( eu- west-2 "
         .  bin_name docs  ( “self_update_example” 
         .  show_download_progress crates.io:clin () 
 (true)          .  current_version docs ( cargo_crate_version!  ())         .  build crates.io:clin ()?         .  crates.io:clin () ?;      println! docs ()  S3 Update status: `{}`! '' 
, status.  (version)  ());      Ok  (()) } #  fn crates.io:clin ()  main) () {}  <::std::error::error>

Separate utilities are also exposed: docs

extern
 
 crate   self_update;   fn  crates.io:clindocs () ->  (Result)  Box  ()      let  releases =(self_update)  ::  backends  ::  (github) ::  (ReleaseList)  ::  configure 
 ()         . 
 repo_owner crates.io:clin (
 "jaemk" 
         . 
 repo_name docs (
 “self_update” 
         .  build crates.io:clin ()?         . 
 fetch crates.io:clin () ?;      println! docs () 
 found releases : "
;      println! docs () ({ {: #?}   n  
, releases);       // get the first available release       let  (asset)=releases [0]         . 
 asset_for  () (

& self_update docs : get_target ()). unwrap ();     

let (tmp_dir=(self_update) (:: TempDir) ::
 ::  (std)  ::  (env) ::  current_dir 
 () ?,  "self_update" 
) ?;      let  (tmp_tarball_path 
=(tmp_dir.) (path 
 ().  (join) (

asset.name);     

let (tmp_tarball
= ::  (std) :: ::  (fs) ::  (File)  :: , (open)  (  tmp_tarball_path) ?;      self_update  :: :: (Download 
 :: 
 (from_url) ( & 

asset.download_url)         .

 download_to  () (

& (tmp_tarball) ?;     

let (bin_name
=(std)  ::  path  ::   PathBuf   ::  (from 
);     self_update  :: ::  Extract  :: 
 (from_source) ( &  tmp_tarball_path)         . 
 archive crates.io:clin (self_update 
 :: 
 ArchiveKind docs :  (Tar) ( Some  (self_update   ::  (Compression) :: ::  Gz)))         .  extract_file  () (

& (tmp_dir.) (path) (), &

bin_name) ?;      let (tmp_file)=(tmp_dir.) (path
 ().  (join) (
 “replacement_tmp” );      let  bin_path=(tmp_dir.) (path 
 ().  (join)  (bin_name);     self_update  :: :: (Move 
 :: 
 (from_source) ( &  bin_path)         .  replace_using_temp docs () (

& (tmp_file)         . to_dest docs () (

& (::
 std  ::  (env) ::   current_exe 
 ()?) ?;       Ok  (()) } 

Build Status

License: MIT docs

   Build Status

(Read More)

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

XIX.ai jobs, Hacker News

XIX.ai jobs, Hacker News

DOJ sues US telecom providers for connecting Indian robocall scammers, Ars Technica

DOJ sues US telecom providers for connecting Indian robocall scammers, Ars Technica