initial commit
Some checks failed
format / build (push) Failing after 6s

Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
ngn
2025-05-02 18:20:24 +03:00
commit ab580d6a18
17 changed files with 1482 additions and 0 deletions

73
scripts/apply.sh Normal file
View File

@ -0,0 +1,73 @@
#!/bin/bash
BLUE="\e[34m"
YELLOW="\e[33m"
RED="\e[31m"
BOLD="\e[1m"
GREEN="\e[32m"
RESET="\e[0m"
if [ $# -ne 1 ]; then
echo "please specify a patch file"
exit 1
fi
if [ ! -f "${1}" ]; then
echo "specified patch file does not exist"
exit 1
fi
from="$(grep "From: " "${1}" | sed 's/From: //g')"
title="$(grep "Subject: \[PATCH\] " "${1}" | sed 's/Subject: \[PATCH\] //g')"
applied=0
code=0
echo
echo -e "${BOLD}${GREEN}From ${RESET}${BOLD}:${RESET} ${from}"
echo -e "${BOLD}${GREEN}Title${RESET}${BOLD}:${RESET} ${title}"
echo
while true; do
echo -en "${BOLD}(${BLUE}E${RESET}${BOLD})dit "
echo -en "${BOLD}(${BLUE}A${RESET}${BOLD})pply "
[ $applied -eq 1 ] && echo -en "${BOLD}(${BLUE}U${RESET}${BOLD})ndo "
echo -en "${BOLD}(${BLUE}S${RESET}${BOLD})kip "
echo -en "${BOLD}(${BLUE}C${RESET}${BOLD})ancel "
read -s -n1 answer
echo -en "\r \r"
case "${answer,,}" in
"e")
$EDITOR "${1}"
;;
"a")
#git apply --reject --whitespace=fix "${1}" && break
git am --reject --whitespace=fix "${1}" && break
applied=1
;;
"u")
git am --abort
;;
"s")
break
;;
"c")
code=1
break
;;
*)
if [ ! -z "${answer}" ]; then
echo -e "${BOLD}Please enter a valid answer${RESET}"
fi
;;
esac
done
exit $code

43
scripts/check.py Normal file
View File

@ -0,0 +1,43 @@
#!/bin/python3
from ups import log
import ups
def check(dir=".") -> bool:
try:
us = ups.upstream(dir=dir)
except Exception as e:
log.fail("failed to create ups upstream", exception=e)
return False
try:
commits = us.last()
except Exception as e:
log.fail("failed to get commits: %s" % e)
return False
if len(commits) == 0:
log.info("upstream does not have any commits")
return True
last_commit = commits[0]
saved_commit = us.commit()
if saved_commit == "":
log.warn("no commit specified, assuming we are on the latest commit")
us.commit(last_commit)
return False
if saved_commit == last_commit:
log.info("up-to-date with the upstream")
return True
commits = us.until(saved_commit)
log.warn("%d commits behind the upstream" % len(commits))
log.info("run ups-update to pull & apply patches")
return False
if "__main__" == __name__:
exit(0 if check() else 1)

23
scripts/commit.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
if [ ! -f ups.json ]; then
echo "ups.json not found"
exit 1
fi
git add ups.json
if git diff --exit-code --cached &> /dev/null; then
echo "no updates for ups.json"
exit 1
fi
diff=$(git blame ups.json | grep 'Not Committed Yet' | grep '"commit"')
if [ -z "${diff}" ]; then
echo "no updates for ups.json"
exit 1
fi
commit=$(echo "${diff}" | awk '{print $10}' | sed -e 's/"//g' -e 's/,//g')
git commit -m "ups: update to ${commit:0:7}"

56
scripts/update.py Normal file
View File

@ -0,0 +1,56 @@
#!/bin/python3
from ups import log
import ups
def update(dir="."):
try:
us = ups.upstream(dir=dir)
except Exception as e:
log.fail("failed to create ups upstream", exception=e)
return False
commit = us.commit()
if commit == "":
log.fail("no commit specified")
return False
commits = us.until(commit)
commits.reverse()
if len(commits) == 0:
log.info("already up-to-date")
return False
log.info("got total of %d commits" % len(commits))
# attempt to apply all the commits
for i, c in enumerate(commits):
# download the patch for the commit
try:
log.info(
"(%d/%d) downloading patch for %s" % (i + 1, len(commits), c)
)
us.download(c)
except Exception as e:
log.fail("failed to download: %s" % c, exception=e)
return False
# apply the downloaded patch
try:
log.info("(%d/%d) applying patch for %s" % (i + 1, len(commits), c))
us.apply(c)
except Exception as e:
log.fail("failed to apply %s" % c, exception=e)
return False
# update the last commit
us.commit(c)
log.info("now up-to-date with the upstream")
if "__main__" == __name__:
exit(0 if update() else 1)