Skip to content

Instantly share code, notes, and snippets.

@nwidger
Created March 10, 2022 15:55
Show Gist options
  • Save nwidger/59ff61eab7339161129e269d7d12d399 to your computer and use it in GitHub Desktop.
Save nwidger/59ff61eab7339161129e269d7d12d399 to your computer and use it in GitHub Desktop.
Script to ease updating delve package in OpenWrt package repository
#!/bin/bash
set -e
pkg_version=
branch=master
remote=https://github.com/nwidger/packages.git
case $# in
1)
pkg_version=$1
;;
2)
pkg_version=$1
branch=$2
;;
3)
pkg_version=$1
branch=$2
remote=$3
;;
*)
name=`basename $0`
echo "Usage: $name <delve-version> [<git-branch-name>] [<git-remote-name>]"
echo ""
echo "Examples:"
echo " $name 1.7.2"
echo " $name 1.7.2 master"
echo " $name 1.7.2 master https://github.com/foo/packages.git"
echo " $name 1.7.2 openwrt-21.02"
echo " $name 1.7.2 openwrt-21.02 https://github.com/foo/packages.git"
exit 1
;;
esac
tmpdir1=$(mktemp -d)
source_path=$tmpdir1/delve-v${pkg_version}.tar.gz
curl -sf https://codeload.github.com/go-delve/delve/tar.gz/v${pkg_version} > $source_path
pkg_hash=$(sha256sum $source_path | awk '{ print $1 }')
rm -rf $tmpdir2
tmpdir2=$(mktemp -d)
git clone -q --branch=$branch https://github.com/openwrt/packages.git $tmpdir2
cd $tmpdir2
git remote add fork $remote
newbranch=delve-$pkg_version
if [ "$branch" != "master" ];
then
newbranch=$newbranch-$branch
fi
git checkout -q -b $newbranch
delve_makefile=devel/delve/Makefile
sed -i -e "s/PKG_VERSION:=.*/PKG_VERSION:=${pkg_version}/g" $delve_makefile
sed -i -e "s/PKG_HASH:=.*/PKG_HASH:=${pkg_hash}/g" $delve_makefile
git add $delve_makefile
title="delve: Update to $pkg_version"
if [ "$branch" != "master" ];
then
title="[$branch] $title"
fi
git_name=$(git config user.name)
git_email=$(git config user.email)
git commit -q -m "$title
See https://github.com/go-delve/delve/blob/master/CHANGELOG.md for
changes.
Signed-off-by: $git_name <$git_email>"
git push fork $newbranch
cd /
rm -rf $tmpdir2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment