Commit cd52adbf authored by KatolaZ's avatar KatolaZ

changed injection

parent 7db03596
......@@ -71,7 +71,7 @@ patch_rules_inject(){
TO_INJECT=""
while read from to; do
TO_INJECT="\tcp $from $to\n${TO_INJECT}"
done < devuan/inject
done < debian/devuan/inject
##echo "TO_INJECT: \n${TO_INJECT}"
......@@ -84,18 +84,49 @@ patch_rules_inject(){
echo "\noverride_dh_install:\n\tdh_install\n${TO_INJECT}" >> debian/rules
else
## debian/rules already has an override_dh_install:
## (hence, we must put out commends after the last command in override_dh_install)
## (hence, we must put our commands after the last command in override_dh_install)
echo "has_override"
OLD_OVERRIDE=$(sed -n -e '/override_dh_install:/,/^$/p' debian/rules | grep -v "^$" )
sed -r -i -e '/override_dh_install:/,/^$/d' debian/rules
echo "\n${OLD_OVERRIDE}" >> debian/rules
echo "${TO_INJECT}" >> debian/rules
fi
git add devuan
git add debian/rules
git commit -a -m "Injected files from ${INJECT_BRANCH}"
}
## simple stitching of debian/changelog due to a merge of a new
## upstream version on a devuanised package (basically, just remove
## the offending lines starting with "<<<<<<<" and ">>>>>>>" and
## replace the line containing "=======" with an empty one
## function
stitch_changelog(){
### (KatolaZ) PRIZE: It MUST be possible to do the same with a
### single awk/sed spell. I would pay a beer to whoever does it in
### a single awk/sed command
TMPFILE=$(tempfile)
### take the version from upstream
echo "$(sed -r -n -e '/^======.*$/,/^>>>>>>.*$/p' debian/changelog | \
grep -v '^=====' | grep -v '^>>>>>>')" > ${TMPFILE}
echo >> $TMPFILE
## then stitch the version from the devuanised package
echo "$(sed -r -n -e "/^<<<<<<<.*$/,/^======.*/p" debian/changelog | \
sed -r -e '/^<<<<<<.*$/d;s/^======.*$//g' )" >> $TMPFILE
### then print the rest of the file
echo "$(sed -r -e '/^<<<<<.*$/,/^>>>>>.*$/d' debian/changelog)" >> $TMPFILE
mv ${TMPFILE} debian/changelog
}
##
## Check if debian/gbp.conf exists for the current suite, otherwise
## recreate it and commit
......@@ -116,11 +147,24 @@ ignore-branch=True
EOF
git add debian/gbp.conf
git commit -m "re-creating debian/gbp.conf for suite ${SUITE}"
echo "[= suite \"${CUR_BRANCH}\" ready =]" >&2
echo "[= suite \"${SUITE}\" ready =]" >&2
fi
}
## function
get_cur_branch(){
CUR_BRANCH=$(git branch | grep -E "^\*" | cut -d " " -f 2)
}
## function
get_cur_suite(){
CUR_SUITE=$(git branch | grep -E "^\*" | cut -d " " -f 2 | sed -r -e "s/^suites\///g")
}
##
## Import a new package (e.g., from alioth)
......@@ -252,7 +296,8 @@ handle_prepare(){
SUITE=suites/$1
CUR_BRANCH=$(git branch | grep -E "^\*" | cut -d " " -f 2)
##CUR_BRANCH=$(git branch | grep -E "^\*" | cut -d " " -f 2)
get_cur_branch
HAS_SUITE=$(git branch | grep -c -E " ${SUITE}$")
if [ "${HAS_SUITE}" != 0 ]; then
......@@ -267,13 +312,12 @@ handle_prepare(){
fi
git checkout "${SUITE}" 1>&2 2>/dev/null
cat <<EOF > debian/gbp.conf
[DEFAULT]
debian-branch=${SUITE}
EOF
ensure_gbp_conf
git add --all
git commit -m "creating suite ${SUITE}"
echo "[= suite \"${CUR_BRANCH}\" ready =]" >&2
echo "[= suite \"${SUITE}\" ready =]" >&2
git checkout "${CUR_BRANCH}"
exit 0;
}
......@@ -294,8 +338,8 @@ handle_switch(){
git checkout "${SUITE}" 1>&2 2>/dev/null
RET=$?
CUR_BRANCH=$(git branch | grep -E "^\*" | cut -d " " -f 2 | sed -r -e "s/^suites\///g")
echo "[ switched to suite: ${CUR_BRANCH} ]" >&2
get_cur_suite
echo "[ switched to suite: ${CUR_SUITE} ]" >&2
exit $RET
......@@ -375,10 +419,9 @@ handle_stage(){
git tag "${PKG_VERSION}"
CUR_SUITE=$(git branch | grep -E "^\*" | cut -d " " -f 2)
get_cur_branch
git push --set-upstream origin "${CUR_SUITE}"
git push --set-upstream origin "${CUR_BRANCH}"
git push --tags
}
......@@ -398,8 +441,9 @@ handle_suites(){
## function
handle_current(){
CUR_SUITE=$(git branch | grep -E "^\*" | cut -d " " -f 2 | sed -r -e 's:^suites/::g')
##CUR_SUITE=$(git branch | grep -E "^\*" | cut -d " " -f 2 | sed -r -e 's:^suites/::g')
get_cur_suite
if [ -z "${CUR_SUITE}" ]; then
echo "### no suites available -- use 'd1h prepare' to create one ###" >&2
......@@ -437,16 +481,23 @@ handle_inject(){
check_git "$0"
CUR_SUITE=$(git branch | grep -E "^\*" | cut -d " " -f 2 | sed -r -e 's:^suites/::g')
##CUR_SUITE=$(git branch | grep -E "^\*" | cut -d " " -f 2 | sed -r -e 's:^suites/::g')
get_cur_suite
if [ $# -gt 0 ]; then
INJECT_BRANCH="$1"
else
INJECT_BRANCH="${CUR_SUITE}-inject"
fi
if [ -z "${CUR_SUITE}" ]; then
echo "### no suites available -- use 'd1h prepare' to create one ###" >&2
else
## we should import the devuan/ folder from CUR_SUITE-inject
INJECT_BRANCH="${CUR_SUITE}-inject"
check_branch "${INJECT_BRANCH}"
echo "found branch ${INJECT_BRANCH} -- checking out devuan/"
git checkout "${INJECT_BRANCH}" devuan/
##git checkout "${INJECT_BRANCH}" devuan/
git checkout "${INJECT_BRANCH}" debian/
patch_rules_inject "${INJECT_BRANCH}"
......@@ -455,6 +506,39 @@ handle_inject(){
}
## function
handle_inject_update(){
## check that we are on the top dir of a git repo
check_git "$0"
## check that we are in a suite
##CUR_SUITE=$(git branch | grep -E "^\*" | cut -d " " -f 2 | sed -r -e 's:^suites/::g')
get_cur_suite
if [ -z "${CUR_SUITE}" ]; then
echo "### no suites available -- use 'd1h prepare' to create one ###" >&2
return ${ERR_BRANCH}
fi
## check that there are no pengind commits
check_pending_commits
## check that we are trying to update to a newer version,
## otherwise abort
##
## so:
##
## - checkout the named branch
## - extract version number from changelog
## - compare with the current version number
## merge the selected tag into the current suite
## stih debian/changelog, if needed
}
## function
show_usage(){
......@@ -478,6 +562,7 @@ show_usage(){
echo " bump - assign a new version to the current suite"
echo " testbuild - build the package in the current suite"
echo " stage - prepare the package for the CI pipeline"
echo " inject - inject files"
echo
echo "See the d1h(1) manual page for more information"
......@@ -561,6 +646,10 @@ case "$1" in
shift 1
handle_inject "$@"
;;
inject-update)
shift 1
handle_inject_update "$@"
;;
*)
echo "Unknown command: $1"
exit ${ERR_PARAM};
......
......@@ -154,10 +154,14 @@ to origin. This command must be run every time the package changes
version number, and before a build for the new version is initiated.
.El
.It Ic inject
.It Ic inject Op Ar branch_name
inject files in the current suite. In particular, checkout the folders
"debian" and "devuan" from the branch "SUITE-inject" and
inject/remove files as necessary.
"debian" and "devuan" from
.Em branch_name
(or from the branch "SUITE-inject", if
.Em branch_name
is not provided) and inject/remove files as necessary. It is
important that the
.Sh FILES
......
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