Bug 1809569 - pt1 - add new fast-forward state directory. r=ng DONTBUILD

- automatically create state directory (.moz-fast-forward) under top level or repo if missing
- automatically create log and tmp subdirectories if missing
- only execute use_config_env.sh once in nested scripts
- move default location for config_env under state directory

Differential Revision: https://phabricator.services.mozilla.com/D166492
This commit is contained in:
Michael Froman 2023-01-23 21:05:56 +00:00
parent 730eb55729
commit abc1e98d4e
2 changed files with 53 additions and 2 deletions

View file

@ -35,6 +35,7 @@ compile_commands\.json
^\.clang-tidy ^\.clang-tidy
^\.mozconfig ^\.mozconfig
^mozconfig* ^mozconfig*
^\.moz-fast-forward
^old-configure$ ^old-configure$
^config\.cache$ ^config\.cache$
^config\.log$ ^config\.log$

View file

@ -1,10 +1,28 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="dom/media/webrtc/third_party_build" # Assume that if STATE_DIR is already defined, we do not need to
# execute this file again.
if [ "x$STATE_DIR" != "x" ]; then
# no need to run script since we've already run
return
fi
export SCRIPT_DIR="dom/media/webrtc/third_party_build"
# first, make sure we're running from the top of moz-central repo
if [ ! -d $SCRIPT_DIR ]; then
echo "Error: unable to find directory $SCRIPT_DIR"
exit 1
fi
# Should we tie the location of the STATE_DIR to the path
# in MOZ_CONFIG_PATH? Probably.
export STATE_DIR=`pwd`/.moz-fast-forward
export LOG_DIR=$STATE_DIR/logs
export TMP_DIR=$STATE_DIR/tmp
# Allow user to override default path to config_env # Allow user to override default path to config_env
if [ "x$MOZ_CONFIG_PATH" = "x" ]; then if [ "x$MOZ_CONFIG_PATH" = "x" ]; then
MOZ_CONFIG_PATH=~/config_env MOZ_CONFIG_PATH=$STATE_DIR/config_env
echo "Using default MOZ_CONFIG_PATH=$MOZ_CONFIG_PATH" echo "Using default MOZ_CONFIG_PATH=$MOZ_CONFIG_PATH"
fi fi
@ -19,6 +37,36 @@ if [ ! -f $MOZ_CONFIG_PATH ]; then
fi fi
source $MOZ_CONFIG_PATH source $MOZ_CONFIG_PATH
if [ ! -d $STATE_DIR ]; then
echo "Creating missing $STATE_DIR"
mkdir -p $STATE_DIR
if [ ! -d $STATE_DIR ]; then
echo "error: unable to find (or create) $STATE_DIR"
exit 1
fi
fi
echo "Using STATE_DIR=$STATE_DIR"
if [ ! -d $LOG_DIR ]; then
echo "Creating missing $LOG_DIR"
mkdir -p $LOG_DIR
if [ ! -d $LOG_DIR ]; then
echo "error: unable to find (or create) $LOG_DIR"
exit 1
fi
fi
echo "Using LOG_DIR=$LOG_DIR"
if [ ! -d $TMP_DIR ]; then
echo "Creating missing $TMP_DIR"
mkdir -p $TMP_DIR
if [ ! -d $TMP_DIR ]; then
echo "error: unable to find (or create) $TMP_DIR"
exit 1
fi
fi
echo "Using TMP_DIR=$TMP_DIR"
function find_base_commit() function find_base_commit()
{ {
# read the last line of README.moz-ff-commit to retrieve our current base # read the last line of README.moz-ff-commit to retrieve our current base
@ -33,6 +81,7 @@ function find_base_commit()
MOZ_LIBWEBRTC_BASE=`cd $MOZ_LIBWEBRTC_SRC ; git rev-parse --short $MOZ_LIBWEBRTC_BASE` MOZ_LIBWEBRTC_BASE=`cd $MOZ_LIBWEBRTC_SRC ; git rev-parse --short $MOZ_LIBWEBRTC_BASE`
echo "adjusted MOZ_LIBWEBRTC_BASE: $MOZ_LIBWEBRTC_BASE" echo "adjusted MOZ_LIBWEBRTC_BASE: $MOZ_LIBWEBRTC_BASE"
} }
export -f find_base_commit
function find_next_commit() function find_next_commit()
{ {
@ -41,3 +90,4 @@ function find_next_commit()
git log --oneline --ancestry-path $MOZ_LIBWEBRTC_BASE^..$MOZ_TARGET_UPSTREAM_BRANCH_HEAD \ git log --oneline --ancestry-path $MOZ_LIBWEBRTC_BASE^..$MOZ_TARGET_UPSTREAM_BRANCH_HEAD \
| tail -2 | head -1 | awk '{print $1;}'` | tail -2 | head -1 | awk '{print $1;}'`
} }
export -f find_next_commit