Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
madmonkey1907 committed Mar 9, 2018
1 parent 6f7b391 commit 9aa2fc0
Show file tree
Hide file tree
Showing 27 changed files with 657 additions and 134 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ build/macdylibbundler: 3rdparty/macdylibbundler/*
@$(MAKE) -C $(<D)

bin/sntool: sntool/sntool.cpp
@$(CROSS_COMPILE)g++ -I3rdparty/sunxi-tools -std=gnu++11 -Wall -Wextra $< -o $@
@$(CROSS_COMPILE)g++ -I3rdparty/sunxi-tools -I3rdparty/mkbootimg -std=gnu++11 -Wall -Wextra $< -o $@
2 changes: 1 addition & 1 deletion bin/makeimg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ "$2" = "notx" ]; then
rm -f "$inpath/initramfs/bin/rsync"
fi

#(cd "$inpath/initramfs";find . -print0 | sort -z | bundled cpio -0o -H newc -R 0:0 --quiet > "../initramfs.cpio")
#(cd "$inpath/initramfs";find -print0 | sort -z | bundled cpio -0o -H newc -R 0:0 --quiet > "../initramfs.cpio")
mkbootfs "$inpath/initramfs" > "$inpath/initramfs.cpio"

kernelzImage="$inpath/../data/zImage"
Expand Down
2 changes: 1 addition & 1 deletion bin/makepack
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ 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)
(cd "$input" && tar -mcz --owner=root --group=root --numeric-owner -f "$output" * && echo ok)
4 changes: 2 additions & 2 deletions hakchi-gui/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ MainWindow::MainWindow(QWidget *parent) :
printf("Knock, knock\n");

#ifndef DEBUG
ui->actionWrite_nand->setVisible(false);
// ui->actionWrite_nand->setVisible(false);
#endif
}

Expand Down Expand Up @@ -159,7 +159,7 @@ void MainWindow::on_actionDump_nand_triggered()
void MainWindow::on_actionWrite_nand_triggered()
{
// do not use
return;
//return;
if(QMessageBox::warning(this,"nand","sure?",QMessageBox::Yes|QMessageBox::Abort,QMessageBox::Abort)!=QMessageBox::Yes)
return;
emit doWork(Worker::writeNandFull);
Expand Down
3 changes: 2 additions & 1 deletion hakchi-gui/src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ void Worker::do_writeNandFull()
{
return;
}
const size_t block=0x2000000;
// const size_t block=0x2000000;
const size_t block=1*1024*1024;
const size_t count=0x10;
calcProgress(0-(block*count));
const QString nandFile("dump/nand.bin");
Expand Down
2 changes: 1 addition & 1 deletion hakchi-hmod/install
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rm -f "./etc/preinit.d/p0000_config"
cd "./bin/"
./busybox --list | xargs -n1 ln -s "/bin/busybox" 2>/dev/null || true
./busybox --list | xargs -n1 ln -s "busybox" 2>/dev/null || true
cd ".."
return 0
1 change: 1 addition & 0 deletions hakchi-hmod/uninstall
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
return 0
no-uninstall
37 changes: 0 additions & 37 deletions mod/etc/filesystems

This file was deleted.

8 changes: 4 additions & 4 deletions mod/hakchi/init
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ init(){
export modpath="/$modname"
export mountpoint="/newroot"
export temppath="/tmp"
export bootVersion="1.0.1"
export bootVersion="1.0.2"
echo "$modname init script version: $bootVersion"

/bin/busybox --install -s /bin/
ln -s "$modpath/rootfs/etc" "/"
mkdir -p "$temppath"
for dir in etc lib usr; do
[ -e "/$dir" ] || ln -s "$mountpoint/$dir" "/$dir"
for dir in lib usr sbin; do
[ -e "/$dir" ] || ln -s "$mountpoint/$dir" "/"
done
export PATH="/sbin:$modpath/rootfs/bin:/bin:$mountpoint/sbin:/usr/sbin:$mountpoint/bin:/usr/bin"

Expand Down
4 changes: 1 addition & 3 deletions mod/hakchi/rootfs/bin/test-menu
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/bin/sh
uistop 1>/dev/null 2>&1
/opt/test/bin/test-menu </dev/null
uistart
exec /opt/test/bin/test-menu </dev/null
12 changes: 12 additions & 0 deletions mod/hakchi/rootfs/etc/filesystems
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
squashfs
ext4
ext3
ext2
ntfs
vfat
exfat
cramfs
fuseblk
iso9660
msdos
udf
2 changes: 1 addition & 1 deletion mod/hakchi/rootfs/etc/preinit
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source_parts(){
rm -f "$script"
local searchpath="$(dirname "$1")"
[ -d "$searchpath" ] || return 1
for i in $(find "$searchpath" -maxdepth 1 -path "$1" | sort); do
for i in $(find "$searchpath/" -maxdepth 1 -path "$1" | sort); do
cat "$i" >> "$script"
done
dos2unix -u "$script"
Expand Down
8 changes: 4 additions & 4 deletions mod/hakchi/rootfs/etc/preinit.d/b0010_functions
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ loadFirmware(){
if ! checkFirmware "$firmware"; then
[ "$cfg_firmware" == "auto" ] || return 0
[ -d "$extfirmwarepath" ] && \
firmware="$(find "$extfirmwarepath" -type f -name "*.hsqs" | sort | head -n1)"
firmware="$(find "$extfirmwarepath/" -type f -name "*.hsqs" | sort | head -n1)"
if ! checkFirmware "$firmware"; then
[ -d "$firmwarepath" ] && \
firmware="$(find "$firmwarepath" -type f -name "*.hsqs" | sort | head -n1)"
firmware="$(find "$firmwarepath/" -type f -name "*.hsqs" | sort | head -n1)"
fi
fi
checkFirmware "$firmware" || return 0
Expand Down Expand Up @@ -163,8 +163,8 @@ reboot(){

early_getty(){
cd "$modpath/transfer"
getty -ni 115200 ttyS0 -l /bin/sh
cd /
preinit="$preinit" getty -ni 115200 ttyS0 -l /bin/sh
cd - 1>/dev/null
}

copy(){
Expand Down
2 changes: 1 addition & 1 deletion mod/hakchi/rootfs/etc/preinit.d/b0020_backup
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ backup_nandb(){
cd "$backuppath" || return 1
if [ ! -f "$nandb_filename" ]; then
echo "backup $nandb_filename"
dd if=/dev/mapper/root-crypt bs=4k \
dd if=/dev/mapper/root-crypt bs=4K \
count="$((($(hexdump -e '1/4 "%u"' -s $((0x28)) -n 4 /dev/mapper/root-crypt)+0xfff)/0x1000))" \
> "$nandb_filename" && \
md5sum "$nandb_filename" > "$nandb_filename.md5"
Expand Down
14 changes: 8 additions & 6 deletions mod/hakchi/rootfs/etc/preinit.d/b0030_package
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ transfer_path(){
find "$transferpath/" -maxdepth 1 -type f -iname "*.md" -delete
local docopy=y
cd "$transferpath"
[ -d "./bin" ] && chmod 755 ./bin/*
[ -d "./etc/init.d" ] && chmod 755 ./etc/init.d/*
for dir in bin sbin usr/bin usr/sbin etc/init.d; do
[ -d "./$dir" ] && chmod 755 ./$dir/*
done
[ -d "./etc/preinit.d" ] && chmod 644 ./etc/preinit.d/*
transfer_file "$transferpath/install" || docopy=n
cd "$transferpath"
transfer_file "$transferpath/transfer" || docopy=n
Expand Down Expand Up @@ -57,9 +59,9 @@ pack_install(){
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"
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 "$packFile")"
Expand Down Expand Up @@ -103,7 +105,7 @@ pack_uninstall(){

packs_install(){
[ -d "$1" ] || return 1
for i in $(find "$1" -maxdepth 1 -name "*.hmod" | sort); do
for i in $(find "$1/" -maxdepth 1 -name "*.hmod" | sort); do
pack_install "$i"
rm -rf "$i"
done
Expand Down
2 changes: 1 addition & 1 deletion mod/hakchi/rootfs/etc/preinit.d/b0040_usb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ switchToUsbHost(){
}

getUsbStorageIds(){
find "/dev/bus/usb" -type c | while read device
find "/dev/bus/usb/" -type c | while read device
do
hexdump -n 1 -s 32 "$device" -C | grep -e '^00000020 08' && echo "$device"
done
Expand Down
2 changes: 1 addition & 1 deletion mod/hakchi/rootfs/etc/preinit.d/p0000_version
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
createVersionFile(){
[ -d "$mountpoint/var" ] || return 1
local vfile="$mountpoint/var/version"
local hakchiVersion="[master]v1.0.3-110(7f31082)"
local hakchiVersion="[master]v1.0.3-110(6f7b391)"
local kernelVersion="$(uname -r)"
[ -z "$bootVersion" ] && local bootVersion="v1.0.0"
echo "# $(uname -a)" > "$vfile"
Expand Down
2 changes: 2 additions & 0 deletions mod/hakchi/rootfs/etc/profile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ fi
export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM

umask 022

eval $(resize)
7 changes: 3 additions & 4 deletions mod/hakchi/script/reflash
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
umount_base

local firmware="$(find -type f -name "*.hsqs" | sort | head -n 1)"
local firmware="$(find -type f -name "*.hsqs" | sort | head -n1)"
if [ -f "$firmware" ]; then
umount "$mountpoint"

Expand All @@ -19,11 +19,10 @@ unset firmware

local tmk="$(pwd)/mkfs.txz"
if [ -f "$tmk"]; then
rm "/lib"
rm -f "/lib"
cd / && tar xJf "$tmk"
mount_bind "$mountpoint/lib" "/lib"
# /sbin/mkfs.ext4 -L data -m 0 /dev/nandc
mkfs.ext2 -L data -m 0 /dev/nandc
yes | /sbin/mke2fs -t ext4 -L data -b 4K -E stripe-width=32 -O ^huge_file,^metadata_csum /dev/nandc
umount "/lib"
fi
unset tmk
Expand Down
4 changes: 2 additions & 2 deletions mod/hakchi/script/transfer
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ fi

# transfer firmware, if any
if [ -d "$transferpath/firmware" ]; then
local firmware="$(find "$transferpath/firmware" -type f -name "*.hsqs" | sort | head -n 1)"
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
find "$firmwarepath/" -type f -not -name "$firmware_name" -delete
echo "transferring firmware..."
copy "$firmware" "$firmwarepath/"
cfg_firmware="auto"
Expand Down
48 changes: 48 additions & 0 deletions mod/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh

cd /bin
busybox --list | busybox xargs -n1 busybox ln -s "busybox" 2>/dev/null
cd /

# devtmpfs does not get automounted for initramfs
mkdir -p /dev /proc /sys
mount -t devtmpfs devtmpfs /dev
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
mount -t proc proc /proc
mount -t sysfs sys /sys

keyfile="/key-file"
for i in $(cat /proc/cmdline); do
if [ "$i" = "ro" ]; then
READONLY="y"
elif [ "${i#root=}" != "$i" ]; then
ROOTFS="${i#root=}"
elif [ "$i" = "decrypt" ]; then
DECRYPT="y"
elif [ "${i#hakchi-key-file=base64:}" != "$i" ]; then
echo "${i#hakchi-key-file=base64:}" | base64 -d >"$keyfile"
fi
done
[ -f "$keyfile" ] || sntool sunxi_flash ramdisk | cpio -iu "$(basename "$keyfile")" 2>/dev/null

MOUNT_OPTS="noatime"
[ "${READONLY}" = "y" ] && MOUNT_OPTS="ro,${MOUNT_OPTS}"

if [ "${DECRYPT}" = "y" ]; then
[ "${READONLY}" = "y" ] && READONLY="--readonly"
cryptsetup open "${ROOTFS}" root-crypt "${READONLY}" --type plain --cipher aes-xts-plain --key-file "$keyfile"
ROOTFS="/dev/mapper/root-crypt"
fi

mountpoint="/newroot"
mkdir -p "$mountpoint"
mount -o "${MOUNT_OPTS}" "${ROOTFS}" "$mountpoint"

[ -f "/hakchi/init" ] && sh "/hakchi/init"

mount --move /dev "$mountpoint/dev"
mount --move /proc "$mountpoint/proc"
mount --move /sys "$mountpoint/sys"
exec switch_root "$mountpoint" /sbin/init
39 changes: 0 additions & 39 deletions mod/sbin/init

This file was deleted.

Loading

0 comments on commit 9aa2fc0

Please sign in to comment.