forked from Spark/builder
kek
This commit is contained in:
parent
9409134f5e
commit
8d262d67be
81
repo-clean
Executable file
81
repo-clean
Executable file
|
@ -0,0 +1,81 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
parse_pkg_filename() {
|
||||
declare filename=$1
|
||||
declare -a filename_array
|
||||
|
||||
IFS='-' read -r -a filename_array <<< "$filename"
|
||||
|
||||
for (( i=${#filename_array[@]}; i>=0; i-- )); do
|
||||
printf '%s ' "${filename_array[$i]}"
|
||||
done
|
||||
}
|
||||
|
||||
is_latest() {
|
||||
declare filename=$1 p
|
||||
|
||||
for p in "${latest[@]}"; do
|
||||
if [[ "$filename" == "$p" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
_pacsort() {
|
||||
declare i
|
||||
|
||||
for i in *.pkg.tar.xz; do
|
||||
printf '%s\n' "$i"
|
||||
done | pacsort -f
|
||||
}
|
||||
|
||||
while (( $# )); do
|
||||
case "$1" in
|
||||
-r) flag_rm=1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if ! (( flag_rm )); then
|
||||
if ! [[ -d old ]]; then
|
||||
mkdir -p old || {
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
read -d '' -r -a package_files < <( _pacsort )
|
||||
|
||||
for f in "${package_files[@]}"; do
|
||||
unset revision version end package_name
|
||||
|
||||
read -r end revision version _ < <(parse_pkg_filename "$f")
|
||||
package_name=${f%%-$version-$revision*}
|
||||
|
||||
declare -g -A latest["$package_name"]="$package_name-$version-$revision-$end"
|
||||
done
|
||||
|
||||
for f in ${package_files[@]}; do
|
||||
if is_latest "$f"; then
|
||||
printf '%s is the latest version available\n' "$f"
|
||||
else
|
||||
printf 'Removing: %s\n' "$f"
|
||||
|
||||
if (( flag_rm )); then
|
||||
rm -f "$f" "${f}.sig"
|
||||
else
|
||||
mv "$f" old/
|
||||
|
||||
if [[ -f "${f}.sig" ]]; then
|
||||
mv "${f}.sig" old/
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -d old ]]; then
|
||||
cd old
|
||||
exec bash "$0" -r
|
||||
fi
|
15
repo-sign
Executable file
15
repo-sign
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
for i in *.pkg.*; do
|
||||
if ! [[ "$i" == "${i%.*}.sig" ]]; then
|
||||
if ! [[ -f "${i}.sig" ]]; then
|
||||
unsigned_pkgs+=( "$i" )
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
for i in "${unsigned_pkgs[@]}"; do
|
||||
echo $i
|
||||
gpg --pinentry-mode loopback --passphrase-fd 0 --batch --no-tty --detach-sign --no-armor "$i" < ~/.gnupg/passphrase
|
||||
#gpg --batch --no-tty --detach-sign --no-armor "$i"
|
||||
done
|
49
syntax
Executable file
49
syntax
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
_highlight() {
|
||||
declare -n syn=$1
|
||||
|
||||
if [[ "$syn" ]]; then
|
||||
exec highlight --force --inline-css -f -I -O xhtml -S "$syn" 2>/dev/null
|
||||
else
|
||||
# echo " :cgit: No syntax type provided."
|
||||
exec cat
|
||||
fi
|
||||
}
|
||||
|
||||
file_name=$1
|
||||
file_extension="${file_name##*.}"
|
||||
|
||||
if ! [[ "$file_name" == "$file_extension" ]]; then
|
||||
case "$file_extension" in
|
||||
(md) exec cmark;;
|
||||
(bash|zsh) syntax='sh';;
|
||||
(*) syntax=$file_extension;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$file_name" in
|
||||
(Makefile) syntax='makefile';;
|
||||
(PKGBUILD) syntax='sh';;
|
||||
esac
|
||||
|
||||
# Read and output the first line
|
||||
read -r
|
||||
|
||||
# Set syntax if the first line is a shebang
|
||||
if [[ "$REPLY" =~ ^'#!' ]]; then
|
||||
case "$REPLY" in
|
||||
(*sh) syntax='sh';;
|
||||
(*ruby*) syntax='ruby';;
|
||||
esac
|
||||
fi
|
||||
|
||||
{
|
||||
# Print the first line
|
||||
printf '%s\n' "$REPLY"
|
||||
|
||||
# Read and output everything
|
||||
while read -r; do
|
||||
printf '%s\n' "$REPLY"
|
||||
done
|
||||
} | _highlight syntax
|
Loading…
Reference in New Issue
Block a user