diff options
author | madmonkey1907 <madfkingmonkey@gmail.com> | 2017-02-15 03:19:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-15 03:19:08 +0300 |
commit | a0212c8736ca75a374a088dcbb4c9443b6429366 (patch) | |
tree | 16c631fc2117a14131e87a2104bb6e5385fb4442 | |
parent | 47b5a7c2009d04978dcf8ad0fd3236a304755012 (diff) | |
parent | 98fded14be707708d474e9cbc49cb82c8e4cab0f (diff) |
Merge pull request #19 from ClusterM/master
It's alive!
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit | 7 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/b0010_functions | 7 | ||||
-rw-r--r-- | mod/hakchi/script/games | 26 | ||||
-rw-r--r-- | mod/hakchi/script/install | 2 | ||||
-rw-r--r-- | mod/hakchi/script/package | 4 | ||||
-rw-r--r-- | mod/hakchi/script/transfer | 4 |
6 files changed, 30 insertions, 20 deletions
diff --git a/mod/hakchi/rootfs/etc/preinit b/mod/hakchi/rootfs/etc/preinit index 6c543a1..99ec8f1 100644 --- a/mod/hakchi/rootfs/etc/preinit +++ b/mod/hakchi/rootfs/etc/preinit @@ -3,6 +3,7 @@ rand(){ } source_parts(){ + [ -z "$temppath" ] && local temppath=/tmp local script=$temppath/script_$(rand) rm -f "$script" for i in $(find $(dirname "$1") -maxdepth 1 -path "$1" | sort); do @@ -27,6 +28,10 @@ source_base(){ source_parts "$preinitpath/b????_*" return 0 fi + if [ -d "$rootfs/etc/preinit.d" ]; then + source_parts "$rootfs/etc/preinit.d/b????_*" + return 0 + fi if [ -d "/etc/preinit.d" ]; then source_parts "/etc/preinit.d/b????_*" return 0 @@ -48,6 +53,8 @@ script_init(){ } preinit(){ + mkdir -p /tmp + [ -z "$gamepath" ] && [ -d "/newroot" ] && /bin/busybox --install -s /bin/ && cp $rootfs/bin/rsync /bin source_base source_parts "$preinitpath/p????_*" } diff --git a/mod/hakchi/rootfs/etc/preinit.d/b0010_functions b/mod/hakchi/rootfs/etc/preinit.d/b0010_functions index 0445eab..2e96d9d 100644 --- a/mod/hakchi/rootfs/etc/preinit.d/b0010_functions +++ b/mod/hakchi/rootfs/etc/preinit.d/b0010_functions @@ -35,6 +35,11 @@ copy(){ rsync -ac "$1" "$2" } +copy_mask(){ + # this function is unsafe, avoid spaces in filenames! + rsync -ac $1 "$2" +} + restore(){ copy "$mountpoint$1" "$rootfs$1" } @@ -61,7 +66,7 @@ overmount_games(){ local menu_code=000 [ -f "$installpath/menu" ] && menu_code=$(cat "$installpath/menu") [ -z "$menu_code" ] && menu_code=000 - echo Menu code: $menu_code + echo menu code: $menu_code if [ "$menu_code" == "000" ]; then overmount "$gamepath" else diff --git a/mod/hakchi/script/games b/mod/hakchi/script/games index 4e3c64c..157033f 100644 --- a/mod/hakchi/script/games +++ b/mod/hakchi/script/games @@ -1,16 +1,16 @@ transfer_original_games(){ [ -d "$1" ] || return 1 - echo Transfering original games... + echo transfering original games... # Using temporary directory for original games tmp_games=/tmp/original_games mkdir -p "$tmp_games" - copy "$mountpoint$gamepath/CLV-*" "$tmp_games" + copy_mask "$mountpoint$gamepath/CLV-*" "$tmp_games" # Patching games to use our wrapper - find $tmp_games/* -name *.desktop -exec sed -i -e 's/clover-kachikachi/clover-kachikachi-wr/g' {} + + find $tmp_games -name *.desktop -exec sed -i -e 's/\/usr\/bin\/clover-kachikachi/\/bin\/clover-kachikachi-wr/g' {} + # We need to decide game distination directory, so we can't just copy all games at once for dir in $tmp_games/*; do if [ -d $dir ]; then - code=`echo $dir | sed "s/.*\///"` + code=$(basename "$dir") # File "hidden" contains list of unwanted original games, so we need to check it if [ -f $1/hidden ] && grep -q $code $1/hidden; then echo $code is hidden @@ -20,17 +20,17 @@ transfer_original_games(){ if [ -f "$1/gpath-$code" ]; then dist=`cat "$1/gpath-$code"` mkdir -p "$tmp_games/$dist" - echo Moving $code to $dist folder + echo moving $code to $dist folder mv "$tmp_games/$code" "$tmp_games/$dist" rm "$1/gpath-$code" else - echo There is no path file for $code, moved to root + echo there is no path file for $code, moved to root fi fi fi done # Now we can write games to flash - copy "$tmp_games/*" "$target_dir" + copy_mask "$tmp_games/*" "$target_dir" rm -rf "$tmp_games" rm -rf "$1" } @@ -40,8 +40,8 @@ transfer_games(){ target_dir=$rootfs$gamepath # Flag to remove all installed games if [ -f "$1/clear" ]; then - echo Removing games... - rm -rf $target_dir/CLV-* + echo removing games and subfolders... + rm -rf $target_dir/CLV-* $target_dir/??? rm "$1/clear" fi mkdir -p "$target_dir" @@ -49,9 +49,9 @@ transfer_games(){ restore "$gamepath/title.fnt" restore "$gamepath/copyright.fnt" transfer_original_games "$1/original" - echo Transfering new games... - # This is simple - copy "$1/*" "$target_dir" - # Need to reset menu state + echo transfering new games... + # this is simple + copy_mask "$1/*" "$target_dir" + # need to reset menu state rm -f $installpath/menu } diff --git a/mod/hakchi/script/install b/mod/hakchi/script/install index c258e6d..9c9f059 100644 --- a/mod/hakchi/script/install +++ b/mod/hakchi/script/install @@ -9,7 +9,7 @@ mod_repair(){ restore "/etc/clover/" restore "/etc/issue" rm -f "$modpath/rootfs/etc/preinit.d/p0000_config" - chown -R root:root $modpath/ + chown -R 0:0 $modpath/ chmod 755 $modpath/rootfs/bin/* copy "$modpath/rootfs/" "$rootfs/" copy "/bin/" "$rootfs/bin/" diff --git a/mod/hakchi/script/package b/mod/hakchi/script/package index 3d1e691..e7e2997 100644 --- a/mod/hakchi/script/package +++ b/mod/hakchi/script/package @@ -52,9 +52,7 @@ pack_install(){ cd "$transferpath" find . -type l -exec echo rm -f \"\$installpath/{}\" + >> "$transferpath/uninstall" find . -type f -exec echo rm -f \"\$installpath/{}\" + >> "$transferpath/uninstall" - find . -depth -type d -exec echo rmdir \"\$installpath/{}\" + >> "$transferpath/uninstall" - sed -i "s#rmdir \"\$installpath/\.\"#echo#" "$transferpath/uninstall" - sed -i "s#\"\$installpath/\.#\"\$installpath#" "$transferpath/uninstall" + find . -depth -mindepth 1 -type d -exec echo rmdir \"\$installpath/{}\" + >> "$transferpath/uninstall" [ $(stat -c%s "$transferpath/uninstall") -gt 8 ] || rm -f "$transferpath/uninstall" fi cd / diff --git a/mod/hakchi/script/transfer b/mod/hakchi/script/transfer index e58c6cd..ca6d81e 100644 --- a/mod/hakchi/script/transfer +++ b/mod/hakchi/script/transfer @@ -20,8 +20,8 @@ fi local transferpath=$modpath/transfer -packs_uninstall $(cat "$transferpath/uninstall") -packs_uninstall $(cat "$transferpath/hmod/uninstall") +[ -f "$transferpath/uninstall" ] && packs_uninstall $(cat "$transferpath/uninstall") +[ -f "$transferpath/hmod/uninstall" ] && packs_uninstall $(cat "$transferpath/hmod/uninstall") packs_install "$transferpath" if [ -d "$transferpath/hmod" ]; then |