Skip to content

Commit

Permalink
Merge pull request #129 from minetest-whynot/buildscripts_compat
Browse files Browse the repository at this point in the history
fix check-updates.sh and build-mods.sh using new lib-build-whynot.sh
  • Loading branch information
dacmot authored Sep 1, 2022
2 parents 203a3b9 + 0bb1e4d commit d46205f
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 125 deletions.
138 changes: 33 additions & 105 deletions builder/build-mods.sh
Original file line number Diff line number Diff line change
@@ -1,114 +1,42 @@
#!/bin/bash

PROJ="$(realpath $(dirname $0)/..)" # Absolute path
SRC="$PROJ"/builder/mods_src/
DST="$PROJ"/mods/ # Subgame mods
LOG="$PROJ"/mod_sources.txt
GIT="git --no-pager"
GITPARAM="--color=always"
RSYNC="rsync -a --info=NAME --delete --exclude=.git --exclude=.gitignore"

export LC_ALL="C"

! [ -e "$DST" ] && mkdir "$DST"
#######################
### Debugging options
#######################
#export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' # for debugging, uncomment this line and use `bash -cx` below

######################
### Script constants
######################
MODDIR="mods_src"
export PROJ="$(realpath $(dirname $0)/..)" # Absolute path
export SRC="$PROJ"/builder/$MODDIR
export DST="$PROJ"/mods
export LOG="$PROJ"/mod_sources.txt

[[ $VERBOSITY == '--quiet' ]] && QUIETONLY=$VERBOSITY || QUIETONLY=''
[[ $VERBOSITY == '--verbose' ]] && VERBOSEONLY=$VERBOSITY || VERBOSEONLY=''
export QUIETONLY
export VERBOSEONLY

#####################
### Start of script
#####################

source "$PROJ"/builder/lib-build-whynot.sh
cd "$SRC" # for proper resolving the '*'

# Remove old log
rm "$LOG" 2>/dev/null

## Sync minetest_game
# exclude env_sounds => Tenplus1/ambience is used
# exclude farming =>Tenplus1/farming is used
# exclude mtg_craftguide => sfcraftguide is used
# exclude player_api => bell07/player_api_modpack is used

