From 411ba18ef79232063f5a78b39b0ff192613d15e0 Mon Sep 17 00:00:00 2001 From: xonixx Date: Mon, 9 Dec 2024 23:46:41 +0200 Subject: [PATCH] selfupdate is broken #174 : update master makesure to let selfupdate test work --- makesure | 30 +++++++++++++++++++----------- makesure_candidate | 30 +++++++++++++++++++----------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/makesure b/makesure index e2bb572..7afc024 100755 --- a/makesure +++ b/makesure @@ -493,20 +493,28 @@ function currentTimeMillis(res){ res=executeGetLine("date +%s%3N") sub(/%?3N/,"000",res) return +res} -function selfUpdate(url,tmp,err,newVer){ - url="https://raw.githubusercontent.com/xonixx/makesure/main/makesure?token="rand() +function selfUpdate(tmp,err,newVer,line,sha){ tmp=executeGetLine("mktemp /tmp/makesure_new.XXXXXXXXXX") - err=dl(url,tmp) - if(!err&&!ok("chmod +x "tmp))err="can'\''t chmod +x "tmp + err=dl("https://api.github.com/repos/xonixx/makesure/commits?per_page=1",tmp) if(!err){ - newVer=executeGetLine(tmp" -v") - if(Version!=newVer){ - if(!ok("cp "tmp" "quoteArg(Prog))) - err="can'\''t overwrite "Prog - else print"updated "Version" -> "newVer - }else print"you have latest version "Version" installed"} + while(getline line "newVer + }else print"you have latest version "Version" installed"}}} rm(tmp) - if(err)die(err)} + if(err)die(err"\nPlease use manual update: https://makesure.dev/Installation.html")} function renderDuration(deltaMillis,\ deltaSec,deltaMin,deltaHr,deltaDay,dayS,hrS,minS,secS,secSI,res){ deltaSec=deltaMillis/1000 diff --git a/makesure_candidate b/makesure_candidate index e2bb572..7afc024 100755 --- a/makesure_candidate +++ b/makesure_candidate @@ -493,20 +493,28 @@ function currentTimeMillis(res){ res=executeGetLine("date +%s%3N") sub(/%?3N/,"000",res) return +res} -function selfUpdate(url,tmp,err,newVer){ - url="https://raw.githubusercontent.com/xonixx/makesure/main/makesure?token="rand() +function selfUpdate(tmp,err,newVer,line,sha){ tmp=executeGetLine("mktemp /tmp/makesure_new.XXXXXXXXXX") - err=dl(url,tmp) - if(!err&&!ok("chmod +x "tmp))err="can'\''t chmod +x "tmp + err=dl("https://api.github.com/repos/xonixx/makesure/commits?per_page=1",tmp) if(!err){ - newVer=executeGetLine(tmp" -v") - if(Version!=newVer){ - if(!ok("cp "tmp" "quoteArg(Prog))) - err="can'\''t overwrite "Prog - else print"updated "Version" -> "newVer - }else print"you have latest version "Version" installed"} + while(getline line "newVer + }else print"you have latest version "Version" installed"}}} rm(tmp) - if(err)die(err)} + if(err)die(err"\nPlease use manual update: https://makesure.dev/Installation.html")} function renderDuration(deltaMillis,\ deltaSec,deltaMin,deltaHr,deltaDay,dayS,hrS,minS,secS,secSI,res){ deltaSec=deltaMillis/1000