From 630e1fbb519211111401114e8d64b96ecbf76b69 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Wed, 12 Apr 2023 22:39:02 -0300 Subject: ventoy-bin: rename to ventoy --- .../cd-dvd/ventoy-bin/000-nixos-sanitization.patch | 301 --------------------- pkgs/tools/cd-dvd/ventoy-bin/default.nix | 209 -------------- .../cd-dvd/ventoy/000-nixos-sanitization.patch | 301 +++++++++++++++++++++ pkgs/tools/cd-dvd/ventoy/default.nix | 208 ++++++++++++++ 4 files changed, 509 insertions(+), 510 deletions(-) delete mode 100644 pkgs/tools/cd-dvd/ventoy-bin/000-nixos-sanitization.patch delete mode 100644 pkgs/tools/cd-dvd/ventoy-bin/default.nix create mode 100644 pkgs/tools/cd-dvd/ventoy/000-nixos-sanitization.patch create mode 100644 pkgs/tools/cd-dvd/ventoy/default.nix (limited to 'pkgs/tools/cd-dvd') diff --git a/pkgs/tools/cd-dvd/ventoy-bin/000-nixos-sanitization.patch b/pkgs/tools/cd-dvd/ventoy-bin/000-nixos-sanitization.patch deleted file mode 100644 index 1d7afc5159c..00000000000 --- a/pkgs/tools/cd-dvd/ventoy-bin/000-nixos-sanitization.patch +++ /dev/null @@ -1,301 +0,0 @@ -A shameless merge of many patches floating around; indeed it was made by reading -and applying them manually. - -diff -Naur ventoy-1.0.81-old/CreatePersistentImg.sh ventoy-1.0.81-new/CreatePersistentImg.sh ---- ventoy-1.0.81-old/CreatePersistentImg.sh 2022-10-25 08:26:21.000000000 -0300 -+++ ventoy-1.0.81-new/CreatePersistentImg.sh 2022-11-02 10:29:07.355891607 -0300 -@@ -119,17 +119,13 @@ - sync - - if [ -n "$config" ]; then -- if [ -d ./persist_tmp_mnt ]; then -- rm -rf ./persist_tmp_mnt -- fi -- -- mkdir ./persist_tmp_mnt -- if mount $freeloop ./persist_tmp_mnt; then -- echo '/ union' > ./persist_tmp_mnt/$config -+ path_to_persist_mnt="`mktemp -d`" -+ if mount $freeloop "$path_to_persist_mnt"; then -+ echo '/ union' > "$path_to_persist_mnt"/$config - sync -- umount ./persist_tmp_mnt -+ umount "$path_to_persist_mnt" - fi -- rm -rf ./persist_tmp_mnt -+ rm -rf "$path_to_persist_mnt" - fi - - if [ ! -z "$passphrase" ]; then -diff -Naur ventoy-1.0.81-old/tool/ventoy_lib.sh ventoy-1.0.81-new/tool/ventoy_lib.sh ---- ventoy-1.0.81-old/tool/ventoy_lib.sh 2022-10-25 08:26:21.000000000 -0300 -+++ ventoy-1.0.81-new/tool/ventoy_lib.sh 2022-11-02 09:46:29.764568349 -0300 -@@ -6,6 +6,8 @@ - VENTOY_SECTOR_SIZE=512 - VENTOY_SECTOR_NUM=65536 - -+LOGFILE="/var/log/ventoy.log" -+ - ventoy_false() { - [ "1" = "2" ] - } -@@ -29,7 +31,7 @@ - } - - vtdebug() { -- echo "$*" >> ./log.txt -+ echo "$*" >> $LOGFILE - } - - vtoy_gen_uuid() { -@@ -51,31 +53,7 @@ - } - - check_tool_work_ok() { -- -- if echo 1 | hexdump > /dev/null; then -- vtdebug "hexdump test ok ..." -- else -- vtdebug "hexdump test fail ..." -- ventoy_false -- return -- fi -- -- if mkexfatfs -V > /dev/null; then -- vtdebug "mkexfatfs test ok ..." -- else -- vtdebug "mkexfatfs test fail ..." -- ventoy_false -- return -- fi -- -- if vtoycli fat -T; then -- vtdebug "vtoycli fat test ok ..." -- else -- vtdebug "vtoycli fat test fail ..." -- ventoy_false -- return -- fi -- -+ - vtdebug "tool check success ..." - ventoy_true - } -@@ -311,7 +289,7 @@ - else - vtdebug "format disk by fdisk ..." - --fdisk $DISK >>./log.txt 2>&1 <>$LOGFILE 2>&1 </dev/null 2>&1 -- rm -rf ./tmp_mnt -- if [ -d ./tmp_mnt ]; then -- vterr "tmp_mnt directory exists, please delete it first." -- exit 1 -- fi --fi -- -- - if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then - vtdebug "install Ventoy ..." - -@@ -567,16 +554,16 @@ - PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"') - - #reserve disk uuid -- rm -f ./diskuuid.bin -- dd status=none conv=fsync if=${DISK} skip=384 bs=1 count=16 of=./diskuuid.bin -+ path_to_diskuuid="`mktemp`" -+ dd status=none conv=fsync if=${DISK} skip=384 bs=1 count=16 of="$path_to_diskuuid" - - dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=440 -- dd status=none conv=fsync if=./diskuuid.bin of=$DISK bs=1 count=16 seek=384 -- rm -f ./diskuuid.bin -+ dd status=none conv=fsync if="$path_to_diskuuid" of=$DISK bs=1 count=16 seek=384 -+ rm -f "$path_to_diskuuid" - - #reserve data -- rm -f ./rsvdata.bin -- dd status=none conv=fsync if=${DISK} skip=2040 bs=512 count=8 of=./rsvdata.bin -+ path_to_rsvdata="`mktemp`" -+ dd status=none conv=fsync if=${DISK} skip=2040 bs=512 count=8 of="$path_to_rsvdata" - - if [ "$PART1_TYPE" = "EE" ]; then - vtdebug "This is GPT partition style ..." -@@ -598,8 +585,8 @@ - xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1 - fi - -- dd status=none conv=fsync if=./rsvdata.bin seek=2040 bs=512 count=8 of=${DISK} -- rm -f ./rsvdata.bin -+ dd status=none conv=fsync if="$path_to_rsvdata" seek=2040 bs=512 count=8 of=${DISK} -+ rm -f "$path_to_rsvdata" - - check_umount_disk "$DISK" - -diff -Naur ventoy-1.0.81-old/Ventoy2Disk.sh ventoy-1.0.81-new/Ventoy2Disk.sh ---- ventoy-1.0.81-old/Ventoy2Disk.sh 2022-10-25 08:26:21.000000000 -0300 -+++ ventoy-1.0.81-new/Ventoy2Disk.sh 2022-11-02 09:50:17.649369332 -0300 -@@ -32,48 +32,4 @@ - echo '**********************************************' - echo '' - -- --if ! [ -f ./boot/boot.img ]; then -- if [ -d ./grub ]; then -- echo "Don't run Ventoy2Disk.sh here, please download the released install package, and run the script in it." -- else -- echo "Please run under the correct directory!" -- fi -- exit 1 --fi -- --echo "############# Ventoy2Disk $* [$TOOLDIR] ################" >> ./log.txt --date >> ./log.txt -- --#decompress tool --echo "decompress tools" >> ./log.txt --cd ./tool/$TOOLDIR -- --ls *.xz > /dev/null 2>&1 --if [ $? -eq 0 ]; then -- [ -f ./xzcat ] && chmod +x ./xzcat -- -- for file in $(ls *.xz); do -- echo "decompress $file" >> ./log.txt -- xzcat $file > ${file%.xz} -- [ -f ./${file%.xz} ] && chmod +x ./${file%.xz} -- [ -f ./$file ] && rm -f ./$file -- done --fi -- --cd ../../ --chmod +x -R ./tool/$TOOLDIR -- -- --if [ -f /bin/bash ]; then -- /bin/bash ./tool/VentoyWorker.sh $* --else -- ash ./tool/VentoyWorker.sh $* --fi -- --if [ -n "$OLDDIR" ]; then -- CURDIR=$(pwd) -- if [ "$CURDIR" != "$OLDDIR" ]; then -- cd "$OLDDIR" -- fi --fi -+./tool/VentoyWorker.sh $* -diff -Naur ventoy-1.0.81-old/VentoyPlugson.sh ventoy-1.0.81-new/VentoyPlugson.sh ---- ventoy-1.0.81-old/VentoyPlugson.sh 2022-10-25 08:26:21.000000000 -0300 -+++ ventoy-1.0.81-new/VentoyPlugson.sh 2022-11-02 09:51:36.758360872 -0300 -@@ -43,39 +43,6 @@ - exit 1 - fi - -- --if ! [ -f "$OLDDIR/tool/plugson.tar.xz" ]; then -- echo "Please run under the correct directory!" -- exit 1 --fi -- --echo "############# VentoyPlugson $* [$TOOLDIR] ################" >> ./VentoyPlugson.log --date >> ./VentoyPlugson.log -- --echo "decompress tools" >> ./VentoyPlugson.log --cd ./tool/$TOOLDIR -- --ls *.xz > /dev/null 2>&1 --if [ $? -eq 0 ]; then -- [ -f ./xzcat ] && chmod +x ./xzcat -- -- for file in $(ls *.xz); do -- echo "decompress $file" >> ./VentoyPlugson.log -- xzcat $file > ${file%.xz} -- [ -f ./${file%.xz} ] && chmod +x ./${file%.xz} -- [ -f ./$file ] && rm -f ./$file -- done --fi -- --cd ../../ --chmod +x -R ./tool/$TOOLDIR -- --if ! [ -f "$OLDDIR/tool/$TOOLDIR/Plugson" ]; then -- echo "$OLDDIR/tool/$TOOLDIR/Plugson does not exist!" -- exit 1 --fi -- -- - PATH=./tool/$TOOLDIR:$PATH - - HOST="127.0.0.1" -@@ -217,11 +184,3 @@ - - wait $wID - fi -- -- --if [ -n "$OLDDIR" ]; then -- CURDIR=$(pwd) -- if [ "$CURDIR" != "$OLDDIR" ]; then -- cd "$OLDDIR" -- fi --fi -diff -Naur ventoy-1.0.81-old/VentoyWeb.sh ventoy-1.0.81-new/VentoyWeb.sh ---- ventoy-1.0.81-old/VentoyWeb.sh 2022-10-25 08:26:21.000000000 -0300 -+++ ventoy-1.0.81-new/VentoyWeb.sh 2022-11-02 09:53:13.773791254 -0300 -@@ -15,12 +15,6 @@ - echo "" - } - --uid=$(id -u) --if [ $uid -ne 0 ]; then -- print_err "Please use sudo or run the script as root." -- exit 1 --fi -- - OLDDIR=$(pwd) - - if uname -m | egrep -q 'aarch64|arm64'; then -@@ -85,8 +79,8 @@ - exit 1 - fi - --LOGFILE=log.txt --#delete the log.txt if it's more than 8MB -+LOGFILE=/var/log/ventoy.log -+#delete the logfile if it's more than 8MB - if [ -f $LOGFILE ]; then - logsize=$(stat -c '%s' $LOGFILE) - if [ $logsize -gt 8388608 ]; then -@@ -94,7 +88,6 @@ - fi - fi - -- - if [ -f ./tool/$TOOLDIR/V2DServer.xz ]; then - xz -d ./tool/$TOOLDIR/V2DServer.xz - chmod +x ./tool/$TOOLDIR/V2DServer diff --git a/pkgs/tools/cd-dvd/ventoy-bin/default.nix b/pkgs/tools/cd-dvd/ventoy-bin/default.nix deleted file mode 100644 index 3de0397d063..00000000000 --- a/pkgs/tools/cd-dvd/ventoy-bin/default.nix +++ /dev/null @@ -1,209 +0,0 @@ -{ lib -, stdenv -, fetchurl -, fetchpatch -, autoPatchelfHook -, bash -, copyDesktopItems -, coreutils -, cryptsetup -, dosfstools -, e2fsprogs -, exfat -, gawk -, gnugrep -, gnused -, gtk3 -, hexdump -, makeDesktopItem -, makeWrapper -, ntfs3g -, parted -, procps -, util-linux -, which -, xfsprogs -, xz -, defaultGuiType ? "" -, withCryptsetup ? false -, withXfs ? false -, withExt4 ? false -, withNtfs ? false -, withGtk3 ? false -, withQt5 ? false -, libsForQt5 -}: - -assert lib.elem defaultGuiType [ "" "gtk3" "qt5" ]; -assert defaultGuiType == "gtk3" -> withGtk3; -assert defaultGuiType == "qt5" -> withQt5; - -let - inherit (lib) optional optionalString; - inherit (libsForQt5) qtbase wrapQtAppsHook; - arch = { - x86_64-linux = "x86_64"; - i686-linux = "i386"; - aarch64-linux = "aarch64"; - mipsel-linux = "mips64el"; - }.${stdenv.hostPlatform.system} - or (throw "Unsupported platform ${stdenv.hostPlatform.system}"); -in -stdenv.mkDerivation (finalAttrs: { - pname = "ventoy-bin"; - version = "1.0.90"; - - src = let - inherit (finalAttrs) version; - in fetchurl { - url = "https://github.com/ventoy/Ventoy/releases/download/v${version}/ventoy-${version}-linux.tar.gz"; - hash = "sha256-UJ4kgtF2lIZn37p1SDkvCyHmuBSFSHmMHKLD4/ZorbQ="; - }; - - patches = [ - ./000-nixos-sanitization.patch - ]; - - postPatch = '' - # Fix permissions. - find -type f -name \*.sh -exec chmod a+x '{}' \; - - # Fix path to log. - sed -i 's:log\.txt:/var/log/ventoy\.log:g' \ - WebUI/static/js/languages.js tool/languages.json - ''; - - nativeBuildInputs = [ - autoPatchelfHook - makeWrapper - ] - ++ optional (withQt5 || withGtk3) copyDesktopItems - ++ optional withQt5 wrapQtAppsHook; - - buildInputs = [ - bash - coreutils - dosfstools - exfat - gawk - gnugrep - gnused - hexdump - parted - procps - util-linux - which - xz - ] - ++ optional withCryptsetup cryptsetup - ++ optional withExt4 e2fsprogs - ++ optional withGtk3 gtk3 - ++ optional withNtfs ntfs3g - ++ optional withXfs xfsprogs - ++ optional withQt5 qtbase; - - desktopItems = [ - (makeDesktopItem { - name = "Ventoy"; - desktopName = "Ventoy"; - comment = "Tool to create bootable USB drive for ISO/WIM/IMG/VHD(x)/EFI files"; - icon = "VentoyLogo"; - exec = "ventoy-gui"; - terminal = false; - categories = [ "Utility" ]; - startupNotify = true; - })]; - - dontConfigure = true; - dontBuild = true; - - installPhase = '' - runHook preInstall - - # Setup variables - local VENTOY_PATH="$out"/share/ventoy - local ARCH='${arch}' - - # Prepare - cd tool/"$ARCH" - rm ash* hexdump* mkexfatfs* mount.exfat-fuse* xzcat* - for archive in *.xz; do - xzcat "$archive" > "''${archive%.xz}" - rm "$archive" - done - chmod a+x * - cd - - - # Cleanup. - case "$ARCH" in - x86_64) rm -r {tool/,VentoyGUI.}{i386,aarch64,mips64el};; - i386) rm -r {tool/,VentoyGUI.}{x86_64,aarch64,mips64el};; - aarch64) rm -r {tool/,VentoyGUI.}{x86_64,i386,mips64el};; - mips64el) rm -r {tool/,VentoyGUI.}{x86_64,i386,aarch64};; - esac - rm README - rm tool/"$ARCH"/Ventoy2Disk.gtk2 || true # For aarch64 and mips64el. - - # Copy from "$src" to "$out" - mkdir -p "$out"/bin "$VENTOY_PATH" - cp -r . "$VENTOY_PATH" - - # Fill bin dir - for f in Ventoy2Disk.sh_ventoy VentoyWeb.sh_ventoy-web \ - CreatePersistentImg.sh_ventoy-persistent \ - ExtendPersistentImg.sh_ventoy-extend-persistent \ - VentoyPlugson.sh_ventoy-plugson; do - local bin="''${f%_*}" wrapper="''${f#*_}" - makeWrapper "$VENTOY_PATH/$bin" "$out/bin/$wrapper" \ - --prefix PATH : "${lib.makeBinPath finalAttrs.buildInputs}" \ - --chdir "$VENTOY_PATH" - done - '' - # VentoGUI uses the `ventoy_gui_type` file to determine the type of GUI. - # See: https://github.com/ventoy/Ventoy/blob/v1.0.78/LinuxGUI/Ventoy2Disk/ventoy_gui.c#L1096 - + optionalString (withGtk3 || withQt5) '' - echo "${defaultGuiType}" > "$VENTOY_PATH/ventoy_gui_type" - makeWrapper "$VENTOY_PATH/VentoyGUI.$ARCH" "$out/bin/ventoy-gui" \ - --prefix PATH : "${lib.makeBinPath finalAttrs.buildInputs}" \ - --chdir "$VENTOY_PATH" - mkdir "$out"/share/{applications,pixmaps} - ln -s "$VENTOY_PATH"/WebUI/static/img/VentoyLogo.png "$out"/share/pixmaps/ - '' - + optionalString (!withGtk3) '' - rm "$VENTOY_PATH"/tool/{"$ARCH"/Ventoy2Disk.gtk3,VentoyGTK.glade} - '' - + optionalString (!withQt5) '' - rm "$VENTOY_PATH/tool/$ARCH/Ventoy2Disk.qt5" - '' - + optionalString (!withGtk3 && !withQt5) '' - rm "$VENTOY_PATH"/VentoyGUI.* - '' + - '' - - runHook postInstall - ''; - - meta = with lib; { - homepage = "https://www.ventoy.net"; - description = "A New Bootable USB Solution"; - longDescription = '' - Ventoy is an open source tool to create bootable USB drive for - ISO/WIM/IMG/VHD(x)/EFI files. With ventoy, you don't need to format the - disk over and over, you just need to copy the ISO/WIM/IMG/VHD(x)/EFI files - to the USB drive and boot them directly. You can copy many files at a time - and ventoy will give you a boot menu to select them. You can also browse - ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them. x86 Legacy - BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI are supported - in the same way. Most type of OS supported - (Windows/WinPE/Linux/ChromeOS/Unix/VMware/Xen...). With ventoy you can - also browse ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them. - 800+ image files are tested. 90%+ distros in DistroWatch supported. - ''; - changelog = "https://www.ventoy.net/doc_news.html"; - license = licenses.gpl3Plus; - maintainers = with maintainers; [ AndersonTorres ]; - platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "mipsel-linux" ]; - sourceProvenance = with sourceTypes; [ binaryNativeCode ]; - mainProgram = "ventoy"; - }; -}) diff --git a/pkgs/tools/cd-dvd/ventoy/000-nixos-sanitization.patch b/pkgs/tools/cd-dvd/ventoy/000-nixos-sanitization.patch new file mode 100644 index 00000000000..1d7afc5159c --- /dev/null +++ b/pkgs/tools/cd-dvd/ventoy/000-nixos-sanitization.patch @@ -0,0 +1,301 @@ +A shameless merge of many patches floating around; indeed it was made by reading +and applying them manually. + +diff -Naur ventoy-1.0.81-old/CreatePersistentImg.sh ventoy-1.0.81-new/CreatePersistentImg.sh +--- ventoy-1.0.81-old/CreatePersistentImg.sh 2022-10-25 08:26:21.000000000 -0300 ++++ ventoy-1.0.81-new/CreatePersistentImg.sh 2022-11-02 10:29:07.355891607 -0300 +@@ -119,17 +119,13 @@ + sync + + if [ -n "$config" ]; then +- if [ -d ./persist_tmp_mnt ]; then +- rm -rf ./persist_tmp_mnt +- fi +- +- mkdir ./persist_tmp_mnt +- if mount $freeloop ./persist_tmp_mnt; then +- echo '/ union' > ./persist_tmp_mnt/$config ++ path_to_persist_mnt="`mktemp -d`" ++ if mount $freeloop "$path_to_persist_mnt"; then ++ echo '/ union' > "$path_to_persist_mnt"/$config + sync +- umount ./persist_tmp_mnt ++ umount "$path_to_persist_mnt" + fi +- rm -rf ./persist_tmp_mnt ++ rm -rf "$path_to_persist_mnt" + fi + + if [ ! -z "$passphrase" ]; then +diff -Naur ventoy-1.0.81-old/tool/ventoy_lib.sh ventoy-1.0.81-new/tool/ventoy_lib.sh +--- ventoy-1.0.81-old/tool/ventoy_lib.sh 2022-10-25 08:26:21.000000000 -0300 ++++ ventoy-1.0.81-new/tool/ventoy_lib.sh 2022-11-02 09:46:29.764568349 -0300 +@@ -6,6 +6,8 @@ + VENTOY_SECTOR_SIZE=512 + VENTOY_SECTOR_NUM=65536 + ++LOGFILE="/var/log/ventoy.log" ++ + ventoy_false() { + [ "1" = "2" ] + } +@@ -29,7 +31,7 @@ + } + + vtdebug() { +- echo "$*" >> ./log.txt ++ echo "$*" >> $LOGFILE + } + + vtoy_gen_uuid() { +@@ -51,31 +53,7 @@ + } + + check_tool_work_ok() { +- +- if echo 1 | hexdump > /dev/null; then +- vtdebug "hexdump test ok ..." +- else +- vtdebug "hexdump test fail ..." +- ventoy_false +- return +- fi +- +- if mkexfatfs -V > /dev/null; then +- vtdebug "mkexfatfs test ok ..." +- else +- vtdebug "mkexfatfs test fail ..." +- ventoy_false +- return +- fi +- +- if vtoycli fat -T; then +- vtdebug "vtoycli fat test ok ..." +- else +- vtdebug "vtoycli fat test fail ..." +- ventoy_false +- return +- fi +- ++ + vtdebug "tool check success ..." + ventoy_true + } +@@ -311,7 +289,7 @@ + else + vtdebug "format disk by fdisk ..." + +-fdisk $DISK >>./log.txt 2>&1 <>$LOGFILE 2>&1 </dev/null 2>&1 +- rm -rf ./tmp_mnt +- if [ -d ./tmp_mnt ]; then +- vterr "tmp_mnt directory exists, please delete it first." +- exit 1 +- fi +-fi +- +- + if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then + vtdebug "install Ventoy ..." + +@@ -567,16 +554,16 @@ + PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"') + + #reserve disk uuid +- rm -f ./diskuuid.bin +- dd status=none conv=fsync if=${DISK} skip=384 bs=1 count=16 of=./diskuuid.bin ++ path_to_diskuuid="`mktemp`" ++ dd status=none conv=fsync if=${DISK} skip=384 bs=1 count=16 of="$path_to_diskuuid" + + dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=440 +- dd status=none conv=fsync if=./diskuuid.bin of=$DISK bs=1 count=16 seek=384 +- rm -f ./diskuuid.bin ++ dd status=none conv=fsync if="$path_to_diskuuid" of=$DISK bs=1 count=16 seek=384 ++ rm -f "$path_to_diskuuid" + + #reserve data +- rm -f ./rsvdata.bin +- dd status=none conv=fsync if=${DISK} skip=2040 bs=512 count=8 of=./rsvdata.bin ++ path_to_rsvdata="`mktemp`" ++ dd status=none conv=fsync if=${DISK} skip=2040 bs=512 count=8 of="$path_to_rsvdata" + + if [ "$PART1_TYPE" = "EE" ]; then + vtdebug "This is GPT partition style ..." +@@ -598,8 +585,8 @@ + xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1 + fi + +- dd status=none conv=fsync if=./rsvdata.bin seek=2040 bs=512 count=8 of=${DISK} +- rm -f ./rsvdata.bin ++ dd status=none conv=fsync if="$path_to_rsvdata" seek=2040 bs=512 count=8 of=${DISK} ++ rm -f "$path_to_rsvdata" + + check_umount_disk "$DISK" + +diff -Naur ventoy-1.0.81-old/Ventoy2Disk.sh ventoy-1.0.81-new/Ventoy2Disk.sh +--- ventoy-1.0.81-old/Ventoy2Disk.sh 2022-10-25 08:26:21.000000000 -0300 ++++ ventoy-1.0.81-new/Ventoy2Disk.sh 2022-11-02 09:50:17.649369332 -0300 +@@ -32,48 +32,4 @@ + echo '**********************************************' + echo '' + +- +-if ! [ -f ./boot/boot.img ]; then +- if [ -d ./grub ]; then +- echo "Don't run Ventoy2Disk.sh here, please download the released install package, and run the script in it." +- else +- echo "Please run under the correct directory!" +- fi +- exit 1 +-fi +- +-echo "############# Ventoy2Disk $* [$TOOLDIR] ################" >> ./log.txt +-date >> ./log.txt +- +-#decompress tool +-echo "decompress tools" >> ./log.txt +-cd ./tool/$TOOLDIR +- +-ls *.xz > /dev/null 2>&1 +-if [ $? -eq 0 ]; then +- [ -f ./xzcat ] && chmod +x ./xzcat +- +- for file in $(ls *.xz); do +- echo "decompress $file" >> ./log.txt +- xzcat $file > ${file%.xz} +- [ -f ./${file%.xz} ] && chmod +x ./${file%.xz} +- [ -f ./$file ] && rm -f ./$file +- done +-fi +- +-cd ../../ +-chmod +x -R ./tool/$TOOLDIR +- +- +-if [ -f /bin/bash ]; then +- /bin/bash ./tool/VentoyWorker.sh $* +-else +- ash ./tool/VentoyWorker.sh $* +-fi +- +-if [ -n "$OLDDIR" ]; then +- CURDIR=$(pwd) +- if [ "$CURDIR" != "$OLDDIR" ]; then +- cd "$OLDDIR" +- fi +-fi ++./tool/VentoyWorker.sh $* +diff -Naur ventoy-1.0.81-old/VentoyPlugson.sh ventoy-1.0.81-new/VentoyPlugson.sh +--- ventoy-1.0.81-old/VentoyPlugson.sh 2022-10-25 08:26:21.000000000 -0300 ++++ ventoy-1.0.81-new/VentoyPlugson.sh 2022-11-02 09:51:36.758360872 -0300 +@@ -43,39 +43,6 @@ + exit 1 + fi + +- +-if ! [ -f "$OLDDIR/tool/plugson.tar.xz" ]; then +- echo "Please run under the correct directory!" +- exit 1 +-fi +- +-echo "############# VentoyPlugson $* [$TOOLDIR] ################" >> ./VentoyPlugson.log +-date >> ./VentoyPlugson.log +- +-echo "decompress tools" >> ./VentoyPlugson.log +-cd ./tool/$TOOLDIR +- +-ls *.xz > /dev/null 2>&1 +-if [ $? -eq 0 ]; then +- [ -f ./xzcat ] && chmod +x ./xzcat +- +- for file in $(ls *.xz); do +- echo "decompress $file" >> ./VentoyPlugson.log +- xzcat $file > ${file%.xz} +- [ -f ./${file%.xz} ] && chmod +x ./${file%.xz} +- [ -f ./$file ] && rm -f ./$file +- done +-fi +- +-cd ../../ +-chmod +x -R ./tool/$TOOLDIR +- +-if ! [ -f "$OLDDIR/tool/$TOOLDIR/Plugson" ]; then +- echo "$OLDDIR/tool/$TOOLDIR/Plugson does not exist!" +- exit 1 +-fi +- +- + PATH=./tool/$TOOLDIR:$PATH + + HOST="127.0.0.1" +@@ -217,11 +184,3 @@ + + wait $wID + fi +- +- +-if [ -n "$OLDDIR" ]; then +- CURDIR=$(pwd) +- if [ "$CURDIR" != "$OLDDIR" ]; then +- cd "$OLDDIR" +- fi +-fi +diff -Naur ventoy-1.0.81-old/VentoyWeb.sh ventoy-1.0.81-new/VentoyWeb.sh +--- ventoy-1.0.81-old/VentoyWeb.sh 2022-10-25 08:26:21.000000000 -0300 ++++ ventoy-1.0.81-new/VentoyWeb.sh 2022-11-02 09:53:13.773791254 -0300 +@@ -15,12 +15,6 @@ + echo "" + } + +-uid=$(id -u) +-if [ $uid -ne 0 ]; then +- print_err "Please use sudo or run the script as root." +- exit 1 +-fi +- + OLDDIR=$(pwd) + + if uname -m | egrep -q 'aarch64|arm64'; then +@@ -85,8 +79,8 @@ + exit 1 + fi + +-LOGFILE=log.txt +-#delete the log.txt if it's more than 8MB ++LOGFILE=/var/log/ventoy.log ++#delete the logfile if it's more than 8MB + if [ -f $LOGFILE ]; then + logsize=$(stat -c '%s' $LOGFILE) + if [ $logsize -gt 8388608 ]; then +@@ -94,7 +88,6 @@ + fi + fi + +- + if [ -f ./tool/$TOOLDIR/V2DServer.xz ]; then + xz -d ./tool/$TOOLDIR/V2DServer.xz + chmod +x ./tool/$TOOLDIR/V2DServer diff --git a/pkgs/tools/cd-dvd/ventoy/default.nix b/pkgs/tools/cd-dvd/ventoy/default.nix new file mode 100644 index 00000000000..21ba7391d3f --- /dev/null +++ b/pkgs/tools/cd-dvd/ventoy/default.nix @@ -0,0 +1,208 @@ +{ lib +, stdenv +, fetchurl +, fetchpatch +, autoPatchelfHook +, bash +, copyDesktopItems +, coreutils +, cryptsetup +, dosfstools +, e2fsprogs +, exfat +, gawk +, gnugrep +, gnused +, gtk3 +, hexdump +, makeDesktopItem +, makeWrapper +, ntfs3g +, parted +, procps +, util-linux +, which +, xfsprogs +, xz +, defaultGuiType ? "" +, withCryptsetup ? false +, withXfs ? false +, withExt4 ? false +, withNtfs ? false +, withGtk3 ? false +, withQt5 ? false +, libsForQt5 +}: + +assert lib.elem defaultGuiType [ "" "gtk3" "qt5" ]; +assert defaultGuiType == "gtk3" -> withGtk3; +assert defaultGuiType == "qt5" -> withQt5; + +let + inherit (lib) optional optionalString; + inherit (libsForQt5) qtbase wrapQtAppsHook; + arch = { + x86_64-linux = "x86_64"; + i686-linux = "i386"; + aarch64-linux = "aarch64"; + mipsel-linux = "mips64el"; + }.${stdenv.hostPlatform.system} + or (throw "Unsupported platform ${stdenv.hostPlatform.system}"); +in +stdenv.mkDerivation (finalAttrs: { + pname = "ventoy"; + version = "1.0.90"; + + src = let + inherit (finalAttrs) version; + in fetchurl { + url = "https://github.com/ventoy/Ventoy/releases/download/v${version}/ventoy-${version}-linux.tar.gz"; + hash = "sha256-UJ4kgtF2lIZn37p1SDkvCyHmuBSFSHmMHKLD4/ZorbQ="; + }; + + patches = [ + ./000-nixos-sanitization.patch + ]; + + postPatch = '' + # Fix permissions. + find -type f -name \*.sh -exec chmod a+x '{}' \; + + # Fix path to log. + sed -i 's:log\.txt:/var/log/ventoy\.log:g' \ + WebUI/static/js/languages.js tool/languages.json + ''; + + nativeBuildInputs = [ + autoPatchelfHook + makeWrapper + ] + ++ optional (withQt5 || withGtk3) copyDesktopItems + ++ optional withQt5 wrapQtAppsHook; + + buildInputs = [ + bash + coreutils + dosfstools + exfat + gawk + gnugrep + gnused + hexdump + parted + procps + util-linux + which + xz + ] + ++ optional withCryptsetup cryptsetup + ++ optional withExt4 e2fsprogs + ++ optional withGtk3 gtk3 + ++ optional withNtfs ntfs3g + ++ optional withXfs xfsprogs + ++ optional withQt5 qtbase; + + desktopItems = [ + (makeDesktopItem { + name = "Ventoy"; + desktopName = "Ventoy"; + comment = "Tool to create bootable USB drive for ISO/WIM/IMG/VHD(x)/EFI files"; + icon = "VentoyLogo"; + exec = "ventoy-gui"; + terminal = false; + categories = [ "Utility" ]; + startupNotify = true; + })]; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + # Setup variables + local VENTOY_PATH="$out"/share/ventoy + local ARCH='${arch}' + + # Prepare + cd tool/"$ARCH" + rm ash* hexdump* mkexfatfs* mount.exfat-fuse* xzcat* + for archive in *.xz; do + xzcat "$archive" > "''${archive%.xz}" + rm "$archive" + done + chmod a+x * + cd - + + # Cleanup. + case "$ARCH" in + x86_64) rm -r {tool/,VentoyGUI.}{i386,aarch64,mips64el};; + i386) rm -r {tool/,VentoyGUI.}{x86_64,aarch64,mips64el};; + aarch64) rm -r {tool/,VentoyGUI.}{x86_64,i386,mips64el};; + mips64el) rm -r {tool/,VentoyGUI.}{x86_64,i386,aarch64};; + esac + rm README + rm tool/"$ARCH"/Ventoy2Disk.gtk2 || true # For aarch64 and mips64el. + + # Copy from "$src" to "$out" + mkdir -p "$out"/bin "$VENTOY_PATH" + cp -r . "$VENTOY_PATH" + + # Fill bin dir + for f in Ventoy2Disk.sh_ventoy VentoyWeb.sh_ventoy-web \ + CreatePersistentImg.sh_ventoy-persistent \ + ExtendPersistentImg.sh_ventoy-extend-persistent \ + VentoyPlugson.sh_ventoy-plugson; do + local bin="''${f%_*}" wrapper="''${f#*_}" + makeWrapper "$VENTOY_PATH/$bin" "$out/bin/$wrapper" \ + --prefix PATH : "${lib.makeBinPath finalAttrs.buildInputs}" \ + --chdir "$VENTOY_PATH" + done + '' + # VentoGUI uses the `ventoy_gui_type` file to determine the type of GUI. + # See: https://github.com/ventoy/Ventoy/blob/v1.0.78/LinuxGUI/Ventoy2Disk/ventoy_gui.c#L1096 + + optionalString (withGtk3 || withQt5) '' + echo "${defaultGuiType}" > "$VENTOY_PATH/ventoy_gui_type" + makeWrapper "$VENTOY_PATH/VentoyGUI.$ARCH" "$out/bin/ventoy-gui" \ + --prefix PATH : "${lib.makeBinPath finalAttrs.buildInputs}" \ + --chdir "$VENTOY_PATH" + mkdir "$out"/share/{applications,pixmaps} + ln -s "$VENTOY_PATH"/WebUI/static/img/VentoyLogo.png "$out"/share/pixmaps/ + '' + + optionalString (!withGtk3) '' + rm "$VENTOY_PATH"/tool/{"$ARCH"/Ventoy2Disk.gtk3,VentoyGTK.glade} + '' + + optionalString (!withQt5) '' + rm "$VENTOY_PATH/tool/$ARCH/Ventoy2Disk.qt5" + '' + + optionalString (!withGtk3 && !withQt5) '' + rm "$VENTOY_PATH"/VentoyGUI.* + '' + + '' + + runHook postInstall + ''; + + meta = { + homepage = "https://www.ventoy.net"; + description = "A New Bootable USB Solution"; + longDescription = '' + Ventoy is an open source tool to create bootable USB drive for + ISO/WIM/IMG/VHD(x)/EFI files. With ventoy, you don't need to format the + disk over and over, you just need to copy the ISO/WIM/IMG/VHD(x)/EFI files + to the USB drive and boot them directly. You can copy many files at a time + and ventoy will give you a boot menu to select them. You can also browse + ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them. x86 Legacy + BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI are supported + in the same way. Most type of OS supported + (Windows/WinPE/Linux/ChromeOS/Unix/VMware/Xen...). With ventoy you can + also browse ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them. + 800+ image files are tested. 90%+ distros in DistroWatch supported. + ''; + changelog = "https://www.ventoy.net/doc_news.html"; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ AndersonTorres ]; + platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "mipsel-linux" ]; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + }; +}) -- cgit 1.4.1