mod_install minetest_game --exclude=farming --exclude=env_sounds --exclude=mtg_craftguide minetest_game/mods/*

mod_install libs

mod_install player --exclude=3d_armor --exclude=smart_sfinv_modpack
mod_install player --exclude=3d_armor_ip --exclude=3d_armor_ui player/3d_armor/*
mod_install player player/smart_sfinv_modpack/*

mod_install ambience

mod_install flora_ores
mod_install mapgen

mod_install tools --exclude=flight --exclude=maidroid

mod_install tools flight/flyingcarpet
mod_install tools maidroid/maidroid*

mod_install decor --exclude=homedecor_modpack --exclude=home_workshop_modpack --exclude=mydoors

mod_install decor decor/homedecor_modpack/building_blocks #grate and marble in recipes
# no computers - I use laptop mod
mod_install decor decor/homedecor_modpack/fake_fire
# no inbox, itemframes
mod_install decor decor/homedecor_modpack/lavalamp
## the homedecor blob was in whynot, therefore applied all at the first
## Next step is to check each mod for whynot rules
# no 3d_extras
mod_install decor decor/homedecor_modpack/homedecor_bathroom
mod_install decor decor/homedecor_modpack/homedecor_bedroom
mod_install decor decor/homedecor_modpack/homedecor_books
mod_install decor decor/homedecor_modpack/homedecor_climate_control
mod_install decor decor/homedecor_modpack/homedecor_clocks
mod_install decor decor/homedecor_modpack/homedecor_cobweb
mod_install decor decor/homedecor_modpack/homedecor_common
mod_install decor decor/homedecor_modpack/homedecor_doors_and_gates
mod_install decor decor/homedecor_modpack/homedecor_electrical
mod_install decor decor/homedecor_modpack/homedecor_electronics
mod_install decor decor/homedecor_modpack/homedecor_exterior
mod_install decor decor/homedecor_modpack/homedecor_fences
mod_install decor decor/homedecor_modpack/homedecor_foyer
mod_install decor decor/homedecor_modpack/homedecor_furniture
mod_install decor decor/homedecor_modpack/homedecor_furniture_medieval
mod_install decor decor/homedecor_modpack/homedecor_gastronomy
mod_install decor decor/homedecor_modpack/homedecor_kitchen
mod_install decor decor/homedecor_modpack/homedecor_laundry
mod_install decor decor/homedecor_modpack/homedecor_lighting
mod_install decor decor/homedecor_modpack/homedecor_misc
mod_install decor decor/homedecor_modpack/homedecor_office
mod_install decor decor/homedecor_modpack/homedecor_pictures_and_paintings
mod_install decor decor/homedecor_modpack/homedecor_plasmascreen
mod_install decor decor/homedecor_modpack/homedecor_roofing
mod_install decor decor/homedecor_modpack/homedecor_seating
mod_install decor decor/homedecor_modpack/homedecor_tables
mod_install decor decor/homedecor_modpack/homedecor_trash_cans
mod_install decor decor/homedecor_modpack/homedecor_wardrobe
mod_install decor decor/homedecor_modpack/homedecor_windows_and_treatments

mod_install decor decor/home_workshop_modpack/home_vending_machines
mod_install decor decor/home_workshop_modpack/home_workshop_misc

mod_install decor decor/mydoors/my_castle_doors
mod_install decor decor/mydoors/my_cottage_doors
mod_install decor decor/mydoors/my_default_doors
mod_install decor decor/mydoors/my_door_wood
mod_install decor decor/mydoors/my_fancy_doors
mod_install decor decor/mydoors/my_future_doors
mod_install decor decor/mydoors/my_hidden_doors
mod_install decor decor/mydoors/my_misc_doors
mod_install decor decor/mydoors/my_old_doors
mod_install decor decor/mydoors/my_old_doors
mkdir -p "$DST"
cd "$SRC"

mod_install food --exclude=food_modpack
# Overwrite old log
>"$LOG"

mod_install food food/food_modpack/food food/food_modpack/food_basic
echo "Process submodules..."
git submodule status | xargs -P 1 -n 3 bash -c 'source "$PROJ"/builder/lib-config-whynot.sh; process_rebuild_mods "$@"' _

mod_install mesecons --exclude=mesecons_lucacontroller \
--exclude=mesecons_commandblock \
--exclude=mesecons_detector \
--exclude=mesecons_fpga \
--exclude=mesecons_gates \
--exclude=mesecons_hydroturbine \
--exclude=mesecons_luacontroller \
--exclude=mesecons_microcontroller \
--exclude=mesecons_stickyblocks \
mesecons/mesecons/*
# Update built-in mods (not submodules)
$RSYNC $SRC/libs/whynot_compat $DST/libs/
git diff --quiet -- $DST/libs/whynot_compat || git commit $VERBOSITY -m "Update whynot_compat" $DST/libs/whynot_compat

mod_install mobs_redo mobs_redo/*
# Finalize mods update by commiting mod_sources.txt
git diff --quiet -- $LOG || git commit $VERBOSITY -m "Update mod_sources.txt" $LOG
30 changes: 13 additions & 17 deletions builder/check-updates.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
#!/bin/bash

PROJ="$(realpath $(dirname $0)/..)" # Subgame dir (..)
######################
### Script constants
######################
MODDIR="mods_src"
export PROJ="$(realpath $(dirname $0)/..)" # Absolute path
export SRC="$PROJ"/builder/$MODDIR

# Repositories points to non-default branch
declare -A BRANCHES=(
[minetest_game]=origin/stable-5 # Stay on stable version
[flora_ores/farming]=0b06c7cd450c5ec9a76b3c22a9c57f06e4f8a7c2 # See https://github.com/minetest-whynot/whynot-game/issues/105
)
#####################
### Start of script
#####################

source "$PROJ"/builder/lib-build-whynot.sh

fgrep path "$PROJ"/.gitmodules | while read _ _ p; do
ls -1 "$PROJ"/.git/modules/"$p"/refs/remotes/*/HEAD | sed 's:.*git/modules/builder/mods_src/::;s:/refs/remotes/: :g' | while read mod branch; do
if [ -n "${BRANCHES[$mod]}" ]; then
branch="${BRANCHES[$mod]}"
fi
cd "$SRC"

