Skip to content

Commit

Permalink
selfupdate is broken #174 : switch to commits strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Dec 12, 2024
1 parent ab176c6 commit 54b167b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions makesure
Original file line number Diff line number Diff line change
Expand Up @@ -493,17 +493,17 @@ function currentTimeMillis(res){
res=executeGetLine("date +%s%3N")
sub(/%?3N/,"000",res)
return +res}
function selfUpdate(tmp,err,newVer,line,ver){
function selfUpdate(tmp,err,newVer,line,sha){
tmp=executeGetLine("mktemp /tmp/makesure_new.XXXXXXXXXX")
err=dl("https://github.com/xonixx/makesure/releases",tmp)
err=dl("https://github.com/xonixx/makesure/commits/main",tmp)
if(!err){
while(getline line<tmp){
if(match(line,/\/xonixx\/makesure\/releases\/tag\/v[0-9.]+/)){
ver=substr(line=substr(line,RSTART,RLENGTH),index(line,"/v")+1)
if(match(line,/\/xonixx\/makesure\/commits\/[0-9a-z]+/)){
sha=substr(line=substr(line,RSTART,RLENGTH),25)
break}}
if(!ver)err="unable to get the latest release"
if(!sha)err="unable to get the latest commit"
if(!err){
err=dl("https://raw.githubusercontent.com/xonixx/makesure/"ver"/makesure",tmp)
err=dl("https://raw.githubusercontent.com/xonixx/makesure/"sha"/makesure",tmp)
if(!err&&!ok("chmod +x "tmp))err="can'\''t chmod +x "tmp
if(!err){
newVer=executeGetLine(tmp" -v")
Expand Down
14 changes: 7 additions & 7 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -720,21 +720,21 @@ function currentTimeMillis( res) {
return +res
}

function selfUpdate( tmp, err, newVer,line,ver) {
function selfUpdate( tmp, err, newVer,line,sha) {
tmp = executeGetLine("mktemp /tmp/makesure_new.XXXXXXXXXX")
# first get the last release version
err = dl("https://github.com/xonixx/makesure/releases", tmp)
# first get the last commit hash
err = dl("https://github.com/xonixx/makesure/commits/main", tmp)
if (!err) {
while (getline line < tmp) {
if (match(line, /\/xonixx\/makesure\/releases\/tag\/v[0-9.]+/)) {
ver = substr(line = substr(line, RSTART, RLENGTH), index(line, "/v") + 1) # v0.9.23
if (match(line, /\/xonixx\/makesure\/commits\/[0-9a-z]+/)) {
sha = substr(line = substr(line, RSTART, RLENGTH), 25)
break
}
}
if (!ver) err = "unable to get the latest release"
if (!sha) err = "unable to get the latest commit"
if (!err) {
# now download the latest executable
err = dl("https://raw.githubusercontent.com/xonixx/makesure/" ver "/makesure", tmp)
err = dl("https://raw.githubusercontent.com/xonixx/makesure/" sha "/makesure", tmp)
if (!err && !ok("chmod +x " tmp)) err = "can't chmod +x " tmp
if (!err) {
newVer = executeGetLine(tmp " -v")
Expand Down
12 changes: 6 additions & 6 deletions makesure_candidate
Original file line number Diff line number Diff line change
Expand Up @@ -493,17 +493,17 @@ function currentTimeMillis(res){
res=executeGetLine("date +%s%3N")
sub(/%?3N/,"000",res)
return +res}
function selfUpdate(tmp,err,newVer,line,ver){
function selfUpdate(tmp,err,newVer,line,sha){
tmp=executeGetLine("mktemp /tmp/makesure_new.XXXXXXXXXX")
err=dl("https://github.com/xonixx/makesure/releases",tmp)
err=dl("https://github.com/xonixx/makesure/commits/main",tmp)
if(!err){
while(getline line<tmp){
if(match(line,/\/xonixx\/makesure\/releases\/tag\/v[0-9.]+/)){
ver=substr(line=substr(line,RSTART,RLENGTH),index(line,"/v")+1)
if(match(line,/\/xonixx\/makesure\/commits\/[0-9a-z]+/)){
sha=substr(line=substr(line,RSTART,RLENGTH),25)
break}}
if(!ver)err="unable to get the latest release"
if(!sha)err="unable to get the latest commit"
if(!err){
err=dl("https://raw.githubusercontent.com/xonixx/makesure/"ver"/makesure",tmp)
err=dl("https://raw.githubusercontent.com/xonixx/makesure/"sha"/makesure",tmp)
if(!err&&!ok("chmod +x "tmp))err="can'\''t chmod +x "tmp
if(!err){
newVer=executeGetLine(tmp" -v")
Expand Down

0 comments on commit 54b167b

Please sign in to comment.