Skip to content

Commit 9b3371e

Browse files
committed
builder - only build binaries when newer
Copy retropie.pkg to archive folder named as $md_id.pkg and use this in rp_hasNewerModule if no installed package is found. Adjust the builder code to check for a newer source package to utilise this so we only rebuild binaries as are needed.
1 parent 4709f5a commit 9b3371e

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

scriptmodules/admin/builder.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ function module_builder() {
2626
# eg scraper which fails as go1.8 doesn't work under qemu
2727
hasFlag "${__mod_info[$id/flags]}" "nobin" && continue
2828

29+
# if the module has no install_ function skip to the next module
2930
! fnExists "install_${id}" && continue
3031

31-
# skip already built archives, so we can retry failed modules
32-
[[ -f "$__tmpdir/archives/$__binary_path/${__mod_info[$id/type]}/$id.tar.gz" ]] && continue
32+
# if there is a not a newer version, skip to the next module
33+
! rp_hasNewerModule "$id" "source" && continue
3334

3435
# build, install and create binary archive.
3536
# initial clean in case anything was in the build folder when calling
3637
local mode
37-
for mode in clean remove depends sources build install create_bin clean remove "depends remove"; do
38+
for mode in clean depends sources build install create_bin clean remove "depends remove"; do
3839
# continue to next module if not available or an error occurs
3940
rp_callModule "$id" $mode || break
4041
done
@@ -108,6 +109,6 @@ function chroot_build_builder() {
108109
/home/pi/RetroPie-Setup/retropie_packages.sh builder "$@"
109110
done
110111

111-
rsync -av "$md_build/$dist/home/pi/RetroPie-Setup/tmp/archives/" "$home/RetroPie-Setup/tmp/archives/"
112+
rsync -av --exclude '*.pkg' "$md_build/$dist/home/pi/RetroPie-Setup/tmp/archives/" "$home/RetroPie-Setup/tmp/archives/"
112113
done
113114
}

scriptmodules/packages.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -684,32 +684,37 @@ function rp_installBin() {
684684
function rp_createBin() {
685685
printHeading "Creating binary archive for $md_desc"
686686
687-
if [[ ! -d "$rootdir/$md_type/$md_id" ]]; then
688-
printMsgs "console" "No install directory $rootdir/$md_type/$md_id - no archive created"
687+
if [[ ! -d "$md_inst" ]]; then
688+
printMsgs "console" "No install directory $md_inst - no archive created"
689689
return 1
690690
fi
691691
692-
if dirIsEmpty "$rootdir/$md_type/$md_id"; then
693-
printMsgs "console" "Empty install directory $rootdir/$md_type/$md_id - no archive created"
692+
if dirIsEmpty "$md_inst"; then
693+
printMsgs "console" "Empty install directory $md_inst - no archive created"
694694
return 1
695695
fi
696696
697697
local archive="$md_id.tar.gz"
698698
local dest="$__tmpdir/archives/$__binary_path/$md_type"
699699
mkdir -p "$dest"
700700
rm -f "$dest/$archive" "$dest/$archive.asc"
701+
local ret=1
701702
if tar cvzf "$dest/$archive" -C "$rootdir/$md_type" "$md_id"; then
702703
if [[ -n "$__gpg_signing_key" ]]; then
703704
if signFile "$dest/$archive"; then
704705
chown $user:$user "$dest/$archive" "$dest/$archive.asc"
705-
return 0
706+
ret=0
706707
fi
707708
else
708-
return 0
709+
ret=0
709710
fi
710711
fi
711-
rm -f "$dest/$archive"
712-
return 1
712+
if [[ "$ret" -eq 0 ]]; then
713+
cp "$md_inst/retropie.pkg" "$dest/$md_id.pkg"
714+
else
715+
rm -f "$dest/$archive"
716+
fi
717+
return "$ret"
713718
}
714719
715720
function rp_hasModule() {
@@ -835,6 +840,12 @@ function rp_loadPackageInfo() {
835840
local load=0
836841
local pkg_file="$(rp_getInstallPath $id)/retropie.pkg"
837842
843+
local builder_pkg_file="$__tmpdir/archives/$__binary_path/${__mod_info[$id/type]}/$id.pkg"
844+
# fallback to using package info for built binaries so the binary builder code can update only changed modules
845+
if [[ ! -f "$pkg_file" && -f "$builder_pkg_file" ]]; then
846+
pkg_file="$builder_pkg_file"
847+
fi
848+
838849
# if the pkg file is available, we will load the data in the next loop
839850
[[ -f "$pkg_file" ]] && load=1
840851

0 commit comments

Comments
 (0)