-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
Add Forgejo to dietpi-software #7071
base: dev
Are you sure you want to change the base?
Conversation
Many thanks. Linking the request discussion: #6133
It does not.
Nope, but I think it is not required. While common it is (should be) optional, an SSH server is pre-installed on DietPi, and in the |
dietpi/dietpi-software
Outdated
esac | ||
|
||
local fallback_url="https://codeberg.org/forgejo/forgejo/releases/download/v7.0.2/forgejo-7.0.2-linux-$arch.xz" | ||
Download_Install "$(curl -sSfL 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/latest' | jq '.' | mawk -F\" "/\"browser_download_url\": \".*\/forgejo-[^\"\/]*-linux-$arch\.xz\"/{print \$4}")" /mnt/dietpi_userdata/forgejo/forgejo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an alternative to jg
, mawk
could loop through all fields, until it finds one which matches the URL pattern. I can write that, if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familiar with awk, but I found a manual, I am looking into it. https://www.gnu.org/software/gawk/manual/gawk.html
I could not use the gitea awk command because the json from github is readable https://api.github.com/repos/go-gitea/gitea/releases/latest, while the codeberg/forgejo api returns a single string. https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/latest
https://codeberg.org/api/swagger#/repository/repoGetLatestRelease
I can find the fields I need with
curl -sSfL 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/latest' | mawk -F: -v RS=, '$1~/"browser_download_url"/'
but there are some tweaks to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
curl -sSfL 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/latest' | mawk -F:\" -v RS=, '/"browser_download_url":".*\/forgejo-[^\"\/]*-linux-arm64\.xz"/{gsub("\"|}| ]","",$2);print $2}'
I will update the file and test it, please let me know if I can improve the regex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be working now.
I also added a line to start Forgejo after the installation is done. systemctl status
was showing it as inactive before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the "loop through fields" I actually meant something like this:
curl -sSfL 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/latest' | mawk -F\" "{for(i=NF;i>0;i--) if(\$i~/^https:.*linux-$arch\.xz$/) {print \$i;exit}}"
But changing the record delimiter isn't a bad idea either. Running some tests, it seems to perform slightly faster. Can be simplified a little:
curl -sSfL 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/latest' | mawk -v RS=, -F\" "/^\"browser_download_url\":\".*-linux-$arch\.xz\"/{print \$4;exit}"
Since every key: value
pair must be separated by comma, no need to worry about additional "
. And no need to separate fields by "
as well as :
, then removing all "
to effectively use :
as field separator only. Just use "
only 😉.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is brilliant, it also solves the problem with the closing brackets.
It is also faster, I guess removing the gsub
and adding the exit
statement helps with that.
Thanks for the guidance.
I tested it here and updated the code.
It works similar to Gitea. The docs can be reused.
#6133
1 - I need to confirm if
jq
comes with dietpi. It was on mine, but my installation is ancient, and I do not remember.I used it to get the release url from the codeberg repo, as the returning json is different from github used by gitea. Line [10662]
2 - I wonder if there are any tags for
ssh server
dependencies like 'browser' show inhttps://github.com/MichaIng/DietPi/wiki/How-to-add-a-new-software-title#asoftware_depssoftware_id
I noticed that there is also Dropbear besides OpenSSH.