On 16.06.19 10:34, Thomas Morley wrote:
You might want to kill the git daemon after building lilypond. Or you might
want systemd to start the git daemon whenever the machine boots.
I don't know how to do any of above, could you give me some hints?
Attached is a quickshot bash script gubllb.
Execute the script with three arguments, the
gub directory, the directory of the lilypond
repository you want to use, and the branch
you want to build, e.g.:
gubllb /home/gub/gubĀ /home/gub/lily testbranch
Obviously you need to make the script
executable. You might put it somewhere
in your path.
Knut
#!/bin/bash
GITEXEC=`which git`
echo "gubllb --- GUB Local Lilypond Build"
# abort if not exactly 3 arguments are provided
if [ $# -ne 3 ]; then
echo "ERROR: invalid number of command line arguments!"
echo "USAGE: gubllb gub_directory lilypond_repository_directory
lilypond_branch"
exit 1
fi
GUBDIR=$1
LILYREPODIR=$2
LILYBRANCH=$3
echo "Trying to build branch '$LILYBRANCH' of local lilypond repository
'$LILYREPODIR' with gub '$GUBDIR'"
# abort if a git-daemon is active
ps ax | grep git-daemon | grep -v grep | grep git-daemon
if [ $? -eq 0 ]; then
echo "ERROR: A git-daemon is already running on this system!"
exit 1
fi
# abort if GUBDIR parameter is invalid
if [ ! -f "$GUBDIR/bin/gub" ]; then
echo "ERROR: gub_directory parameter '$GUBDIR' invalid!"
exit 1
fi
# abort if LILYREPODIR parameter is invalid
if [ ! -f "$LILYREPODIR/lily/lilypond-version.cc" ]; then
echo "ERROR: lilypond_repository_directory '$LILYREPODIR' invalid!"
exit 1
fi
# abort if there is no branch LILYBRANCH in LILYREPODIR
cd $LILYREPODIR
TESTOUT=`git branch --list $LILYBRANCH | grep -o $LILYBRANCH`
if [ "$TESTOUT" != "$LILYBRANCH" ]; then
echo "ERROR: lilypond branch '$LILYBRANCH'does not exist in '$LILYREPODIR' !"
exit 1
fi
# create a temporary git server directory in GUBDIR, abort if this fails
TMPSRVDIR=$(mktemp -d -t -p $GUBDIR/ gubllb-XXXXXXXXXX)
if [ ! -d "$TMPSRVDIR" ]; then
echo ERROR: We failed to created the directory $TMPSRVDIR!
exit 1
else
echo Temporary git daemon directory is $TMPSRVDIR
fi
# create the lilypong.git link in TMPSRVDIR
ln -s $LILYREPODIR $TMPSRVDIR/lilypond.git
# start git-daemon in the background
$GITEXEC daemon --log-destination=none --export-all --reuseaddr
--base-path=$TMPSRVDIR/ $TMPSRVDIR &> /dev/null &
GITPID=$!
echo Started git daemon with PID $GITPID
# wait until git-daemon starts to provide its service ... abort if this does
not occur within a reasonable time
i=0
while [ $i -le 10 ]
do
((i++))
echo Waiting for git daemon ...
TESTOUT=`git ls-remote git://localhost/lilypond.git $LILYBRANCH 2>&1 | grep
-o refs/heads/$LILYBRANCH`
if [ "$TESTOUT" == "refs/heads/$LILYBRANCH" ]; then
break;
fi
if [ $i -eq 10 ]; then
echo ERROR: Git daemon timed out or $LILYBRANCH does not exist!
kill -n 9 -- $(ps -o pid= --ppid $GITPID)
rm -rf $TMPSRVDIR
exit 1
fi
sleep 1
done
# everything seems to be ok, build LILYBRANCH
cd $GUBDIR
make LILYPOND_REPO_URL=git://localhost/lilypond.git LILYPOND_BRANCH=$LILYBRANCH
lilypond
# kill our git daemon and remove our temporary git server directory
kill -n 9 -- $(ps -o pid= --ppid $GITPID)
rm -rf $TMPSRVDIR
_______________________________________________
lilypond-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-devel