Skip to content

Commit

Permalink
BOARD: Add IPK package manager after firstboot (MiyooCFW#133)
Browse files Browse the repository at this point in the history
* BOARD: Add IPK package manager after firstboot

* Use lazy loading package description
  • Loading branch information
tiopex authored Nov 9, 2024
1 parent 55cec4b commit 6f3f361
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 70 deletions.
105 changes: 56 additions & 49 deletions board/miyoo/boot/firstboot
100755 → 100644

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions board/miyoo/boot/ipk_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

export TERM=linux
WARN="
MiyooCFW team is not responsible for any issues \
arising from the use of third-party applications \
with current software. Support, bug fixes, or \
improvements for 3rd-party apps are not provided \
by our team members unless explicitly stated otherwise \
(contact Maintainer of the app).
\n\n
\Z5 Do you still wish to CONTINUE with install?\Zn
\n\n
Select an option & press START"
ipk_directory="/mnt/pkgs"
package_list=()
help_messages=()
index=1
for ipk_file in "$ipk_directory"/*.ipk; do
if [[ -f "$ipk_file" ]]; then
ipk_name=$(basename -s .ipk "$ipk_file")
package_list+=("$index" "$ipk_name" "off")
help_messages[$((2 * index))]="$index"
help_messages[$((2 * index + 1))]="$ipk_file"
((index++))
fi
done
if [[ ${#package_list[@]} -eq 0 ]]; then
echo "No packages to install."
exit 1
fi

dialog --backtitle "MiyooCFW 2.0" --timeout 10 --title "IPK package manager" --colors --no-shadow --msgbox "\nSelect pkg with \Zb\Z3Y\Zn button on the list." 8 28
until selected_packages=$(dialog --backtitle "MiyooCFW 2.0" --title "IPK package manager" --colors --no-shadow --help-button --help-status --checklist "Press \Zb\Z3Y\Zn to select packages to install:" 20 60 15 "${package_list[@]}" 3>&1 1>&2 2>&3); do
case $? in
(1) btn=Cancel && break;;
(2)
set -- $selected_packages
shift
index=$1
package_info=$(opkg info "${help_messages[$((2 * index + 1))]}")
package_name=$(echo "$package_info" | grep "^Package:" | cut -d' ' -f2)
package_description=$(echo "$package_info" | grep "^Description:" | cut -d' ' -f2-)
package_version=$(echo "$package_info" | grep "^Version:" | cut -d' ' -f2-)
package_source=$(echo "$package_info" | grep "^Source:" | cut -d' ' -f2-)
package_maintainer=$(echo "$package_info" | grep "^Maintainer:" | cut -d' ' -f2-)
dialog --backtitle "MiyooCFW 2.0" --no-shadow --msgbox "$package_name\n\n$package_description\n\nVersion: $package_version\nMaintainer: $package_maintainer\nSource: $package_source" 0 0
for ((i = 2; i < ${#package_list[@]}; i += 3)); do
package_list[$i]="off"
done
shift
for selected in "$@"; do
package_list[$((3 * selected - 1))]="on"
done
esac
done

clear
if [[ $? -ne 0 || -z "$selected_packages" ]]; then
echo "No packages were selected."
exit 1
fi

if (dialog --backtitle "MiyooCFW 2.0" --no-shadow --clear --stdout --title "WARNING" \
--colors --pause "\n \ZbMiyooCFW\Zn\n$WARN" 22 60 30 || test $? -eq 255); then
clear
for package in $selected_packages; do
ipk_package="${help_messages[$((2 * package + 1))]}"
echo "Installing $ipk_package..."
if opkg install "$ipk_package" 2>/dev/null; then
echo "$ipk_package installed successfully."
else
echo "Failed to install $ipk_package."
fi
done
echo "Installation complete."
else
clear
echo "Installation complete."
fi
1 change: 1 addition & 0 deletions board/miyoo/genimage-sdcard.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ image bootfs.vfat {
"boot/firstboot.custom.sh-OFF",
"boot/modules.custom.sh",
"boot/normalboot.custom.sh",
"boot/ipk_install.sh",
}
}
size = 8M
Expand Down
6 changes: 3 additions & 3 deletions package/miyoo/ipk-drpocketsnes/ipk-drpocketsnes.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ IPK_DRPOCKETSNES_LICENSE = Custom
#IPK_DRPOCKETSNES_LICENSE_FILES = COPYRIGHT

define IPK_DRPOCKETSNES_EXTRACT_CMDS
cd $(@D) && ar x $(DL_DIR)/ipk-drpocketsnes/$(IPK_DRPOCKETSNES_SOURCE)
cd $(@D) && cp $(DL_DIR)/ipk-drpocketsnes/$(IPK_DRPOCKETSNES_SOURCE) .
endef

define IPK_DRPOCKETSNES_INSTALL_TARGET_CMDS
mkdir -p $(BINARIES_DIR)/main
tar -xzf $(@D)/data.tar.gz --strip-components=2 -C $(BINARIES_DIR)/main
mkdir -p $(BINARIES_DIR)/main/pkgs
$(INSTALL) -D -m 0666 $(@D)/$(IPK_DRPOCKETSNES_SOURCE) $(BINARIES_DIR)/main/pkgs
endef

$(eval $(generic-package))
6 changes: 3 additions & 3 deletions package/miyoo/ipk-fceux/ipk-fceux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ IPK_FCEUX_LICENSE = GPL-2.0
#IPK_FCEUX_LICENSE_FILES = COPYING

define IPK_FCEUX_EXTRACT_CMDS
cd $(@D) && ar x $(DL_DIR)/ipk-fceux/$(IPK_FCEUX_SOURCE)
cd $(@D) && cp $(DL_DIR)/ipk-fceux/$(IPK_FCEUX_SOURCE) .
endef

define IPK_FCEUX_INSTALL_TARGET_CMDS
mkdir -p $(BINARIES_DIR)/main
tar -xzf $(@D)/data.tar.gz --strip-components=2 -C $(BINARIES_DIR)/main
mkdir -p $(BINARIES_DIR)/main/pkgs
$(INSTALL) -D -m 0666 $(@D)/$(IPK_FCEUX_SOURCE) $(BINARIES_DIR)/main/pkgs
endef

$(eval $(generic-package))
6 changes: 3 additions & 3 deletions package/miyoo/ipk-gambatte/ipk-gambatte.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ IPK_GAMBATTE_LICENSE = GPL-2.0
#IPK_GAMBATTE_LICENSE_FILES = COPYING

define IPK_GAMBATTE_EXTRACT_CMDS
cd $(@D) && ar x $(DL_DIR)/ipk-gambatte/$(IPK_GAMBATTE_SOURCE)
cd $(@D) && cp $(DL_DIR)/ipk-gambatte/$(IPK_GAMBATTE_SOURCE) .
endef

define IPK_GAMBATTE_INSTALL_TARGET_CMDS
mkdir -p $(BINARIES_DIR)/main
tar -xzf $(@D)/data.tar.gz --strip-components=2 -C $(BINARIES_DIR)/main
mkdir -p $(BINARIES_DIR)/main/pkgs
$(INSTALL) -D -m 0666 $(@D)/$(IPK_GAMBATTE_SOURCE) $(BINARIES_DIR)/main/pkgs
endef

$(eval $(generic-package))
6 changes: 3 additions & 3 deletions package/miyoo/ipk-gngeo/ipk-gngeo.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ IPK_GNGEO_LICENSE = GPL-2.0, Custom
#IPK_GNGEO_LICENSE_FILES = COPYING

define IPK_GNGEO_EXTRACT_CMDS
cd $(@D) && ar x $(DL_DIR)/ipk-gngeo/$(IPK_GNGEO_SOURCE)
cd $(@D) && cp $(DL_DIR)/ipk-gngeo/$(IPK_GNGEO_SOURCE) .
endef

define IPK_GNGEO_INSTALL_TARGET_CMDS
mkdir -p $(BINARIES_DIR)/main
tar -xzf $(@D)/data.tar.gz --strip-components=2 -C $(BINARIES_DIR)/main
mkdir -p $(BINARIES_DIR)/main/pkgs
$(INSTALL) -D -m 0666 $(@D)/$(IPK_GNGEO_SOURCE) $(BINARIES_DIR)/main/pkgs
endef

$(eval $(generic-package))
6 changes: 3 additions & 3 deletions package/miyoo/ipk-gpsp/ipk-gpsp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ IPK_GPSP_LICENSE = GPL-2.0
#IPK_GPSP_LICENSE_FILES = COPYING.DOC

define IPK_GPSP_EXTRACT_CMDS
cd $(@D) && ar x $(DL_DIR)/ipk-gpsp/$(IPK_GPSP_SOURCE)
cd $(@D) && cp $(DL_DIR)/ipk-gpsp/$(IPK_GPSP_SOURCE) .
endef

define IPK_GPSP_INSTALL_TARGET_CMDS
mkdir -p $(BINARIES_DIR)/main
tar -xzf $(@D)/data.tar.gz --strip-components=2 -C $(BINARIES_DIR)/main
mkdir -p $(BINARIES_DIR)/main/pkgs
$(INSTALL) -D -m 0666 $(@D)/$(IPK_GPSP_SOURCE) $(BINARIES_DIR)/main/pkgs
endef

$(eval $(generic-package))
6 changes: 3 additions & 3 deletions package/miyoo/ipk-pcsx_rearmed/ipk-pcsx_rearmed.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ IPK_PCSX_REARMED_LICENSE = GPL-2.0
#IPK_PCSX_REARMED_LICENSE_FILES = COPYING

define IPK_PCSX_REARMED_EXTRACT_CMDS
cd $(@D) && ar x $(DL_DIR)/ipk-pcsx_rearmed/$(IPK_PCSX_REARMED_SOURCE)
cd $(@D) && cp $(DL_DIR)/ipk-pcsx_rearmed/$(IPK_PCSX_REARMED_SOURCE) .
endef

define IPK_PCSX_REARMED_INSTALL_TARGET_CMDS
mkdir -p $(BINARIES_DIR)/main
tar -xzf $(@D)/data.tar.gz --strip-components=2 -C $(BINARIES_DIR)/main
mkdir -p $(BINARIES_DIR)/main/pkgs
$(INSTALL) -D -m 0666 $(@D)/$(IPK_PCSX_REARMED_SOURCE) $(BINARIES_DIR)/main/pkgs
endef

$(eval $(generic-package))
6 changes: 3 additions & 3 deletions package/miyoo/ipk-race/ipk-race.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ IPK_RACE_LICENSE = GPL-2.0
#IPK_RACE_LICENSE_FILES = License.txt

define IPK_RACE_EXTRACT_CMDS
cd $(@D) && ar x $(DL_DIR)/ipk-race/$(IPK_RACE_SOURCE)
cd $(@D) && cp $(DL_DIR)/ipk-race/$(IPK_RACE_SOURCE) .
endef

define IPK_RACE_INSTALL_TARGET_CMDS
mkdir -p $(BINARIES_DIR)/main
tar -xzf $(@D)/data.tar.gz --strip-components=2 -C $(BINARIES_DIR)/main
mkdir -p $(BINARIES_DIR)/main/pkgs
$(INSTALL) -D -m 0666 $(@D)/$(IPK_RACE_SOURCE) $(BINARIES_DIR)/main/pkgs
endef

$(eval $(generic-package))

0 comments on commit 6f3f361

Please sign in to comment.