59 lines
2.9 KiB
Bash
59 lines
2.9 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
source ./config.sh
|
||
|
|
||
|
set -e
|
||
|
|
||
|
# What is needed to "start"?
|
||
|
# it all begins with an upstream repo, which may have submodules, incl. recursively (each represents another repo)
|
||
|
# To facilitate speedy work on this upstream repo, we want to have local clones of these repos
|
||
|
# Next we have a tarball, either that we created from the repo, or that upstream provided
|
||
|
# To alter the content of this tarball, lets use git to track these changes, and produce patches which can be included
|
||
|
# in the package spec file
|
||
|
|
||
|
# The following can get things a bit out of the expected order, but I don't think that is really much of a problem, as long as we're guaranteed to patch the superproject before any of it's submodules
|
||
|
# !!!! actually the simply submodule status --recursive w/out the additional processing we do for the groking of the bundle files
|
||
|
SUBMODULE_COMMIT_IDS=($(git -C ~/git/qemu-opensuse submodule status --recursive|awk '{print $1}'))
|
||
|
SUBMODULE_DIRS=($(git -C ~/git/qemu-opensuse submodule status --recursive|awk '{print $2}'))
|
||
|
SUBMODULE_COUNT=${#SUBMODULE_COMMIT_IDS[@]}
|
||
|
# !!! I should be able to do this with simply math - ie: use (( ... ))
|
||
|
if [[ "$REPO_COUNT" != "$(expr $SUBMODULE_COUNT + 1)" ]]; then
|
||
|
echo "ERROR: submodule count doesn't match the REPO_COUNT variable in config.sh file!"
|
||
|
exit
|
||
|
fi
|
||
|
rm -rf $BUNDLE_DIR
|
||
|
mkdir -p $BUNDLE_DIR
|
||
|
for (( i=0; i <$SUBMODULE_COUNT; i++ )); do
|
||
|
mkdir -p $BUNDLE_DIR/${SUBMODULE_DIRS[$i]}
|
||
|
# what should this file be? for now use an extension of id
|
||
|
touch $BUNDLE_DIR/${SUBMODULE_DIRS[$i]}/${SUBMODULE_COMMIT_IDS[$i]}.id
|
||
|
done
|
||
|
# also handle the superproject (I need to make this smarter, or change something - works for tag, but not normal commit:
|
||
|
|
||
|
GIT_UPSTREAM_COMMIT=$(git -C ~/git/qemu-opensuse show-ref -d $GIT_UPSTREAM_COMMIT_ISH|grep -F "^{}"|awk '{print $1}')
|
||
|
touch $BUNDLE_DIR/$GIT_UPSTREAM_COMMIT.id
|
||
|
|
||
|
# Now go through all the submodule local repos that are present and create a bundle file for the patches found there
|
||
|
rm -rf $GIT_DIR
|
||
|
for (( i=0; i <$REPO_COUNT; i++ )); do
|
||
|
if [[ -e $(readlink -f ${LOCAL_REPO_MAP[$i]}) ]]; then
|
||
|
SUBDIR=${PATCH_PATH_MAP[$i]}
|
||
|
GITREPO_COMMIT_ISH=($BUNDLE_DIR/$SUBDIR*.id)
|
||
|
if [[ $GITREPO_COMMIT_ISH =~ .*(.{40})[.]id ]]; then
|
||
|
GITREPO_COMMIT_ISH=${BASH_REMATCH[1]}
|
||
|
fi
|
||
|
echo "Using $GITREPO_COMMIT_ISH"
|
||
|
PATCH_RANGE_INDEX=$i
|
||
|
mkdir -p $GIT_DIR/$SUBDIR
|
||
|
git -C $GIT_DIR/$SUBDIR init
|
||
|
git -C $GIT_DIR/$SUBDIR remote add origin file://$(readlink -f \
|
||
|
${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
|
||
|
git -C $GIT_DIR/$SUBDIR fetch origin $GIT_BRANCH
|
||
|
git -C $GIT_DIR/$SUBDIR bundle create $BUNDLE_DIR/$SUBDIR$GITREPO_COMMIT_ISH.bundle $GITREPO_COMMIT_ISH..FETCH_HEAD || true
|
||
|
git -C $(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]}) remote get-url origin >$BUNDLE_DIR/$SUBDIR/repo
|
||
|
fi
|
||
|
done
|
||
|
tar cJvf bundles.tar.xz -C $BUNDLE_DIR .
|
||
|
rm -rf $BUNDLE_DIR
|
||
|
rm -rf $GIT_DIR
|