mirror of
https://github.com/DaoCloud/public-image-mirror.git
synced 2025-08-08 18:18:55 +08:00
Update image match
This commit is contained in:
44
hack/fmt-image-match.sh
Executable file
44
hack/fmt-image-match.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function check_match() {
|
||||
local image=$1
|
||||
local lines=$2
|
||||
for line in ${lines}; do
|
||||
if [[ "${line}" == *"**" ]]; then
|
||||
if [[ "${image}" == "${line%\*\*}"* ]]; then
|
||||
return
|
||||
fi
|
||||
elif [[ "${line}" == *"*" ]]; then
|
||||
if [[ "${image}" == "${line%\*}"* ]]; then
|
||||
if [[ "${image#"${line%\*}"}" != *"/"* ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${image}"
|
||||
}
|
||||
|
||||
function format() {
|
||||
local file=$1
|
||||
local lines="$(cat "${file}")"
|
||||
for line in ${lines}; do
|
||||
if [[ "${line}" != *"*" ]]; then
|
||||
check_match "${line}" "${lines}"
|
||||
fi
|
||||
done
|
||||
|
||||
for line in ${lines}; do
|
||||
if [[ "${line}" == *"*" ]]; then
|
||||
echo ${line}
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
export LC_ALL=C
|
||||
file=$1
|
||||
|
||||
format "${file}" |
|
||||
sort -u |
|
||||
grep -v '^$' >$1.tmp && mv $1.tmp $1
|
9
hack/verify-image-match.sh
Executable file
9
hack/verify-image-match.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export LC_ALL=C
|
||||
|
||||
cp $1 $1.bak
|
||||
|
||||
$(dirname "${BASH_SOURCE}")/fmt-image-match.sh $1.bak
|
||||
|
||||
diff -c $1 $1.bak && rm $1.bak
|
Reference in New Issue
Block a user