1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gitea_ynh.git synced 2024-09-03 20:36:22 +02:00

handling armv7 bug and migration stuff

This commit is contained in:
OniriCorpe 2023-02-24 19:03:21 +01:00
parent 6081733f39
commit c342c77e78

View file

@ -9,8 +9,12 @@
# Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected.
# Remove this exit command when you are ready to run this Action
# exit 1
update_source_file() {
# Rewrite source file
sed -i "s@SOURCE_URL=.*@SOURCE_URL=$asset_url@" "$path"
sed -i "s@SOURCE_SUM=.*@SOURCE_SUM=$checksum@" "$path"
echo "... $path"
}
#=================================================
# FETCHING LATEST RELEASE AND ITS ASSETS
@ -84,6 +88,7 @@ esac
done
echo "Checksums acquired."
echo "Second loop for processing source files..."
@ -123,15 +128,16 @@ if [ -n "$src" ]; then
filename=${asset_url##*/}
checksum=$(< "$tempdir/$filename.sha256" awk '{print $1;}')
# Rewrite source file
cat <<EOT > "conf/source/$src.src"
SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FILENAME=gitea
SOURCE_EXTRACT=false
EOT
echo "... conf/source/$src.src updated"
path="conf/source/$src.src"
# patching the armv7 file with the armv6 bin version
if [ "$src" = "arm" ]; then
update_source_file
path="conf/source/armv7.src"
update_source_file
else
update_source_file
fi
else
echo "... asset ignored"
@ -139,9 +145,49 @@ fi
done
echo "Upgrade done."
# Delete temporary directory
rm -rf "$tempdir"
last_main_version="${current_version%.*}"
main_version="${version%.*}"
if [ "$last_main_version" != "$main_version" ]; then
echo "Minor or major version number increased, creating migration stuff:"
for i in arm arm64 armv7 i386 x86-64
do
path="conf/source/${i}_${last_main_version}.src"
cp conf/source/"$i".src "$path"
# retrieve the last minor release of the main version
last_main_version_full=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | grep "$last_main_version" | tail -1 | cut -c2-)
# set the checksum file link
if [ "$i" = "arm" ]; then
asset_url="https://github.com/$repo/releases/download/v$last_main_version_full/gitea-$last_main_version_full-linux-arm-6"
elif [ "$i" = "armv7" ]; then
asset_url="https://github.com/$repo/releases/download/v$last_main_version_full/gitea-$last_main_version_full-linux-arm-6"
elif [ "$i" = "arm64" ]; then
asset_url="https://github.com/$repo/releases/download/v$last_main_version_full/gitea-$last_main_version_full-linux-arm64"
elif [ "$i" = "i386" ]; then
asset_url="https://github.com/$repo/releases/download/v$last_main_version_full/gitea-$last_main_version_full-linux-386"
elif [ "$i" = "x86-64" ]; then
asset_url="https://github.com/$repo/releases/download/v$last_main_version_full/gitea-$last_main_version_full-linux-amd64"
fi
# downloading the checksum
echo "Downloading checksum file at" "$asset_url.sha256"
checksum=$(curl --silent -4 -L "$asset_url.sha256" | awk '{print $1;}')
update_source_file
done
echo "Creation of source files for migration completed"
fi
#=================================================
@ -151,15 +197,39 @@ rm -rf "$tempdir"
# Any action on the app's source code can be done.
# The GitHub Action workflow takes care of committing all changes after this script ends.
# WE need to add this
# "1.7."* )
# ynh_setup_source $final_path source/${architecture}_1.8
# restart_gitea
# ;&
# esac
if [ "$last_main_version" != "$main_version" ]; then
echo "Creating the migration steps in the upgrade file"
last_last_version=$(grep 'ynh_setup_source $final_path source/${architecture}_' scripts/upgrade | tail -n1 | grep -Eo '[[:alnum:]]+\.[[:alnum:]]+$')
perl -0777 -pe "s@restart_gitea\n;&\nesac@restart_gitea\n;&\n\"${last_last_version}."'"* )\n ynh_setup_source \$final_path source/\${architecture}_'"${main_version}\n restart_gitea\n;&\nesac@" scripts/upgrade > "$tempdir"/upgrade
mv "$tempdir"/upgrade scripts/upgrade
echo "Migration stuff is done."
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# Delete temporary directory
rm -rf "$tempdir"
# Replace new version in manifest
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
# No need to update the README, yunohost-bot takes care of it
echo "End of script."
# The Action will proceed only if the PROCEED environment variable is set to true
echo "PROCEED=true" >> "$GITHUB_ENV"
exit 0