Port the sgdisk utilit form the gptfdisk package

This commit is contained in:
Pirmin Duss
2019-05-10 14:29:25 +02:00
committed by Norman Feske
parent 71193e0f5c
commit 5c353771ba
6 changed files with 207 additions and 0 deletions

1
ports/gptfdisk.hash Normal file
View File

@@ -0,0 +1 @@
8799b535db3d55dca0fef5c73f383d4536ddc50d

9
ports/gptfdisk.port Normal file
View File

@@ -0,0 +1,9 @@
LICENSE := GPLv2
VERSION := 0.8.1
DOWNLOADS := gptfdisk.git
URL(gptfdisk) := https://github.com/kini/gptfdisk.git
REV(gptfdisk) := 0541b56fee4e92822340a2b2387508dd58d0ca7c
DIR(gptfdisk) := src/app/gptfdisk
PATCHES := src/app/sgdisk/patches/*.patch

140
run/sgdisk.run Normal file
View File

@@ -0,0 +1,140 @@
create_boot_directory
import_from_depot [depot_user]/src/[base_src] \
[depot_user]/src/acpi_drv \
[depot_user]/src/ahci_drv \
[depot_user]/src/init \
[depot_user]/src/libc \
[depot_user]/src/ncurses \
[depot_user]/src/platform_drv \
[depot_user]/src/posix \
[depot_user]/src/report_rom \
[depot_user]/src/stdcxx \
[depot_user]/src/vfs
build { app/sgdisk }
set config {
<config verbose="yes">
<parent-provides>
<service name="CPU"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="IRQ"/>
<service name="LOG"/>
<service name="PD"/>
<service name="RM"/>
<service name="ROM"/>
</parent-provides>
<start name="timer" caps="100">
<resource name="RAM" quantum="10M"/>
<provides>
<service name="Timer"/>
</provides>
<route>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
<start name="report_rom" caps="300">
<resource name="RAM" quantum="2M"/>
<provides>
<service name="Report"/>
<service name="ROM"/>
</provides>
<config verbose="yes">
<policy label="platform_drv -> acpi" report="acpi_drv -> acpi"/>
</config>
<route>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
<start name="acpi_drv" caps="300">
<resource name="RAM" quantum="4M"/>
<route>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
<start name="platform_drv" caps="200">
<resource name="RAM" quantum="3M" constrain_phys="yes"/>
<provides>
<service name="Platform"/>
<service name="Acpi"/>
</provides>
<config>
<policy label_prefix="ahci_drv"> <pci class="AHCI"/> </policy>
</config>
<route>
<service name="ROM" label="acpi"> <child name="report_rom"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
<start name="ahci_drv" caps="100">
<resource name="RAM" quantum="10M"/>
<provides>
<service name="Block"/>
</provides>
<config>
<default-policy device="0" writeable="yes"/>
</config>
<route>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
<start name="sgdisk" caps="100">
<resource name="RAM" quantum="8M"/>
<config>
<libc stdout="/dev/log" stderr="/dev/log"/>
<vfs>
<dir name="dev">
<block name="block"/>
<inline name="rtc">2000-01-01 00:00</inline>
<log/>
</dir>
</vfs>
<arg value="sgdisk"/>
<arg value="--new=1:2048:10239"/>
<arg value="--change-name=1:boot"/>
<arg value="--new=2:10240:28671"/>
<arg value="--change-name=2:root"/>
<arg value="--new=3:28672:40926"/>
<arg value="--change-name=3:stuff"/>
<arg value="-p"/>
<arg value="/dev/block"/>
</config>
<route>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
</config>
}
install_config $config
build_boot_image {
sgdisk
libuuid.lib.so
popt.lib.so
}
# Create empty image file!
set image_file "bin/image.raw"
set image_size 20
eval "exec -ignorestderr dd if=/dev/zero of=$image_file bs=1M count=$image_size"
append qemu_args " -nographic -device ahci,id=ahci "
append qemu_args " -drive id=disk,file=$image_file,format=raw,if=none -device ide-hd,drive=disk,bus=ahci.0 -boot d "
run_genode_until ".*child \"sgdisk\" exited.*\n" 20

View File

@@ -0,0 +1,11 @@
index 3735b9f..ec083cf 100644
--- src/app/gptfdisk/diskio-unix.cc
+++ src/app/gptfdisk/diskio-unix.cc
@@ -21,6 +21,7 @@
#include <stdint.h>
#include <errno.h>
#include <fcntl.h>
+#include <unistd.h>
#include <sys/stat.h>
#ifdef __linux__

View File

@@ -0,0 +1,11 @@
--- src/app/gptfdisk/guid.h
+++ src/app/gptfdisk/guid.h
@@ -26,7 +26,7 @@
#endif
typedef unsigned char my_uuid_t[16];
#else // Not Windows
-#include <uuid/uuid.h>
+#include <uuid.h>
typedef uuid_t my_uuid_t;
#endif

35
src/app/sgdisk/target.mk Normal file
View File

@@ -0,0 +1,35 @@
TARGET = sgdisk
LIBS += libc stdcxx posix libuuid popt ncurses
GPTFDISK_PORT_DIR := $(call select_from_ports,gptfdisk)
GPTFDISK_DIR := $(GPTFDISK_PORT_DIR)/src/app/gptfdisk
SRC_CC := attributes.cc
SRC_CC += basicmbr.cc
SRC_CC += bsd.cc
SRC_CC += crc32.cc
SRC_CC += diskio-unix.cc
SRC_CC += diskio.cc
SRC_CC += gpt.cc
SRC_CC += gptcl.cc
SRC_CC += gptcurses.cc
SRC_CC += gptpart.cc
SRC_CC += gpttext.cc
SRC_CC += guid.cc
SRC_CC += mbr.cc
SRC_CC += mbrpart.cc
SRC_CC += parttypes.cc
SRC_CC += sgdisk.cc
SRC_CC += support.cc
CC_CXX_OPT += -fpermissive
# too much to cope with...
CC_WARN =
vpath %.cc $(REP_DIR)/src/app/gptfdisk
vpath %.cc $(GPTFDISK_DIR)
CC_CXX_WARN_STRICT =