diff options
author | madmonkey <madfkingmonkey@gmail.com> | 2017-02-14 22:16:33 +0300 |
---|---|---|
committer | madmonkey <madfkingmonkey@gmail.com> | 2017-02-14 22:16:33 +0300 |
commit | 41088ca218237f1a9c7fbcc3e395fbbd48b4a8c5 (patch) | |
tree | a29edf3aae610f4441f5970c4da988a6ee9e5fc3 | |
parent | d82a0f329a6cda413d07fda9e58a449a2c438602 (diff) | |
parent | 65131d9e1cf61fac3effb73e28861988d0145feb (diff) |
Merge branch 'ClusterM-master'
-rw-r--r-- | mod/hakchi/rootfs/bin/chmenu | 34 | ||||
-rw-r--r-- | mod/hakchi/rootfs/bin/clover-kachikachi-wr | 10 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit | 2 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/p0000_config | 2 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/p7100_preinit | 6 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/pa100_games | 12 | ||||
-rw-r--r-- | mod/hakchi/script/base | 17 | ||||
-rw-r--r-- | mod/hakchi/script/games | 57 | ||||
-rw-r--r-- | mod/hakchi/script/install | 14 | ||||
-rw-r--r-- | mod/hakchi/script/package | 34 | ||||
-rw-r--r-- | mod/hakchi/script/transfer | 15 | ||||
-rw-r--r-- | mod/hakchi/script/transfer-first | 47 | ||||
-rw-r--r-- | mod/hakchi/script/transfer-gui | 71 | ||||
-rw-r--r-- | mod/hakchi/script/transfer-last | 13 |
14 files changed, 177 insertions, 157 deletions
diff --git a/mod/hakchi/rootfs/bin/chmenu b/mod/hakchi/rootfs/bin/chmenu new file mode 100644 index 0000000..f333c26 --- /dev/null +++ b/mod/hakchi/rootfs/bin/chmenu @@ -0,0 +1,34 @@ +#!/bin/sh +installpath=/var/lib/hakchi +rootfs=$installpath/rootfs +gamepath=$rootfs/usr/share/games/nes/kachikachi +state_file=$installpath/menu + +[ -z "$1" ] && exit 0 +prev_code=$(cat "$state_file") +[ "$1" == "$prev_code" ] && exit 0 + +echo Switching to menu $1 +if [ "$1" == "000" ]; then + targetpath=$gamepath +else + targetpath=$gamepath/$1 +fi + +[ -d "$targetpath" ] || exit 1 +echo $1 > "$state_file" + +echo New directory: $targetpath +if [ ! -f "$targetpath/title.fnt" ]; then + ln -s "$gamepath/title.fnt" "$targetpath/title.fnt" +fi +if [ ! -f "$targetpath/copyright.fnt" ]; then + ln -s "$gamepath/copyright.fnt" "$targetpath/copyright.fnt" +fi + +pkill -KILL clover-mcp +pkill -KILL ReedPlayer-Clover + +umount -f /usr/share/games/nes/kachikachi +mount -o bind "$targetpath" /usr/share/games/nes/kachikachi +clover-mcp diff --git a/mod/hakchi/rootfs/bin/clover-kachikachi-wr b/mod/hakchi/rootfs/bin/clover-kachikachi-wr new file mode 100644 index 0000000..26b2996 --- /dev/null +++ b/mod/hakchi/rootfs/bin/clover-kachikachi-wr @@ -0,0 +1,10 @@ +#!/bin/sh +# Wrapper for kachikachi +# You can add extra command line arguments to all games at once +# using "cfg_nes_extra_args" variable in p0000_config +# or disable epilepsy protection using "cfg_disable_armet=y" + +source /etc/preinit.d/p0000_config +args="$@ $cfg_nes_extra_args" +[ "$cfg_disable_armet" == "y" ] && args="$(echo $args | sed 's/--enable-armet//g')" +exec /usr/bin/clover-kachikachi $args diff --git a/mod/hakchi/rootfs/etc/preinit b/mod/hakchi/rootfs/etc/preinit index 6a34c2a..2b8216f 100644 --- a/mod/hakchi/rootfs/etc/preinit +++ b/mod/hakchi/rootfs/etc/preinit @@ -9,7 +9,9 @@ source_parts(){ cat "$i" >> "$script" done source "$script" + local ret=$? rm -f "$script" + return $ret } preinit(){ diff --git a/mod/hakchi/rootfs/etc/preinit.d/p0000_config b/mod/hakchi/rootfs/etc/preinit.d/p0000_config index a42f68d..e4faab6 100644 --- a/mod/hakchi/rootfs/etc/preinit.d/p0000_config +++ b/mod/hakchi/rootfs/etc/preinit.d/p0000_config @@ -1,4 +1,6 @@ cfg_boot_stock_firmware='n' cfg_boot_stock='n' cfg_clovercon_option='' +cfg_disable_armet='y' +cfg_nes_extra_args='--ppu-palette 2' cfg_savecheck='n' diff --git a/mod/hakchi/rootfs/etc/preinit.d/p7100_preinit b/mod/hakchi/rootfs/etc/preinit.d/p7100_preinit index 6f6fd9b..61336e1 100644 --- a/mod/hakchi/rootfs/etc/preinit.d/p7100_preinit +++ b/mod/hakchi/rootfs/etc/preinit.d/p7100_preinit @@ -1,7 +1,7 @@ overmount_all(){ - overmount /bin - overmount /etc - overmount "$gamepath" + overmount "/bin" + overmount "/etc" + overmount "/usr/bin" } [ "$cfg_boot_stock" == "y" ] || overmount_all diff --git a/mod/hakchi/rootfs/etc/preinit.d/pa100_games b/mod/hakchi/rootfs/etc/preinit.d/pa100_games new file mode 100644 index 0000000..76a88a0 --- /dev/null +++ b/mod/hakchi/rootfs/etc/preinit.d/pa100_games @@ -0,0 +1,12 @@ +overmount_games(){ + local menu_code=000 + [ -f "$installpath/menu" ] && menu_code=$(cat "$installpath/menu") + echo Menu code: $menu_code + if [ "$menu_code" == "000" ]; then + overmount "$gamepath" + else + overmount "$rootfs$gamepath/$menu_code" "$gamepath" + fi +} + +[ "$cfg_boot_stock" == "y" ] || overmount_games diff --git a/mod/hakchi/script/base b/mod/hakchi/script/base index 4047ef7..b0c2819 100644 --- a/mod/hakchi/script/base +++ b/mod/hakchi/script/base @@ -33,10 +33,23 @@ early_getty(){ getty -ni 115200 ttyS0 -l /bin/sh } +copy(){ + # we must create target directory if source is directory + [ -d "$1" ] && mkdir -p "$2" + rsync -ac "$1" "$2" +} + restore(){ - rsync -ac "$mountpoint$1" "$rootfs$1" + copy "$mountpoint$1" "$rootfs$1" } overmount(){ - mount -o bind "$rootfs$1" "$mountpoint$1" + if [ "$#" == "1" ]; then + echo overmounting $1 + mount -o bind "$rootfs$1" "$mountpoint$1" + fi + if [ "$#" == "2" ]; then + echo overmounting $1 on $2 + mount -o bind "$1" "$mountpoint$2" + fi } diff --git a/mod/hakchi/script/games b/mod/hakchi/script/games new file mode 100644 index 0000000..7e59555 --- /dev/null +++ b/mod/hakchi/script/games @@ -0,0 +1,57 @@ +transfer_original_games(){ + [ -d "$1" ] || return 1 + echo Transfering original games... + # Using temporary directory for original games + tmp_games=/tmp/original_games + mkdir -p "$tmp_games" + copy "$mountpoint/usr/share/games/nes/kachikachi/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' {} + + # 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/.*\///"` + # 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 + rm -rf $tmp_games/$code + else + # Now we trying to get destination directory + if [ -f "$1/gpath-$code" ]; then + dist=`cat "$1/gpath-$code"` + mkdir -p "$tmp_games/$dist" + 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 + fi + fi + fi + done + # Now we can write games to flash + copy "$tmp_games/*" "$target_dir" + rm -rf "$tmp_games" + rm -rf "$1" +} + +transfer_games(){ + [ -d "$1" ] || return 1 + target_dir=$rootfs/usr/share/games/nes/kachikachi + # Flag to remove all installed games + if [ -f "$1/clear" ]; then + echo Removing games... + rm -rf $target_dir/CLV-* + rm "$1/clear" + fi + mkdir -p "$target_dir" + # But we need fonts + restore "/usr/share/games/nes/kachikachi/title.fnt" + restore "/usr/share/games/nes/kachikachi/copyright.fnt" + transfer_original_games "$1/original" + echo Transfering new games... + # This is simple + copy "$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 95c3bdd..c258e6d 100644 --- a/mod/hakchi/script/install +++ b/mod/hakchi/script/install @@ -1,6 +1,6 @@ mod_uninstall(){ echo uninstalling $modname... - rm -rf "$rootfs" + rm -rf "$installpath" echo done. shutdown } @@ -9,9 +9,15 @@ mod_repair(){ restore "/etc/clover/" restore "/etc/issue" rm -f "$modpath/rootfs/etc/preinit.d/p0000_config" - rsync -ac "$modpath/rootfs/" "$rootfs/" - rsync -ac "/bin/" "$rootfs/bin/" - rsync -ac "/sbin/cryptsetup" "$rootfs/bin/cryptsetup" + chown -R root:root $modpath/ + chmod 755 $modpath/rootfs/bin/* + copy "$modpath/rootfs/" "$rootfs/" + copy "/bin/" "$rootfs/bin/" + copy "/sbin/cryptsetup" "$rootfs/bin/cryptsetup" + + # This file required by hakchi2 kernel... + echo hakchi_enabled=y > "$temppath/config" + copy "$temppath/config" "$installpath/" } mod_install(){ diff --git a/mod/hakchi/script/package b/mod/hakchi/script/package index c45deed..3d1e691 100644 --- a/mod/hakchi/script/package +++ b/mod/hakchi/script/package @@ -3,6 +3,7 @@ transfer_file(){ dos2unix -u "$1" guard_ud(){ source "$1" + return 0 } guard_ud "$1" res=$? @@ -47,16 +48,11 @@ pack_install(){ transfer_path "$transferpath" mkdir -p "$installpath/hmod" if [ ! -f "$transferpath/uninstall" ]; then + echo creating uninstall for $(basename "$1" .hmod)... cd "$transferpath" - for i in $(find . -type l); do - echo rm -f \"\$installpath/$i\" >> "$transferpath/uninstall" - done - for i in $(find . -type f); do - echo rm -f \"\$installpath/$i\" >> "$transferpath/uninstall" - done - for i in $(find . -depth -type d); do - echo rmdir \"\$installpath/$i\" >> "$transferpath/uninstall" - done + 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" [ $(stat -c%s "$transferpath/uninstall") -gt 8 ] || rm -f "$transferpath/uninstall" @@ -66,11 +62,11 @@ pack_install(){ if [ -f "$transferpath/uninstall" ]; then dos2unix -u "$transferpath/uninstall" sed -i "s#rmdir #rmdir --ignore-fail-on-non-empty #" "$transferpath/uninstall" - rsync -ac "$transferpath/uninstall" "$unfile" + copy "$transferpath/uninstall" "$unfile" else rm -f "$unfile" fi - rm -rf "$1" + echo package $(basename "$1" .hmod) installed } pack_uninstall(){ @@ -81,15 +77,27 @@ pack_uninstall(){ done fi else - echo uninstalling $(basename "$1" .hmod)... local unfile=$(pack_upath "$1") - transfer_file "$unfile" + if [ -f "$unfile" ]; then + echo uninstalling $(basename "$1" .hmod)... + transfer_file "$unfile" + echo package $(basename "$1" .hmod) uninstalled + fi fi rmdir --ignore-fail-on-non-empty "$installpath/hmod" } packs_install(){ + [ -d "$1" ] || return 1 for i in $(find "$1" -maxdepth 1 -name "*.hmod" | sort); do pack_install "$i" + rm -rf "$1" + done +} + +packs_uninstall(){ + [ -d "$1" ] || return 1 + for i in $@; do + pack_uninstall "$i" done } diff --git a/mod/hakchi/script/transfer b/mod/hakchi/script/transfer index b9ac4b7..aefd1c4 100644 --- a/mod/hakchi/script/transfer +++ b/mod/hakchi/script/transfer @@ -1,6 +1,7 @@ source "$modpath/script/backup" source "$modpath/script/install" source "$modpath/script/package" +source "$modpath/script/games" backup_nandc mount_base @@ -16,17 +17,23 @@ else fi local transferpath=$modpath/transfer + +packs_uninstall $(cat "$transferpath/uninstall") +packs_uninstall $(cat "$transferpath/hmod/uninstall") + packs_install "$transferpath" if [ -d "$transferpath/hmod" ]; then packs_install "$transferpath/hmod" rm -rf "$transferpath/hmod" fi + +if [ -d "$transferpath/games" ]; then + transfer_games "$transferpath/games" + rm -rf "$transferpath/games" +fi + echo transferring data... transfer_path "$transferpath" -source "$modpath/script/transfer-first" -source "$modpath/script/transfer-gui" -source "$modpath/script/transfer-last" - source "$preinitpath/pffff_config" [ "$cf_shutdown" != "y" ] || shutdown diff --git a/mod/hakchi/script/transfer-first b/mod/hakchi/script/transfer-first deleted file mode 100644 index 8ccbfbd..0000000 --- a/mod/hakchi/script/transfer-first +++ /dev/null @@ -1,47 +0,0 @@ -if [ "$hakchi_partial_first" == "y" ]; then - - if [ "$hakchi_remove_games" == "y" ]; then - echo Removing all games... - rm -rf $rootfs/usr/share/games/nes/kachikachi/* - fi - - if [ "$hakchi_original_games" == "y" ]; then - echo Transfering original games... - for dir in $mountpoint/usr/share/games/nes/kachikachi/*; do - if [ -d $dir ]; then - code=`echo $dir | sed "s/.*\///"` - if [ -f /$modname/hidden_games ] && grep -q $code /$modname/hidden_games; then - echo $code is hidden - else - echo Transfering $code - found=false - for p in /games/gpath-$code-*; do - if [ -f "$p" ]; then - dist=`cat $p` - mkdir -p $rootfs/usr/share/games/nes/kachikachi/$dist - echo ...to $rootfs/usr/share/games/nes/kachikachi/$dist - cp -a $mountpoint/usr/share/games/nes/kachikachi/$code $rootfs/usr/share/games/nes/kachikachi/$dist - rm $p - found=true - fi - done - if [ "$found" == "false" ]; then - echo There is no path file for $code - cp -a $mountpoint/usr/share/games/nes/kachikachi/$code $rootfs/usr/share/games/nes/kachikachi/ - fi - fi - fi - done - fi - - if [ "$hakchi_remove_armet_original" == "y" ]; then - echo "Removing armet filter..." - find $rootfs/usr/share/games/nes/kachikachi -name *.desktop -exec sed -i -e 's/--enable-armet//g' {} + - fi - - if [ -f "$hakchi_extra_script" ]; then - echo Executing extra script... - source $hakchi_extra_script - fi - -fi diff --git a/mod/hakchi/script/transfer-gui b/mod/hakchi/script/transfer-gui deleted file mode 100644 index d430922..0000000 --- a/mod/hakchi/script/transfer-gui +++ /dev/null @@ -1,71 +0,0 @@ -if [ -f $installpath/menu ]; then - echo Erasing last menu state... - rm $installpath/menu -fi - -if [ "$hakchi_remove_games" == "y" ] && [ "$hakchi_partial_first" == "y" ]; then - echo Removing all games... - rm -rf $rootfs/usr/share/games/nes/kachikachi/* -fi - -if [ "$hakchi_original_games" == "y" ] && [ "$hakchi_partial_first" == "y" ]; then - echo Transfering original games... - for dir in $mountpoint/usr/share/games/nes/kachikachi/*; do - if [ -d $dir ]; then - code=`echo $dir | sed "s/.*\///"` - if [ -f /$modname/hidden_games ] && grep -q $code /$modname/hidden_games; then - echo $code is hidden - else - echo Transfering $code - found=false - for p in /games/gpath-$code-*; do - if [ -f "$p" ]; then - dist=`cat $p` - mkdir -p $rootfs/usr/share/games/nes/kachikachi/$dist - echo ...to $rootfs/usr/share/games/nes/kachikachi/$dist - cp -a $mountpoint/usr/share/games/nes/kachikachi/$code $rootfs/usr/share/games/nes/kachikachi/$dist - rm $p - found=true - fi - done - if [ "$found" == "false" ]; then - echo There is no path file for $code - cp -a $mountpoint/usr/share/games/nes/kachikachi/$code $rootfs/usr/share/games/nes/kachikachi/ - fi - fi - fi - done -fi - -if [ "$hakchi_remove_armet_original" == "y" ] && [ "$hakchi_partial_first" == "y" ]; then - echo "Removing armet filter..." - find $rootfs/usr/share/games/nes/kachikachi -name *.desktop -exec sed -i -e 's/--enable-armet//g' {} + -fi - -if [ -d /games ]; then - echo Transferring new games... - cp -a /games/* $rootfs/usr/share/games/nes/kachikachi -fi - -if [ "$hakchi_remove_armet_all" == "y" ] && [ "$hakchi_partial_last" == "y" ]; then - echo Removing armet filter... - find $rootfs/usr/share/games/nes/kachikachi -name *.desktop -exec sed -i -e 's/--enable-armet//g' {} + -fi - -if [ -f "$hakchi_extra_args_file" ] && [ "$hakchi_partial_last" == "y" ]; then - echo Appending extra command line arguments... - find $rootfs/usr/share/games/nes/kachikachi -name *.desktop -exec awk -v cfile="$hakchi_extra_args_file" 'BEGIN{getline c < cfile} /Exec=\/usr\//{$0=$0 " " c} {l[ln++]=$0} END{for(i=0;i<ln;i++) print l[i]>ARGV[1]}' {} + -fi - -if [ "$hakchi_partial_first" == "y" ]; then - if [ -d /transfer ]; then - echo Transferring extra data... - cp -a /transfer/* $installpath/ - fi -fi - -if [ -f "$hakchi_extra_script" ]; then - echo 1 - echo Executing extra script... - . "$hakchi_extra_script" -fi diff --git a/mod/hakchi/script/transfer-last b/mod/hakchi/script/transfer-last deleted file mode 100644 index 0bcd766..0000000 --- a/mod/hakchi/script/transfer-last +++ /dev/null @@ -1,13 +0,0 @@ -if [ "$hakchi_partial_last" == "y" ]; then - - if [ "$hakchi_remove_armet_all" == "y" ]; then - echo Removing armet filter... - find $rootfs/usr/share/games/nes/kachikachi -name *.desktop -exec sed -i -e 's/--enable-armet//g' {} + - fi - - if [ -f $hakchi_extra_args_file ]; then - echo Appending extra command line arguments... - find $rootfs/usr/share/games/nes/kachikachi -name *.desktop -exec awk -v cfile="$hakchi_extra_args_file" 'BEGIN{getline c < cfile} /Exec=\/usr\//{$0=$0 " " c} {l[ln++]=$0} END{for(i=0;i<ln;i++) print l[i]>ARGV[1]}' {} + - fi - -fi |