Commit 8065234b authored by KatolaZ's avatar KatolaZ

fixed cache on salsa -- variuous fixes on d1h

parent cd52adbf
......@@ -24,6 +24,7 @@ ERR_FILES=64
CGIT_URL="https://anonscm.debian.org/cgit/"
D1H_DIR=${HOME}/.d1h
CACHE_FILE=${D1H_DIR}/cache
CACHE_URL="http://pkgmaster.devuan.org/d1h_cache"
## function
check_git(){
......@@ -37,7 +38,7 @@ check_git(){
## function
check_pending_commits(){
IS_CLEAN=$(git status 2>&1 | grep -c -E "working.+clean")
IS_CLEAN=$(LC_ALL=C git status 2>&1 | grep -c -E "working.+clean")
if [ "${IS_CLEAN}" = "0" ]; then
printf "There are uncommitted changes or untracked files present.\n\
......@@ -59,6 +60,18 @@ check_branch(){
fi
}
## function
check_not_branch(){
BRANCH="$1"
IS_BRANCH=$(git branch --list ${BRANCH} | grep -E "${BRANCH}[ ]*$")
if [ -n "${IS_BRANCH}" ]; then
printf "Branch ${BRANCH} exists!\n"
exit ${ERR_BRANCH}
fi
}
## function
patch_rules_inject(){
......@@ -69,11 +82,19 @@ patch_rules_inject(){
TO_INJECT=""
while read from to; do
TO_INJECT="\tcp $from $to\n${TO_INJECT}"
done < debian/devuan/inject
[ -f debian/devuan/inject ] && {
while read from to; do
TO_INJECT="\tcp $from $to\n${TO_INJECT}"
done < debian/devuan/inject
}
[ -f debian/devuan/remove ] && {
while read file; do
TO_INJECT="\trm $file\n${TO_INJECT}"
done < debian/devuan/remove
}
##echo "TO_INJECT: \n${TO_INJECT}"
[ -z "${TO_INJECT}" ] && echo "nothing to inject/remove" && return
## now we check if debian/rules already has an override_dh_install
HAS_OVERRIDE=$(grep -E -c "^override_dh_install:" debian/rules)
......@@ -93,7 +114,7 @@ patch_rules_inject(){
fi
git add debian/rules
git commit -a -m "Injected files from ${INJECT_BRANCH}"
## Shall we remove the debian/devuan/ folder we checked out?
}
......@@ -253,8 +274,8 @@ handle_cache(){
fi
echo "## $(date)" > "${CACHE_FILE}"
curl "${CGIT_URL}" | parse_alioth >> "${CACHE_FILE}"
##curl "${CGIT_URL}" | parse_alioth >> "${CACHE_FILE}"
curl "${CACHE_URL}" >> "${CACHE_FILE}"
exit $?
}
......@@ -473,6 +494,41 @@ handle_burp(){
}
##
## Initialise an inject-branch
##
## function
handle_inject_init(){
check_git "$0"
get_cur_branch
get_cur_suite
if [ $# -gt 0 ]; then
INJECT_BRANCH="$1"
else
INJECT_BRANCH="${CUR_SUITE}-inject"
fi
check_not_branch "${INJECT_BRANCH}"
if [ -z "${CUR_SUITE}" ]; then
echo "### no suites available -- use 'd1h prepare' to create one ###" >&2
else
echo "Creating inject branch \"${INJECT_BRANCH}\""
git checkout --orphan "${INJECT_BRANCH}"
git rm -rf .
mkdir -p debian/devuan
touch debian/devuan/inject debian/devuan/remove
git add debian
git commit -m "Inject branch created"
git checkout "${CUR_BRANCH}"
fi
}
## try to inject files from the SUITE-inject repo, and to patch
## debian/rules accordingly (and automatically)
......@@ -496,7 +552,7 @@ handle_inject(){
else
## we should import the devuan/ folder from CUR_SUITE-inject
check_branch "${INJECT_BRANCH}"
echo "found branch ${INJECT_BRANCH} -- checking out devuan/"
echo "found branch \"${INJECT_BRANCH}\" -- checking out debian/devuan/"
##git checkout "${INJECT_BRANCH}" devuan/
git checkout "${INJECT_BRANCH}" debian/
......@@ -534,7 +590,7 @@ handle_inject_update(){
## merge the selected tag into the current suite
## stih debian/changelog, if needed
## stitch debian/changelog, if needed
}
......
#!/bin/sh
##
## Get the list of projects from salsa.debian.org and output a file
## usable as a d1h cache
##
SALSA_URL="https://salsa.debian.org/api/v4/projects"
TMPFILE="cur_page"
CACHE_FILE="d1h_cache"
page=1
stop=""
while [ 1 -eq 1 ]; do
printf "Getting page: ${page}..." >&2
curl -s "${SALSA_URL}?order_by=id&sort=asc&per_page=100&page=${page}" > "${TMPFILE}"
[ $? -ne 0 ] && echo "[FAILED]" >&2 && break
stop=$(cat "${TMPFILE}" | grep "^\[\]$")
[ -z "$stop" ] && {
echo "[DONE]" >&2
page=$(($page + 1))
cat "${TMPFILE}" | jq 'map([.path_with_namespace, .http_url_to_repo]) | .[] | join(": ")' | sed 's:\"::g'
}
[ -n "$stop" ] && echo "[EOF]" >&2 && break
done > "${CACHE_FILE}"
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment