From 0dead4c066a8a4bebf6071c78811e6b6efcfcf43 Mon Sep 17 00:00:00 2001 From: Esteve Varela Colominas Date: Mon, 5 Oct 2026 19:44:17 +0200 Subject: [PATCH] sys-fs/sdformatlinux: New package Signed-off-by: Esteve Varela Colominas --- sys-fs/sdformatlinux/Manifest | 1 + ...inux-0.2.0-unhardcode-compiler-flags.patch | 52 +++++++++++++++++++ ...matLinux-0.2.0-unhardcode-lsblk-path.patch | 18 +++++++ sys-fs/sdformatlinux/metadata.xml | 11 ++++ .../sdformatlinux/sdformatlinux-0.2.0.ebuild | 29 +++++++++++ 5 files changed, 111 insertions(+) create mode 100644 sys-fs/sdformatlinux/Manifest create mode 100644 sys-fs/sdformatlinux/files/sdFormatLinux-0.2.0-unhardcode-compiler-flags.patch create mode 100644 sys-fs/sdformatlinux/files/sdFormatLinux-0.2.0-unhardcode-lsblk-path.patch create mode 100644 sys-fs/sdformatlinux/metadata.xml create mode 100644 sys-fs/sdformatlinux/sdformatlinux-0.2.0.ebuild diff --git a/sys-fs/sdformatlinux/Manifest b/sys-fs/sdformatlinux/Manifest new file mode 100644 index 0000000000..920ef438ad --- /dev/null +++ b/sys-fs/sdformatlinux/Manifest @@ -0,0 +1 @@ +DIST sdFormatLinux-0.2.0.tar.gz 35758 BLAKE2B d5be4625ffc25785b19eb8d6bfe6555f389f66419c43d2cd3e0507564a6db9d0575e62b08d15770da67296fdc1076a1c37c1476665339d3599011f7c147bc8fd SHA512 f57327befebe70d74c55ab903bb41516e89dae6b7548be5dfccd51aabaf432f39a502ec10f974a46b145b8ac6f9aa8c2ee0b1ab77c596430c993d0d1e9472971 diff --git a/sys-fs/sdformatlinux/files/sdFormatLinux-0.2.0-unhardcode-compiler-flags.patch b/sys-fs/sdformatlinux/files/sdFormatLinux-0.2.0-unhardcode-compiler-flags.patch new file mode 100644 index 0000000000..ffb3ee8753 --- /dev/null +++ b/sys-fs/sdformatlinux/files/sdFormatLinux-0.2.0-unhardcode-compiler-flags.patch @@ -0,0 +1,52 @@ +Make it possible to specify custom CFLAGS/CXXFLAGS/etc in the environment + +Also remove -s from LDFLAGS to allow portage to deal with the debug +information. + +--- sdFormatLinux-0.2.0.orig/Makefile ++++ sdFormatLinux-0.2.0/Makefile +@@ -12,25 +12,25 @@ + ARCH := + CFLAGS := $(ARCH) -std=c17 -O2 -g -fPIE -fstrict-aliasing \ + -ffunction-sections -fdata-sections -fstack-protector-strong \ +- -Wall -Wextra -Wstrict-aliasing=2 ++ -Wall -Wextra -Wstrict-aliasing=2 $(CFLAGS) + CXXFLAGS := $(ARCH) -std=c++20 -O2 -g -fPIE -fstrict-aliasing \ + -ffunction-sections -fdata-sections -fstack-protector-strong \ +- -Wall -Wextra -Wstrict-aliasing=2 +-ASFLAGS := $(ARCH) -O2 -g -fPIE -x assembler-with-cpp ++ -Wall -Wextra -Wstrict-aliasing=2 $(CXXFLAGS) ++ASFLAGS := $(ARCH) -O2 -g -fPIE -x assembler-with-cpp $(ASFLAGS) + ARFLAGS := -rcs +-LDFLAGS := $(ARCH) -O2 -s -pie -fPIE -Wl,--gc-sections,-z,relro,-z,now,-z,noexecstack ++LDFLAGS := $(ARCH) -O2 -pie -fPIE -Wl,--gc-sections,-z,relro,-z,now,-z,noexecstack $(LDFLAGS) + + PREFIX := + ifneq ($(strip $(USE_CLANG)),) +-CC := $(PREFIX)clang +-CXX := $(PREFIX)clang++ +-AS := $(PREFIX)clang +-AR := $(PREFIX)gcc-ar ++CC ?= $(PREFIX)clang ++CXX ?= $(PREFIX)clang++ ++AS ?= $(PREFIX)clang ++AR ?= $(PREFIX)gcc-ar + else +-CC := $(PREFIX)gcc +-CXX := $(PREFIX)g++ +-AS := $(PREFIX)gcc +-AR := $(PREFIX)gcc-ar ++CC ?= $(PREFIX)gcc ++CXX ?= $(PREFIX)g++ ++AS ?= $(PREFIX)gcc ++AR ?= $(PREFIX)gcc-ar + endif + + +@@ -107,4 +107,4 @@ + @echo $(notdir $@) + $(AR) $(ARFLAGS) $@ $^ + +-endif +\ No newline at end of file ++endif diff --git a/sys-fs/sdformatlinux/files/sdFormatLinux-0.2.0-unhardcode-lsblk-path.patch b/sys-fs/sdformatlinux/files/sdFormatLinux-0.2.0-unhardcode-lsblk-path.patch new file mode 100644 index 0000000000..b2df95e11f --- /dev/null +++ b/sys-fs/sdformatlinux/files/sdFormatLinux-0.2.0-unhardcode-lsblk-path.patch @@ -0,0 +1,18 @@ +Unhardcode "lsblk" path + +On many systems, lsblk might not be available exactly on /usr/bin. Since +popen() respects $PATH, it makes sense to avoid hardcoding this path. + +--- sdFormatLinux-0.2.0.orig/source/blockdev.cpp ++++ sdFormatLinux-0.2.0/source/blockdev.cpp +@@ -21,8 +21,8 @@ + static int checkDevice(const char *const path) + { + int res = EINVAL; // By default assume the given path is not a suitable device. +- char cmd[64] = "/usr/bin/lsblk -dnr -oTYPE,HOTPLUG,PHY-SEC "; +- strncpy(&cmd[43], path, sizeof(cmd) - 43); ++ char cmd[64] = "lsblk -dnr -oTYPE,HOTPLUG,PHY-SEC "; ++ strncpy(&cmd[34], path, sizeof(cmd) - 34); + cmd[sizeof(cmd) - 1] = '\0'; + FILE *const p = ::popen(cmd, "r"); + if(p == nullptr) diff --git a/sys-fs/sdformatlinux/metadata.xml b/sys-fs/sdformatlinux/metadata.xml new file mode 100644 index 0000000000..f9b8c1adca --- /dev/null +++ b/sys-fs/sdformatlinux/metadata.xml @@ -0,0 +1,11 @@ + + + + + esteve.varela@gmail.com + Esteve Varela Colominas + + + profi200/sdFormatLinux + + diff --git a/sys-fs/sdformatlinux/sdformatlinux-0.2.0.ebuild b/sys-fs/sdformatlinux/sdformatlinux-0.2.0.ebuild new file mode 100644 index 0000000000..2299e2ced4 --- /dev/null +++ b/sys-fs/sdformatlinux/sdformatlinux-0.2.0.ebuild @@ -0,0 +1,29 @@ +# Copyright 2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=9 + +DESCRIPTION="Properly format SD cards under Linux" +HOMEPAGE="https://github.com/profi200/sdFormatLinux/" + +MY_PN=sdFormatLinux +SRC_URI="https://github.com/profi200/sdFormatLinux/archive/refs/tags/v${PV}.tar.gz -> ${MY_PN}-${PV}.tar.gz" +S="${WORKDIR}/${MY_PN}-${PV}" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64" + +PATCHES=( + "${FILESDIR}/sdFormatLinux-0.2.0-unhardcode-compiler-flags.patch" + "${FILESDIR}/sdFormatLinux-0.2.0-unhardcode-lsblk-path.patch" +) + +src_compile() { + emake TARGET=sdFormatLinux +} + +src_install() { + einstalldocs + dobin sdFormatLinux +}