diff options
author | Alexey 'Cluster' Avdyukhin <ClusterM@users.noreply.github.com> | 2017-02-18 04:17:48 +0300 |
---|---|---|
committer | madmonkey1907 <madfkingmonkey@gmail.com> | 2017-02-18 04:17:48 +0300 |
commit | b323d7b3e32b697bc4f8d08c37c8e6c8673cd152 (patch) | |
tree | a26c0c41ef4988692c7da70e33187bebe24d38f8 | |
parent | 14bca53f8ac0a2e618db04ba08f3201a70e59d83 (diff) |
Sync (#23)
* Fucking permissions
* Fucking permissions
* Merged with madmonkey
* Fixes
* Fixes
* Another critical bugfix
* fix
* Sync
* Sync
-rw-r--r-- | bin/hmodunpack | 11 | ||||
-rw-r--r-- | bin/makepack | 11 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit | 15 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/b0010_functions | 16 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/pffff_config | 2 | ||||
-rw-r--r-- | mod/hakchi/script/package | 30 | ||||
-rw-r--r-- | mod/hakchi/script/transfer | 36 |
7 files changed, 85 insertions, 36 deletions
diff --git a/bin/hmodunpack b/bin/hmodunpack new file mode 100644 index 0000000..6f5f1d2 --- /dev/null +++ b/bin/hmodunpack @@ -0,0 +1,11 @@ +#!/bin/bash + +input=$(cd $(dirname "$1");pwd)/$(basename "$1") +[ -f "$input" ] || exit 1 + +ext=.hmod +name=$(basename "$input" $ext) +output=$(pwd)/$name + +mkdir -p "$output" +(cd "$output" && tar xzf "$input" && echo ok) diff --git a/bin/makepack b/bin/makepack new file mode 100644 index 0000000..0435c0f --- /dev/null +++ b/bin/makepack @@ -0,0 +1,11 @@ +#!/bin/bash + +input=$1 +[ -d "$input" ] || exit 1 + +ext=.hmod +name=$(basename "$input" $ext) +output=$(pwd)/$name$ext.tgz + +rm -f "$output" +(cd "$input" && tar -cz --owner=root --group=root --numeric-owner -f "$output" * && echo ok) diff --git a/mod/hakchi/rootfs/etc/preinit b/mod/hakchi/rootfs/etc/preinit index 99ec8f1..8d2bb64 100644 --- a/mod/hakchi/rootfs/etc/preinit +++ b/mod/hakchi/rootfs/etc/preinit @@ -4,16 +4,16 @@ rand(){ source_parts(){ [ -z "$temppath" ] && local temppath=/tmp + mkdir -p "$temppath" local script=$temppath/script_$(rand) rm -f "$script" - for i in $(find $(dirname "$1") -maxdepth 1 -path "$1" | sort); do + local searchpath=$(dirname "$1") + [ -d "$searchpath" ] || return 1 + for i in $(find "$searchpath" -maxdepth 1 -path "$1" | sort); do cat "$i" >> "$script" done - guard_ud(){ - dos2unix -u "$1" - source "$1" - } - guard_ud "$script" + dos2unix -u "$script" + source "$script" local ret=$? rm -f "$script" return $ret @@ -53,8 +53,7 @@ script_init(){ } preinit(){ - mkdir -p /tmp - [ -z "$gamepath" ] && [ -d "/newroot" ] && /bin/busybox --install -s /bin/ && cp $rootfs/bin/rsync /bin + [ -z "$gamepath" ] && [ -d "/newroot" ] && /bin/busybox --install -s /bin/ && cp -a $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 0fc06c6..9085c48 100644 --- a/mod/hakchi/rootfs/etc/preinit.d/b0010_functions +++ b/mod/hakchi/rootfs/etc/preinit.d/b0010_functions @@ -5,11 +5,14 @@ mount_base(){ } umount_base(){ - umount "$mountpoint/var/lib" + sync + umount -r "$mountpoint/var/lib" umount "$mountpoint/var" } remount_root(){ + [ -z "$(mount | grep -F loop)" ] || return 1 + local tmpmount=$modpath/var.tmp mkdir -p "$tmpmount" mount --move "$mountpoint/var" "$tmpmount" @@ -31,7 +34,9 @@ load_firmware(){ shutdown(){ echo shutting down... - umount -a + echo + sync + umount -a -r 2>/dev/null poweroff -f while :;do :;done } @@ -41,13 +46,16 @@ early_getty(){ } copy(){ - # we must create target directory if source is directory - [ -d "$1" ] && mkdir -p "$2" + # we must create target directory + local dirname=$(dirname "$2") + mkdir -p "$dirname" rsync -ac "$1" "$2" } copy_mask(){ # this function is unsafe, avoid spaces in filenames! + local dirname=$(dirname "$2") + mkdir -p "$dirname" rsync -ac $1 "$2" } diff --git a/mod/hakchi/rootfs/etc/preinit.d/pffff_config b/mod/hakchi/rootfs/etc/preinit.d/pffff_config index 6806261..d1e50f5 100644 --- a/mod/hakchi/rootfs/etc/preinit.d/pffff_config +++ b/mod/hakchi/rootfs/etc/preinit.d/pffff_config @@ -1,3 +1,3 @@ config=p0000_config set | grep -F cfg_ | sort > "$temppath/$config" -rsync -ac "$temppath/$config" "$preinitpath/$config" +copy "$temppath/$config" "$preinitpath/$config" diff --git a/mod/hakchi/script/package b/mod/hakchi/script/package index 0ca3a8a..7dea3bd 100644 --- a/mod/hakchi/script/package +++ b/mod/hakchi/script/package @@ -1,12 +1,8 @@ transfer_file(){ [ -f "$1" ] || return 0 dos2unix -u "$1" - guard_ud(){ - source "$1" - return 0 - } - guard_ud "$1" - res=$? + source "$1" + local res=$? rm -f "$1" return $res } @@ -27,7 +23,9 @@ transfer_path(){ find "$transferpath/" -maxdepth 1 -type f -iname "*.txt" -delete find "$transferpath/" -maxdepth 1 -type f -iname "*.md" -delete local docopy=y + cd "$transferpath" transfer_file "$transferpath/install" || docopy=n + cd "$transferpath" transfer_file "$transferpath/transfer" || docopy=n [ "$docopy" == "y" ] && transfer_default } @@ -47,20 +45,20 @@ pack_install(){ local transferpath=$1 fi transfer_path "$transferpath" - mkdir -p "$installpath/hmod" - if [ ! -f "$transferpath/uninstall" ]; then - echo creating uninstall for $(basename "$1" .hmod)... - cd "$transferpath" - find . -type l -exec echo rm -f \"\$rootfs/{}\" + >> "$transferpath/uninstall" - find . -type f -exec echo rm -f \"\$rootfs/{}\" + >> "$transferpath/uninstall" - find . -depth -mindepth 1 -type d -exec echo rmdir \"\$rootfs/{}\" + >> "$transferpath/uninstall" - [ $(stat -c%s "$transferpath/uninstall") -gt 8 ] || rm -f "$transferpath/uninstall" - fi + echo creating uninstall for $(basename "$1" .hmod)... + echo >> "$transferpath/uninstall" + echo "\# auto-generated" >> "$transferpath/uninstall" + cd "$transferpath" + find . -type l -exec echo rm -f \"\$rootfs/{}\" + >> "$transferpath/uninstall" + find . -type f -exec echo rm -f \"\$rootfs/{}\" + >> "$transferpath/uninstall" + find . -depth -mindepth 1 -type d -exec echo rmdir \"\$rootfs/{}\" + >> "$transferpath/uninstall" + [ $(stat -c%s "$transferpath/uninstall") -gt 8 ] || rm -f "$transferpath/uninstall" cd / local unfile=$(pack_upath "$1") if [ -f "$transferpath/uninstall" ]; then dos2unix -u "$transferpath/uninstall" sed -i "s#rmdir #rmdir --ignore-fail-on-non-empty #" "$transferpath/uninstall" + mkdir -p "$installpath/hmod" copy "$transferpath/uninstall" "$unfile" else rm -f "$unfile" @@ -79,10 +77,12 @@ pack_uninstall(){ local unfile=$(pack_upath "$1") if [ -f "$unfile" ]; then echo uninstalling $(basename "$1" .hmod)... + cd "$rootfs" transfer_file "$unfile" echo package $(basename "$1" .hmod) uninstalled fi fi + cd / rmdir --ignore-fail-on-non-empty "$installpath/hmod" } diff --git a/mod/hakchi/script/transfer b/mod/hakchi/script/transfer index f7839d2..f27b217 100644 --- a/mod/hakchi/script/transfer +++ b/mod/hakchi/script/transfer @@ -11,20 +11,40 @@ source "$modpath/rootfs/etc/preinit" source_base "$modpath/rootfs/etc/preinit.d" source_config -if [ -f "$preinit" ]; then +local transferpath=$modpath/transfer + +[ -f "$transferpath/earlybird" ] && source "$transferpath/earlybird" +rm -f "$transferpath/earlybird" + +# transfer firmware, if any +if [ -d "$transferpath/firmware" ]; then + local firmware=$(find "$transferpath/firmware" -type f -name "*.hsqs" | sort | head -n 1) + if [ -f "$firmware" ]; then + mkdir -p "$firmwarepath" + local firmware_name=$(basename "$firmware") + find "$firmwarepath" -type f -not -name "$firmware_name" -delete + echo transferring firmware... + copy "$firmware" "$firmwarepath/" + fi + rm -rf "$transferpath/firmware" +fi + +# if we're running modified firmware, mount it now +source_parts "$preinitpath/p????_*firmware*" +source_parts "$modpath/rootfs/etc/preinit.d/p????_*firmware*" + +# now we can do install/repair +if [ -d "$preinitpath" ]; then echo $modname already installed mod_repair else mod_install fi -# if we're running modified firmware -source "$preinitpath/p7070_firmware" - -local transferpath=$modpath/transfer - -[ -f "$transferpath/uninstall" ] && packs_uninstall $(cat "$transferpath/uninstall") && rm -f $transferpath/uninstall -[ -f "$transferpath/hmod/uninstall" ] && packs_uninstall $(cat "$transferpath/hmod/uninstall") && rm -f $transferpath/hmod/uninstall +[ -f "$transferpath/uninstall" ] && packs_uninstall $(cat "$transferpath/uninstall") +rm -f "$transferpath/uninstall" +[ -f "$transferpath/hmod/uninstall" ] && packs_uninstall $(cat "$transferpath/hmod/uninstall") +rm -f "$transferpath/hmod/uninstall" packs_install "$transferpath" if [ -d "$transferpath/hmod" ]; then |