[prev in list] [next in list] [prev in thread] [next in thread]
List: flightgear-devel
Subject: [Flightgear-devel] Fwd: download_and_compile.sh and Git repositories
From: wkitty42 () gmail ! com
Date: 2019-11-29 14:14:34
Message-ID: 22a778cc-fdef-4389-8fa5-a8190e98a372 () gmail ! com
[Download RAW message or body]
-------- Forwarded Message --------
Subject: download_and_compile.sh and Git repositories
Date: Fri, 29 Nov 2019 13:37:48 +0100
From: Florent Rougon <f.rougon@free.fr>
To: wkitty42@gmail.com
Hi,
[trim irrelevant to dnc discussion]
B) Regarding what you wrote on the list (I looked at the list archive):
> if i can figure out how to jump back to FG 2019.1 or even 2018.3, i'll
> give it another go but since i use the dnc script to build with, this is
> not so easy a task to do... at least it doesn't appear to be but it
> should be as easy as specifying the branch or tag to check out of the
> repo and build it... the question is where to specify the branch or tag
> in the script...
You should just open the script and read:
#######################################################
# SIMGEAR
#######################################################
SIMGEAR_INSTALL_DIR=simgear
INSTALL_DIR_SIMGEAR="$INSTALL_DIR/$SIMGEAR_INSTALL_DIR"
cd "$CBD"
if _elementIn "SIMGEAR" "${WHATTOBUILD[@]}"; then
_printLog "****************************************"
_printLog "**************** SIMGEAR ***************"
_printLog "****************************************"
mkdir -p "simgear"
cd "$CBD"/simgear
_gitDownload SIMGEAR
_gitUpdate "$FGVERSION"
if [ "$RECONFIGURE" = "y" ]; then
cd "$CBD"
mkdir -p build/simgear
cd "$CBD"/build/simgear
rm -f CMakeCache.txt
...
Ditto for the FLIGHTGEAR component.
So, if you manually 'git checkout' a specific branch or commit in your
dnc-downloaded repositories, the potentially problematic guys are the
_gitDownload() and _gitUpdate() functions defined in d&c.sh:
function _gitUpdate(){
if [ "$DOWNLOAD" != "y" ]; then
return
fi
...
}
function _gitDownload(){
local component="$1"
local clone_arg
if [ "$DOWNLOAD" != "y" ]; then
return
fi
...
}
Thus, as long as "$DOWNLOAD" != "y", _gitDownload() and _gitUpdate() do
nothing. Looking earlier in the script, you'll see:
while true; do
case "$1" in
-s) STABLE="STABLE"; shift ;;
-a) APT_GET_UPDATE="$2"; shift 2 ;;
-c) COMPILE="$2"; shift 2 ;;
-p) DOWNLOAD_PACKAGES="$2"; shift 2 ;;
-d) DOWNLOAD="$2"; shift 2 ;;
...
so, it's option -d that sets $DOWNLOAD. By passing -dn, you ensure that
"$DOWNLOAD" != "y" and therefore your local repositories won't be touched
by d&c.sh.
Summary
=======
1) Do a 'cd' to go to the repository root (managed by d&c.sh) for SG, FG
or whatever component you want to test at a specific commit, tag or
branch.
2) Manually change the contents of the working directory:
git checkout <commit-id>
or
# A tag is essentially a fancy name for a commit, so this really is
# the same as above
git checkout <tag>
or
# This checks out the tip of the branch (aka, its HEAD) according to
# the state of the repo on your system. This doesn't download
# anything. This can change the current branch.
git checkout <branch>
3) Repeat steps 1) and 2) for any other component you want to test at
some commit that is not "the current state of 'next'".
4) Run d&c.sh with at least option -dn and, as non-option arguments, the
components you want to build (e.g., SIMGEAR, FGFS, etc.). d&c.sh
tries to be helpful, therefore if you only mention the FGFS
component, it will first work on SIMGEAR too, by default: this is due
to "inter-component dependencies". If you want d&c.sh to work exactly
on the specified components (thus, ignoring inter-component
dependencies), use option --ignore-intercomponent-deps.
5) Do whatever tests you need to do.
[ If you need to change code manually, that's okay, but then you'll
have to restore the working directory to the state resulting from
the checkout operation performed in step 1. Otherwise, Git will
refuse to switch to another branch or commit when you later ask it
to, in order not to lose your local changes. How to do so?
- You can run 'git status' and 'git diff' to see the local changes
and revert them manually.
- You can run 'git reset --hard' to restore the working directory
to the state of the last commit that was checked out (presumably,
the commit, tag or branch from step 1). This throws away your
local changes to the working directory.
- If you want to save local changes "elsewhere" and restore the
working directory to the state of the last commit that was
checked out, you can use 'git stash'. This saves a diff of your
local changes on a stack located inside the .git directory. You
can later apply these changes to the working directory with 'git
stash apply' or 'git stash pop'. The latter also removes the
saved diff from the aforementioned stack. In case you try to
apply saved changes to a *different commit*, this will work as
long as the diff still applies fine. If it doesn't, you'll have a
conflict, and will have to either resolve it or give up on the
changes you were trying to apply. ]
6) Restore the working directories to the expected branches: for each
directory (root of a Git repository) where you did steps 1) and 2),
'cd' there and run:
git checkout @{-1}
This checks out the last branch or commit that was checked out before
the current one. Thus, if the repository was previously on 'next',
this is equivalent to:
git checkout next
If something doesn't work in step 6 (presumably because you made local
changes inside a repository, for instance by adding test code in step
5), use 'git status' to get useful informations. If you are sure you
want to throw away the local changes, you can force the checkout of a
particular commit or branch using:
git reset --hard <commit-id-or-branch-name>
(You can omit <commit-id-or-branch-name> in order to restore the working
directory to the state of the last commit that was checked out.)
Hope this helps; you can forward this to the list.
Regards
--
Florent
.
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic