mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-09 15:37:56 -05:00
130 lines
4.3 KiB
Bash
Executable File
130 lines
4.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Overview:
|
|
#
|
|
# A script to upload binaries to sourceforge.net and add or update package file binaries.
|
|
#
|
|
# Usage:
|
|
#
|
|
# bash ./sf.sh [package1 package2 ...]
|
|
#
|
|
# If no packages are provided, all packages with binaries in release/* will be processed.
|
|
#
|
|
# Directory structure:
|
|
#
|
|
# release/armv7l/*.tar.xz(.sha256) binary tarball and sha256 files for armv7l
|
|
# release/i686/*.tar.xz(.sha256) binary tarball and sha256 files for i686
|
|
# release/x86_64/*.tar.xz(.sha256) binary tarball and sha256 files for x86_64
|
|
#
|
|
# Author: Ed Reel (uberhacker) edreel at gmail dot com
|
|
# Contact me if you would like access to the repository.
|
|
#
|
|
# Updated: 2021-04-14
|
|
#
|
|
# License: GPL-3+
|
|
|
|
packages=
|
|
if test $1; then
|
|
for package in $@; do
|
|
pkgfile="../packages/${package}.rb"
|
|
if [ -f ${pkgfile} ]; then
|
|
packages+=" ${package}"
|
|
else
|
|
echo "Package ${pkgfile} not found."
|
|
fi
|
|
done
|
|
else
|
|
packages=$(find ../release -type f -exec basename -s .tar.xz.sha256 {} + | cut -d'-' -f1 | sort | uniq | xargs)
|
|
fi
|
|
[ -z "${packages}" ] && echo "No packages found." && exit 1
|
|
|
|
function update_url () {
|
|
if sed -e '/binary_url.*({/,/})/p; d' ../packages/$1.rb | grep -q $2:; then
|
|
sed -e "/$2:.*\(http\|https\|ftp\):/c\ \ \ \ $(printf %7s $2): '$3'," -i ../packages/$1.rb
|
|
else
|
|
sed -e "/binary_url.*({/a\ \ \ \ $(printf %7s $2): '$3'," -i ../packages/$1.rb
|
|
fi
|
|
}
|
|
|
|
function update_sha256 () {
|
|
if sed -e '/binary_sha256.*({/,/})/p; d' ../packages/$1.rb | grep -q $2:; then
|
|
sed -e "/$2:.*['\"][0-9a-f]*['\"]/c\ \ \ \ $(printf %7s $2): '$3'," -i ../packages/$1.rb
|
|
else
|
|
sed -e "/binary_sha256.*({/a\ \ \ \ $(printf %7s $2): '$3'," -i ../packages/$1.rb
|
|
fi
|
|
}
|
|
|
|
for package in ${packages}; do
|
|
for arch in x86_64 i686 armv7l; do
|
|
echo "Package: ${package}, Arch: ${arch}"
|
|
pkgfile=../packages/${package}.rb
|
|
old_url="$(grep -m 3 ${arch}: ${pkgfile} 2> /dev/null | head -n 1 | cut -d\' -f2 | tr -d \' | tr -d \" | sed 's/,//g')"
|
|
if [ -n "${old_url}" ]; then
|
|
old_sha256="$(grep -m 3 ${arch}: ${pkgfile} 2> /dev/null | tail -n 1 | cut -d\' -f2 | tr -d \' | tr -d \" | sed 's/,//g')"
|
|
tarfile="$(basename ${old_url})"
|
|
noname="${tarfile#*-}"
|
|
old_version="${noname%-chromeos*}"
|
|
fi
|
|
new_tarfile="$(ls ../release/${arch}/${package}-*-chromeos-${arch}.tar.xz 2> /dev/null | head -1)"
|
|
if [ -z "${new_tarfile}" ]; then
|
|
echo "../release/${arch}/${package}-#-chromeos-${arch}.tar.xz not found."
|
|
echo
|
|
continue
|
|
fi
|
|
new_sha256file="$(ls ../release/${arch}/${package}-*-chromeos-${arch}.tar.xz.sha256 2> /dev/null | head -1)"
|
|
if [ -z "${new_sha256file}" ]; then
|
|
echo "${new_tarfile}.sha256 not found."
|
|
echo
|
|
continue
|
|
else
|
|
new_sha256=$(cut -d' ' -f1 ${new_sha256file})
|
|
fi
|
|
noname="${new_tarfile#*-}"
|
|
new_version="${noname%-chromeos*}"
|
|
new_url=$(echo "https://downloads.sourceforge.net/project/chromebrew/${new_tarfile}" | sed 's,../release/,,')
|
|
echo "Uploading ${new_tarfile}..."
|
|
scp ${new_tarfile} chromebrew@frs.sourceforge.net:/home/frs/project/chromebrew/${arch}/
|
|
if [ -n "${old_url}" ]; then
|
|
if [[ ${old_url} != ${new_url} ]]; then
|
|
echo "Updating binary_url in ${pkgfile}..."
|
|
echo "from: ${arch}: '${old_url}'"
|
|
echo " to: ${arch}: '${new_url}'"
|
|
sed -i "s,${old_url},${new_url},g" ${pkgfile}
|
|
echo "Updating binary_sha256 in ${pkgfile}.."
|
|
echo "from: ${arch}: '${old_sha256}'"
|
|
echo " to: ${arch}: '${new_sha256}'"
|
|
sed -i "s,${old_sha256},${new_sha256},g" ${pkgfile}
|
|
else
|
|
echo "Skipping update in ${pkgfile}..."
|
|
fi
|
|
else
|
|
if ! grep -q binary_url ../packages/${package}.rb; then
|
|
sed -e '/source_sha256/ a\
|
|
\
|
|
\ \ binary_url ({\
|
|
\ \ })\
|
|
\ \ binary_sha256 ({\
|
|
\ \ })' -i ../packages/${package}.rb
|
|
fi
|
|
echo "Adding binary_url to ${pkgfile}..."
|
|
echo "${arch}: '${new_url}'"
|
|
echo "Adding binary_sha256 to ${pkgfile}..."
|
|
echo "${arch}: '${new_sha256}'"
|
|
case x${new_url} in
|
|
x) ;;
|
|
*)
|
|
update_url ${package} ${arch} ${new_url}
|
|
update_sha256 ${package} ${arch} ${new_sha256}
|
|
case ${arch} in
|
|
armv7l)
|
|
update_url ${package} aarch64 ${new_url}
|
|
update_sha256 ${package} aarch64 ${new_sha256}
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
fi
|
|
echo
|
|
done
|
|
done
|