commit:     b1f88cefc7130951876e3ced6cdfb6bec6d6f58d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  1 18:51:59 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun  1 18:53:38 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b1f88cef

sys-fs/mac-fdisk-0.1_p18-r1: revbump to allow partitioning 2TB drives

while at it, ease lives of musl users by ensuring prompts are written

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 sys-fs/mac-fdisk/files/mac-fdisk-0.1_p18-2tb.patch | 164 +++++++++++++++++++++
 .../mac-fdisk/files/mac-fdisk-0.1_p18-musl.patch   |  68 +++++++++
 sys-fs/mac-fdisk/mac-fdisk-0.1_p18-r1.ebuild       |  53 +++++++
 3 files changed, 285 insertions(+)

diff --git a/sys-fs/mac-fdisk/files/mac-fdisk-0.1_p18-2tb.patch 
b/sys-fs/mac-fdisk/files/mac-fdisk-0.1_p18-2tb.patch
new file mode 100644
index 000000000000..bb7c4222a4df
--- /dev/null
+++ b/sys-fs/mac-fdisk/files/mac-fdisk-0.1_p18-2tb.patch
@@ -0,0 +1,164 @@
[email protected]
+
+not sure what big_pt.patch was tested on, but partitioning a 2TB disk
+(Blocks=3907029168) won't work, with a daft warning, and no joy
+
+upgrade size storage to unsigned long long, so we can store these sizes
+tested on a PowerMac G5 with a 2TB SATA drive
+
+
+--- mac-fdisk-0.1.orig/io.c    2022-06-01 19:37:08.000000000 +0200
++++ mac-fdisk-0.1.orig/io.c    2022-06-01 20:32:12.000000000 +0200
+@@ -85,7 +85,7 @@
+ //
+ // Forward declarations
+ //
+-long get_number(int first_char);
++long long get_number(int first_char);
+ char* get_string(int eos);
+ #ifndef __linux__
+ int DoTestUnitReady(UInt8 targetID);
+@@ -201,9 +205,8 @@
+     return 0;
+ }
+ 
+-      
+ int
+-get_number_argument(char *prompt, long *number, long default_value)
++get_number_argument_long(char *prompt, long long *number, long long 
default_value)
+ {
+     int c;
+     int result = 0;
+@@ -237,14 +241,22 @@
+     return result;
+ }
+ 
++int
++get_number_argument(char *prompt, long *number, long default_value)
++{
++    long long retval = (long long)default_value;
++    int ret = get_number_argument_long(prompt, &retval, retval);
++    *number = (long)retval;
++    return ret;
++}
+ 
+-long
++long long
+ get_number(int first_char)
+ {
+     register int c;
+     int base;
+     int digit;
+-    int ret_value;
++    long long ret_value;
+ 
+     if (first_char != '0') {
+       c = first_char;
+--- mac-fdisk-0.1.orig/io.h    1997-01-09 23:31:31.000000000 +0100
++++ mac-fdisk-0.1.orig/io.h    2022-06-01 20:10:20.000000000 +0200
+@@ -57,6 +57,7 @@
+ int get_command(char *prompt, int promptBeforeGet, int *command);
+ long get_multiplier(long divisor);
+ int get_number_argument(char *prompt, long *number, long default_value);
++int get_number_argument_long(char *prompt, long long *number, long long 
default_value);
+ int get_okay(char *prompt, int default_value);
+ int get_string_argument(char *prompt, char **string, int reprompt);
+ int getch();
+--- mac-fdisk-0.1.orig/partition_map.c 2022-06-01 19:37:08.000000000 +0200
++++ mac-fdisk-0.1.orig/partition_map.c 2022-06-01 20:16:26.000000000 +0200
+@@ -90,7 +90,7 @@
+ void coerce_block0(partition_map_header *map);
+ int contains_driver(partition_map *entry);
+ void combine_entry(partition_map *entry);
+-long compute_device_size(int fd);
++unsigned long long compute_device_size(int fd);
+ DPME* create_data(const char *name, const char *dptype, u32 base, u32 length);
+ partition_map_header* create_partition_map(char *name);
+ void delete_entry(partition_map *entry);
+@@ -407,7 +407,7 @@
+     int fd;
+     partition_map_header * map;
+     DPME *data;
+-    unsigned long number;
++    unsigned long long number;
+ #ifdef __linux__
+     struct stat info;
+ #endif
+@@ -435,13 +435,14 @@
+     map->maximum_in_map = -1;
+ 
+     number = compute_device_size(fd);
+-    printf("size of 'device' is %u blocks: ", (unsigned int)number);
++    printf("size of 'device' is %llu blocks: ", number);
++    fflush(NULL);
+     flush_to_newline(0);
+-    get_number_argument("what should be the size? ", (long *)&number, number);
++    get_number_argument_long("what should be the size? ", (long long 
*)&number, (long long)number);
+     if (number < 4) {
+       number = 4;
+     }
+-    printf("new size of 'device' is %u blocks\n", (unsigned int)number);
++    printf("new size of 'device' is %llu blocks\n", number);
+     map->media_size = number;
+ 
+ #ifdef __linux__
+@@ -468,7 +469,7 @@
+           data->dpme_signature = DPME_SIGNATURE;
+           data->dpme_map_entries = 1;
+           data->dpme_pblock_start = 1;
+-          data->dpme_pblocks = map->media_size - 1;
++          data->dpme_pblocks = (u32)(map->media_size - 1);
+           strncpy(data->dpme_name, kFreeName, DPISTRLEN);
+           strncpy(data->dpme_type, kFreeType, DPISTRLEN);
+           data->dpme_lblock_start = 0;
+@@ -506,7 +507,7 @@
+     if (p->sbSig != BLOCK0_SIGNATURE) {
+       p->sbSig = BLOCK0_SIGNATURE;
+       p->sbBlkSize = 512;
+-      p->sbBlkCount = map->media_size;
++      p->sbBlkCount = (u32)map->media_size;
+       p->sbDevType = 0;
+       p->sbDevId = 0;
+       p->sbData = 0;
+@@ -573,7 +574,7 @@
+     }
+       // if the map will overflow then punt
+     if (map->maximum_in_map < 0) {
+-      limit = map->media_size;
++      limit = (int)map->media_size;
+     } else {
+       limit = map->maximum_in_map;
+     }
+@@ -661,7 +662,7 @@
+ }
+ 
+ 
+-long
++unsigned long long
+ compute_device_size(int fd)
+ {
+ #ifdef TEST_COMPUTE
+@@ -753,11 +754,7 @@
+       free(data);
+     }
+     
+-    // Add a warning just in case...
+-    if(x > 0x80000000)
+-      printf("Warning: Large disks may not work with this tool!\n");
+-
+-    return (unsigned long) x;
++    return x;
+ }
+ 
+ 
+--- mac-fdisk-0.1.orig/partition_map.h 2022-06-01 19:37:08.000000000 +0200
++++ mac-fdisk-0.1.orig/partition_map.h 2022-06-01 19:37:49.000000000 +0200
+@@ -47,7 +47,7 @@
+     int regular_file;
+     int blocks_in_map;
+     int maximum_in_map;
+-    unsigned long media_size;
++    unsigned long long media_size;
+ };
+ typedef struct partition_map_header partition_map_header;
+ 

