Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormadmonkey <madfkingmonkey@gmail.com>2017-02-15 00:00:22 +0300
committermadmonkey <madfkingmonkey@gmail.com>2017-02-15 00:00:22 +0300
commit47b5a7c2009d04978dcf8ad0fd3236a304755012 (patch)
tree6f01c8cfb8d8b75aa9a94651c5afdb629b7c4e1c
parent41088ca218237f1a9c7fbcc3e395fbbd48b4a8c5 (diff)
up
-rw-r--r--mod/hakchi/rootfs/bin/chmenu15
-rw-r--r--mod/hakchi/rootfs/bin/clover-kachikachi-wr4
-rw-r--r--mod/hakchi/rootfs/etc/preinit36
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/b0000_defines10
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/b0010_functions70
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/p7070_preinit7
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/p7100_preinit5
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/pa100_games11
-rw-r--r--mod/hakchi/script/base45
-rw-r--r--mod/hakchi/script/games8
-rw-r--r--mod/hakchi/script/transfer6
11 files changed, 133 insertions, 84 deletions
diff --git a/mod/hakchi/rootfs/bin/chmenu b/mod/hakchi/rootfs/bin/chmenu
index f333c26..427982e 100644
--- a/mod/hakchi/rootfs/bin/chmenu
+++ b/mod/hakchi/rootfs/bin/chmenu
@@ -1,10 +1,10 @@
#!/bin/sh
-installpath=/var/lib/hakchi
-rootfs=$installpath/rootfs
-gamepath=$rootfs/usr/share/games/nes/kachikachi
+source /etc/preinit
+script_init
+
state_file=$installpath/menu
-[ -z "$1" ] && exit 0
+[ -z "$1" ] && exit 1
prev_code=$(cat "$state_file")
[ "$1" == "$prev_code" ] && exit 0
@@ -26,9 +26,4 @@ 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
+overmount_games
diff --git a/mod/hakchi/rootfs/bin/clover-kachikachi-wr b/mod/hakchi/rootfs/bin/clover-kachikachi-wr
index 26b2996..d8ff989 100644
--- a/mod/hakchi/rootfs/bin/clover-kachikachi-wr
+++ b/mod/hakchi/rootfs/bin/clover-kachikachi-wr
@@ -4,7 +4,9 @@
# using "cfg_nes_extra_args" variable in p0000_config
# or disable epilepsy protection using "cfg_disable_armet=y"
-source /etc/preinit.d/p0000_config
+source /etc/preinit
+script_init
+
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 2b8216f..6c543a1 100644
--- a/mod/hakchi/rootfs/etc/preinit
+++ b/mod/hakchi/rootfs/etc/preinit
@@ -8,12 +8,46 @@ source_parts(){
for i in $(find $(dirname "$1") -maxdepth 1 -path "$1" | sort); do
cat "$i" >> "$script"
done
- source "$script"
+ guard_ud(){
+ dos2unix -u "$1"
+ source "$1"
+ }
+ guard_ud "$script"
local ret=$?
rm -f "$script"
return $ret
}
+source_base(){
+ if [ -d "$1" ]; then
+ source_parts "$1/b????_*"
+ return 0
+ fi
+ if [ -d "$preinitpath" ]; then
+ source_parts "$preinitpath/b????_*"
+ return 0
+ fi
+ if [ -d "/etc/preinit.d" ]; then
+ source_parts "/etc/preinit.d/b????_*"
+ return 0
+ fi
+ return 1
+}
+
+source_config(){
+ [ -f "$preinitpath/p0000_config" ] && source "$preinitpath/p0000_config"
+}
+
+save_config(){
+ [ -f "$preinitpath/pffff_config" ] && source "$preinitpath/pffff_config"
+}
+
+script_init(){
+ source_base
+ source_config
+}
+
preinit(){
+ source_base
source_parts "$preinitpath/p????_*"
}
diff --git a/mod/hakchi/rootfs/etc/preinit.d/b0000_defines b/mod/hakchi/rootfs/etc/preinit.d/b0000_defines
new file mode 100644
index 0000000..5203e94
--- /dev/null
+++ b/mod/hakchi/rootfs/etc/preinit.d/b0000_defines
@@ -0,0 +1,10 @@
+modname=hakchi
+modpath=/$modname
+[ -z "$mountpoint" ] && mountpoint=/
+installpath=$mountpoint/var/lib/$modname
+firmwarepath=$installpath/firmware
+rootfs=$installpath/rootfs
+preinit=$rootfs/etc/preinit
+preinitpath=$preinit.d
+gamepath=/usr/share/games/nes/kachikachi
+temppath=/tmp
diff --git a/mod/hakchi/rootfs/etc/preinit.d/b0010_functions b/mod/hakchi/rootfs/etc/preinit.d/b0010_functions
new file mode 100644
index 0000000..0445eab
--- /dev/null
+++ b/mod/hakchi/rootfs/etc/preinit.d/b0010_functions
@@ -0,0 +1,70 @@
+remount_root(){
+ local tmpmount=$modpath/var.tmp
+ mkdir -p "$tmpmount"
+ mount --move "$mountpoint/var" "$tmpmount"
+
+ umount "$mountpoint"
+
+ local loopfile=$tmpmount${1##$mountpoint/var}
+ mount -o loop,ro "$loopfile" "$mountpoint" || shutdown
+
+ mount --move "$tmpmount" "$mountpoint/var"
+}
+
+load_firmware(){
+ [ -d "$firmwarepath" ] || return 0
+ local firmware=$(find "$firmwarepath" -type f -name "*.hsqs" | sort | head -n 1)
+ [ -f "$firmware" ] || return 0
+ remount_root "$firmware" && cryptsetup close root-crypt
+}
+
+shutdown(){
+ echo shutting down...
+ umount -a
+ poweroff -f
+ while :;do :;done
+}
+
+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(){
+ copy "$mountpoint$1" "$rootfs$1"
+}
+
+mount_bind(){
+ if mountpoint -q "$2"; then
+ umount "$2" || umount -f "$2"
+ fi
+ mount -o bind "$1" "$2"
+}
+
+overmount(){
+ if [ "$#" == "1" ]; then
+ echo overmounting $1
+ mount_bind "$rootfs$1" "$mountpoint$1"
+ fi
+ if [ "$#" == "2" ]; then
+ echo overmounting $1 on $2
+ mount_bind "$1" "$mountpoint$2"
+ fi
+}
+
+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
+ if [ "$menu_code" == "000" ]; then
+ overmount "$gamepath"
+ else
+ overmount "$rootfs$gamepath/$menu_code" "$gamepath"
+ fi
+}
diff --git a/mod/hakchi/rootfs/etc/preinit.d/p7070_preinit b/mod/hakchi/rootfs/etc/preinit.d/p7070_preinit
index fb34f51..f56ae92 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/p7070_preinit
+++ b/mod/hakchi/rootfs/etc/preinit.d/p7070_preinit
@@ -1,8 +1 @@
-load_firmware(){
- [ -d "$firmwarepath" ] || return 0
- local firmware=$(find "$firmwarepath" -type f -name "*.hsqs" | sort | head -n 1)
- [ -f "$firmware" ] || return 0
- remount_root "$firmware" && cryptsetup close root-crypt
-}
-
[ "cfg_boot_stock_firmware" == "y" ] || load_firmware
diff --git a/mod/hakchi/rootfs/etc/preinit.d/p7100_preinit b/mod/hakchi/rootfs/etc/preinit.d/p7100_preinit
index 61336e1..0e7456f 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/p7100_preinit
+++ b/mod/hakchi/rootfs/etc/preinit.d/p7100_preinit
@@ -1,7 +1,6 @@
-overmount_all(){
+overmount_base(){
overmount "/bin"
overmount "/etc"
- overmount "/usr/bin"
}
-[ "$cfg_boot_stock" == "y" ] || overmount_all
+[ "$cfg_boot_stock" == "y" ] || overmount_base
diff --git a/mod/hakchi/rootfs/etc/preinit.d/pa100_games b/mod/hakchi/rootfs/etc/preinit.d/pa100_games
index 76a88a0..6df5a26 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/pa100_games
+++ b/mod/hakchi/rootfs/etc/preinit.d/pa100_games
@@ -1,12 +1 @@
-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 b0c2819..034c4f7 100644
--- a/mod/hakchi/script/base
+++ b/mod/hakchi/script/base
@@ -8,48 +8,3 @@ umount_base(){
umount "$mountpoint/var/lib"
umount "$mountpoint/var"
}
-
-remount_root(){
- local tmpmount=$modpath/var.tmp
- mkdir -p "$tmpmount"
- mount --move "$mountpoint/var" "$tmpmount"
-
- umount "$mountpoint"
-
- local loopfile=$tmpmount${1##$mountpoint/var}
- mount -o loop,ro "$loopfile" "$mountpoint" || shutdown
-
- mount --move "$tmpmount" "$mountpoint/var"
-}
-
-shutdown(){
- echo shutting down...
- umount -a
- poweroff -f
- while :;do :;done
-}
-
-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(){
- copy "$mountpoint$1" "$rootfs$1"
-}
-
-overmount(){
- 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
index 7e59555..4e3c64c 100644
--- a/mod/hakchi/script/games
+++ b/mod/hakchi/script/games
@@ -4,7 +4,7 @@ transfer_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"
+ copy "$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' {} +
# We need to decide game distination directory, so we can't just copy all games at once
@@ -37,7 +37,7 @@ transfer_original_games(){
transfer_games(){
[ -d "$1" ] || return 1
- target_dir=$rootfs/usr/share/games/nes/kachikachi
+ target_dir=$rootfs$gamepath
# Flag to remove all installed games
if [ -f "$1/clear" ]; then
echo Removing games...
@@ -46,8 +46,8 @@ transfer_games(){
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"
+ restore "$gamepath/title.fnt"
+ restore "$gamepath/copyright.fnt"
transfer_original_games "$1/original"
echo Transfering new games...
# This is simple
diff --git a/mod/hakchi/script/transfer b/mod/hakchi/script/transfer
index aefd1c4..e58c6cd 100644
--- a/mod/hakchi/script/transfer
+++ b/mod/hakchi/script/transfer
@@ -7,7 +7,9 @@ backup_nandc
mount_base
backup
-[ -f "$preinitpath/p0000_config" ] && source "$preinitpath/p0000_config"
+source "$modpath/rootfs/etc/preinit"
+source_base "$modpath/rootfs/etc/preinit.d"
+source_config
if [ -f "$preinit" ]; then
echo $modname already installed
@@ -35,5 +37,5 @@ fi
echo transferring data...
transfer_path "$transferpath"
-source "$preinitpath/pffff_config"
+save_config
[ "$cf_shutdown" != "y" ] || shutdown