mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
update-component-sha --pkg option
Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
parent
f5a1541e00
commit
a05f612aa4
@ -11,14 +11,14 @@ usage() {
|
|||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
$0 --<mode> <how-to-find> <new-hash>
|
$0 --<mode> <how-to-find> <new-hash>
|
||||||
|
|
||||||
Available modes: --hash and --image
|
Available modes: --hash, --image, --pkg
|
||||||
|
|
||||||
Replace by hash:
|
Replace by hash:
|
||||||
$0 --hash <OLD> <NEW>
|
$0 --hash <OLD> <NEW>
|
||||||
Example: $0 --hash 8675309abcdefg abcdef567899
|
Example: $0 --hash 8675309abcdefg abcdef567899
|
||||||
Will replace all instances of 8675309abcdefg with abcdef567899
|
Will replace all instances of 8675309abcdefg with abcdef567899
|
||||||
|
|
||||||
Replace by image: $0 --image <IMAGE> <NEW>
|
Replace by image:
|
||||||
$0 --image <IMAGE> <NEW>
|
$0 --image <IMAGE> <NEW>
|
||||||
Example: $0 --image linuxkit/foo abcdef567899
|
Example: $0 --image linuxkit/foo abcdef567899
|
||||||
Will tag all instances of linuxkit/foo with abcdef567899
|
Will tag all instances of linuxkit/foo with abcdef567899
|
||||||
@ -26,52 +26,74 @@ Replace by image: $0 --image <IMAGE> <NEW>
|
|||||||
$0 --image <IMAGE>:<NEW> is accepted as a convenient shortcut for cutting
|
$0 --image <IMAGE>:<NEW> is accepted as a convenient shortcut for cutting
|
||||||
and pasting e.g.the output of linuxkit pkg show-tag
|
and pasting e.g.the output of linuxkit pkg show-tag
|
||||||
|
|
||||||
By default, for convenience, if no mode is given (--image or --hash), the first method (--hash) is assumed.
|
Replace by pkg directory:
|
||||||
Thus the following are equivalent:
|
$0 --pkg <PATH/TO/PKG> <NEW>
|
||||||
$0 <OLD> <NEW>
|
Example: $0 --pkg ./pkg/xen-tools
|
||||||
$0 --hash <OLD> <NEW>
|
Will use linuxkit pkg show-tag on the directory ./pkg/xen-tools, and then
|
||||||
|
tag all instances with the result
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateImage() {
|
||||||
|
local image
|
||||||
|
local hash
|
||||||
|
|
||||||
|
case $# in
|
||||||
|
1)
|
||||||
|
image=${1%:*}
|
||||||
|
hash=${1#*:}
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
image=$1
|
||||||
|
hash=$2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
git grep -E -l "[[:space:]]$image:" | grep -v /vendor/ | xargs sed -i.bak -E -e "s,([[:space:]])($image):([^[:space:]]+), $image:$hash,g"
|
||||||
|
}
|
||||||
|
|
||||||
# backwards compatibility
|
# backwards compatibility
|
||||||
if [ $# -eq 2 -a -n "${1%--*}" ]; then
|
if [ $# -eq 2 -a -n "${1%--*}" ]; then
|
||||||
set -- "--hash" "$1" "$2"
|
set -- "--hash" "$1" "$2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# sufficient arguments
|
|
||||||
if [ $# -lt 2 -o $# -gt 3 ] ; then
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# which mode?
|
# which mode?
|
||||||
case "$1" in
|
mode=$1
|
||||||
--hash)
|
shift
|
||||||
if [ $# -ne 3 ] ; then
|
|
||||||
|
case "${mode}" in
|
||||||
|
--hash)
|
||||||
|
if [ $# -ne 2 ] ; then
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
old=$2
|
old=$1
|
||||||
new=$3
|
new=$2
|
||||||
|
|
||||||
git grep -w -l "\b$old\b" | grep -v /vendor/ | xargs sed -i.bak -e "s,$old,$new,g"
|
git grep -w -l "\b$old\b" | grep -v /vendor/ | xargs sed -i.bak -e "s,$old,$new,g"
|
||||||
;;
|
;;
|
||||||
--image)
|
--image)
|
||||||
case $# in
|
if [ $# -lt 1 ] ; then
|
||||||
2)
|
usage
|
||||||
image=${2%:*}
|
exit 1
|
||||||
hash=${2#*:}
|
fi
|
||||||
|
|
||||||
|
updateImage $@
|
||||||
;;
|
;;
|
||||||
3)
|
--pkg)
|
||||||
image=$2
|
if [ $# -ne 1 ]; then
|
||||||
hash=$3
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! -d "$1" ]; then
|
||||||
|
echo "Directory '$1' does not exist"
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
tag=$(linuxkit pkg show-tag $1)
|
||||||
|
updateImage ${tag}
|
||||||
;;
|
;;
|
||||||
esac
|
*)
|
||||||
git grep -E -l "\b$image:" | grep -v /vendor/ | xargs sed -i.bak -E -e "s,$image:([[:xdigit:]]{40}|v[0-9\.]+),$image:$hash,g"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown mode $1"
|
echo "Unknown mode $1"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user