echo '**************' "$mod" - "$branch" '***********************'
cd "$PROJ"/builder/mods_src/"$mod"
git fetch
git --no-pager log HEAD.."$branch"
done
done
echo "Check submodules for updates..."
git submodule status | xargs -P 1 -n 3 bash -c 'source "$PROJ"/builder/lib-config-whynot.sh; check_update_mods "$@"' _
63 changes: 63 additions & 0 deletions builder/lib-build-whynot.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[[ -n "$VERBOSITY" ]] && RSYNC_VERBOSITY="$VERBOSITY" || RSYNC_VERBOSITY="--info=NAME"
export RSYNC="rsync -a $RSYNC_VERBOSITY --delete --delete-excluded --exclude=.git*"

function sync_mods_folder {

local subm=$1
Expand Down Expand Up @@ -107,6 +110,66 @@ function process_update_mods {
export -f process_update_mods


function check_update_mods {

local commit=$1
local subm=$2
# ignore local branch=$(echo "$3" | tr -d '()')

cd $subm
echo -n "Checking $subm... "

local branch="origin/HEAD"
if [ ${BRANCHES[$subm]+_} ]; then
branch=${BRANCHES[$subm]}
fi

local modname=$(basename $subm)

git fetch
local current=$(git rev-parse --verify --quiet $branch) #> /dev/null

if [ "$commit" != "$current" ]; then

echo ''
git --no-pager log $commit..$current

else
echo 'No changes.'
fi
}
export -f check_update_mods


function process_rebuild_mods {

local commit=$1
local subm=$2
# ignore local branch=$(echo "$3" | tr -d '()')

cd $subm
echo "Processing $subm... "

local modname=$(basename $subm)

sync_mods_folder $subm $modname
pushd $PROJ > /dev/null
local DSTPATH="$DST/$subm"
if [[ ! -e $DSTPATH ]]; then
local group=$(dirname $subm)
DSTPATH="$DST/$group"
fi

popd &> /dev/null
echo '' >> "$LOG"
echo `git remote -v | grep '\(fetch\)'` >> "$LOG"
git branch --format '%(HEAD) %(objectname) %(subject)' | grep '^[*]' >> "$LOG"
echo "Mod: $subm" >> "$LOG"

}
export -f process_rebuild_mods


declare -a git_repositories
function in_git_repositories {
for entry in "${git_repositories[@]}"; do
Expand Down
4 changes: 1 addition & 3 deletions builder/update_mods.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export PROJ="$(realpath $(dirname $0)/..)" # Absolute path
export SRC="$PROJ"/builder/$MODDIR
export DST="$PROJ"/mods
export LOG="$PROJ"/mod_sources.txt
export DEFAULTBR="origin/HEAD"
export RSYNC="rsync -a $VERBOSITY --delete --delete-excluded --exclude=.git*"

[[ $VERBOSITY == '--quiet' ]] && QUIETONLY=$VERBOSITY || QUIETONLY=''
[[ $VERBOSITY == '--verbose' ]] && VERBOSEONLY=$VERBOSITY || VERBOSEONLY=''
Expand Down Expand Up @@ -69,4 +67,4 @@ echo "Mods have been updated as per your selections."
echo "Please review your commits before pushing using: "
echo ""
echo " git difftool origin/main"
echo ""
echo ""

0 comments on commit d46205f

Please sign in to comment.