123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- #!/usr/bin/env bash
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- REPOHOME="`dirname ~/Projects/Maker/Firmware/.`"
- MARLINREPO="$REPOHOME/MarlinFirmware"
- CONFIGREPO="$REPOHOME/Configurations"
-
- CEXA=config/examples
- CDEF=config/default
- BC=Configuration.h
- AC=Configuration_adv.h
-
- COMMIT_STEPS=0
-
-
-
- ACTION=${1:-init}
- IMPORT=${2:-"import-2.1.x"}
- EXPORT=${3:-"bugfix-2.1.x"}
-
- echo -n "Doing grhh ... " ; grhh ; echo
-
- if [[ $ACTION == "manual" ]]; then
-
-
-
-
-
-
-
- echo "- Updating '$IMPORT' from Marlin..."
-
- git checkout $IMPORT || exit
-
-
-
-
- cp "$MARLINREPO/Marlin/"Configuration*.h "$CDEF/"
-
-
- echo "- Fix up the import branch and come back."
-
- read -p "- Ready to init [y/N] ?" INIT_YES
- echo
-
- [[ $INIT_YES == 'Y' || $INIT_YES == 'y' ]] || { echo "Done." ; exit ; }
-
- ACTION='init'
- fi
-
- if [[ $ACTION == "init" ]]; then
-
-
-
-
-
-
- SED=$(which gsed sed | head -n1)
-
- echo "- Initializing BASE branch..."
-
-
- git checkout $IMPORT || exit
-
-
- TEMP=$( mktemp -d ) ; cp -R config $TEMP
-
-
- IFS=$'\n'; set -f
- for fn in $( find $TEMP/config -type f -name "Configuration.h" ); do
- $SED -i~ -e "20,30{/#error/d}" "$fn"
- rm "$fn~"
- done
- unset IFS; set +f
-
-
- git checkout init-repo >/dev/null 2>&1 || exit
-
-
- git branch -D BASE 2>/dev/null
- git checkout init-repo -b BASE || exit
-
-
- echo "- Copying all configs from fresh $IMPORT..."
- cp -R "$TEMP/config" .
-
-
- find config -type f \! -name "Configuration*" -exec rm "{}" \;
-
-
- ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Commit for comparison" >/dev/null
-
-
- echo "- Initializing configs to default state..."
-
- find "$CEXA" -name $BC -print0 \
- | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
- find "$CEXA" -name $AC -print0 \
- | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done
-
-
- ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset configs..." >/dev/null
-
-
- VERS=$( echo $EXPORT | $SED 's/release-//' )
- eval "${SED} -E -i~ -e 's/%VERSION%/$VERS/g' README.md"
- rm -f README.md~
-
-
- ((COMMIT_STEPS)) || git add . >/dev/null && git commit --amend --no-edit >/dev/null
-
-
- echo "- Creating '$EXPORT' branch for the result..."
- git branch -D $EXPORT 2>/dev/null
- git checkout -b $EXPORT || exit
-
-
- git branch -D BASE 2>/dev/null
-
- echo "- Applying example config customizations..."
- cp -R "$TEMP/config" .
- find config -type f \! -name "Configuration*" -exec rm "{}" \;
-
- echo "- Adding path labels to all configs..."
- config-labels.py >/dev/null 2>&1
-
- git add . >/dev/null && git commit -m "Examples Customizations" >/dev/null
-
- echo "- Copying extras from Marlin..."
- cp -R "$TEMP/config" .
-
-
- config-labels.py >/dev/null 2>&1
-
- git add . >/dev/null && git commit -m "Examples Extras" >/dev/null
-
- rm -rf $TEMP
-
- git push -f --set-upstream upstream "$EXPORT"
-
- else
-
- echo "Usage: mfconfig init|manual|rebase"
-
- fi
|