diff --git a/sys-fs/mac-fdisk/files/mac-fdisk-0.1_p18-musl.patch 
b/sys-fs/mac-fdisk/files/mac-fdisk-0.1_p18-musl.patch
new file mode 100644
index 000000000000..e99d6f5941d6
--- /dev/null
+++ b/sys-fs/mac-fdisk/files/mac-fdisk-0.1_p18-musl.patch
@@ -0,0 +1,68 @@
[email protected]
+
+auto-flush on stdio is really a glibc feature AFAICT, so in order for
+musl to get prompts (and make the tool more bearable) just flush right
+after writing half a line
+
+--- mac-fdisk-0.1.orig/io.c    2022-06-01 19:37:08.000000000 +0200
++++ mac-fdisk-0.1.orig/io.c    2022-06-01 20:32:12.000000000 +0200
+@@ -151,7 +151,8 @@
+     int               c;
+ 
+     flush_to_newline(0);
+-    printf(prompt);
++    printf("%s", prompt);
++    fflush(NULL);
+ 
+     for (;;) {
+       c = getch();
+@@ -169,7 +170,8 @@
+           return 0;
+       } else {
+           flush_to_newline(0);
+-          printf(prompt);
++          printf("%s", prompt);
++          fflush(NULL);
+       }
+     }
+     return -1;
+@@ -182,7 +184,8 @@
+     int               c;
+ 
+     if (promptBeforeGet) {
+-      printf(prompt);
++      printf("%s", prompt);
++      fflush(NULL);
+     } 
+     for (;;) {
+       c = getch();
+@@ -192,7 +195,8 @@
+       } else if (c == ' ' || c == '\t') {
+           // skip blanks and tabs
+       } else if (c == '\n') {
+-          printf(prompt);
++          printf("%s", prompt);
++          fflush(NULL);
+       } else {
+           *command = c;
+           return 1;
+@@ -217,7 +220,8 @@
+           // skip blanks and tabs
+       } else if (c == '\n') {
+           if (default_value < 0) {
+-              printf(prompt);
++              printf("%s", prompt);
++              fflush(NULL);
+           } else {
+               ungetch(c);
+               *number = default_value;
+@@ -295,7 +307,8 @@
+           // skip blanks and tabs
+       } else if (c == '\n') {
+           if (reprompt) {
+-              printf(prompt);
++              printf("%s", prompt);
++              fflush(NULL);
+           } else {
+               ungetch(c);
+               *string = NULL;

diff --git a/sys-fs/mac-fdisk/mac-fdisk-0.1_p18-r1.ebuild 
b/sys-fs/mac-fdisk/mac-fdisk-0.1_p18-r1.ebuild
new file mode 100644
index 000000000000..dad62e50d2ac
--- /dev/null
+++ b/sys-fs/mac-fdisk/mac-fdisk-0.1_p18-r1.ebuild
@@ -0,0 +1,53 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit toolchain-funcs flag-o-matic
+
+DESCRIPTION="Mac/PowerMac disk partitioning utility"
+HOMEPAGE="ftp://ftp.mklinux.apple.com/pub/Other_Tools/";
+SRC_URI="
+       mirror://debian/pool/main/m/mac-fdisk/${PN}_${PV/_p*}.orig.tar.gz
+       mirror://debian/pool/main/m/mac-fdisk/${PN}_${PV/_p*}-${PV/*_p}.diff.gz
+"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~ppc ~ppc64 -riscv ~x86"
+
+S=${WORKDIR}/${P/_p*}.orig
+PATCHES=(
+       "${WORKDIR}"/${PN}_${PV/_p*}-${PV/*_p}.diff
+       "${FILESDIR}"/largerthan2gb.patch
+       "${FILESDIR}"/${PN}-0.1-headers.patch
+       # Patch for bug #142737
+       "${FILESDIR}"/${PN}-0.1_p16-ppc64.patch
+       ### Patch for building on amd64
+       "${FILESDIR}"/${PN}-amd64.patch
+       # Patch for large (>550GB disks)
+       # Note that >=2TB disks may not work due to limitations of the Mac
+       # Partition Table structure, this needs to be investigated
+       "${FILESDIR}"/big_pt.patch
+       "${FILESDIR}"/${PN}-0.1_p16-ppc-inline.patch
+       "${FILESDIR}"/${PN}-0.1_p18-lseek64.patch
+       # add support for partitioning 2TB drives
+       "${FILESDIR}"/${PN}-0.1_p18-2tb.patch
+       "${FILESDIR}"/${PN}-0.1_p18-musl.patch
+)
+
+src_compile() {
+       use elibc_musl && append-cppflags -Dloff_t=off_t
+       emake CC="$(tc-getCC)"
+}
+
+src_install() {
+       into /
+       newsbin pdisk mac-fdisk
+       newsbin fdisk pmac-fdisk
+
+       into /usr
+       newman mac-fdisk.8.in mac-fdisk.8
+       newman pmac-fdisk.8.in pmac-fdisk.8
+
+       dodoc debian/changelog README HISTORY
+}

Reply via email to