summaryrefslogtreecommitdiff
path: root/sys-apps/flashrom
diff options
context:
space:
mode:
Diffstat (limited to 'sys-apps/flashrom')
-rw-r--r--sys-apps/flashrom/Manifest2
-rw-r--r--sys-apps/flashrom/files/flashrom-1.2_make-libflashrom-usable.patch70
-rw-r--r--sys-apps/flashrom/flashrom-1.2-r2.ebuild180
3 files changed, 252 insertions, 0 deletions
diff --git a/sys-apps/flashrom/Manifest b/sys-apps/flashrom/Manifest
index 273304be8e7b..f32ef55a8d98 100644
--- a/sys-apps/flashrom/Manifest
+++ b/sys-apps/flashrom/Manifest
@@ -1,4 +1,6 @@
+AUX flashrom-1.2_make-libflashrom-usable.patch 3230 BLAKE2B ddf5677e8a6b931d372059bf270b74a1dcd6ebfdfb1cf3e7c976e647fdc8180d005f19416ee15bb0b25f1f2b891348a42a83f8e6d44c528864947cd4be78e0da SHA512 dd60f4e25ab519f6b5f03c4e80be2fe24ab2c5c206c78aff2802f91026d5ef3889d2376f88bc4baa32de5c48951afe0cb1d62dbfc65c4965058caccfadff65d1
DIST flashrom-v1.2.tar.bz2 366995 BLAKE2B 091e01a91e12b486154ace334a5e74bccbb5f5311ad76e37f43a28167080757873d8c78b8f549d2e77eb984922c830895ba955b23eb6ee4fc24f1ffed259954b SHA512 8e01395a54d0d1344bc55e7e4975f43bb8e59ebe83fb5f2766d14f76756d718b487254ce9a19ef4093aed04fb9d40fff5fe8f709b18c512f6e6fad894f83d7b8
EBUILD flashrom-1.2-r1.ebuild 4520 BLAKE2B d00007833d23c42b7b59cc1503565e75037d7f4dc835f79c280299a2818bb5ff2f48868958940a237ef52721f971a1c055f0ef35c0167ef263b5ef36232266d9 SHA512 9c7a87c29bf7f57ff9878127c8b38d21d97f3019e0a350e64d7271a208253d85091addff5799e6e947182490a8494f6743e2e2029d3b4ae6d5ab9c9b14900d3f
+EBUILD flashrom-1.2-r2.ebuild 5077 BLAKE2B 920633ca2e0139be61131b1ae752bd65584ec9d0c4d887ed6d99f8fdbcab07752aee64b44df46c7abd71006e24a922ad93a02fa138ca1da8bc33666efd086633 SHA512 c80d1ee1d91f3c06e23a6be41472561853d5ee9a4fca263190be3731f05b4abeb210e7e9cd46e61687c0b26f91260809cc320038f5c798203dcf5774b11f7841
EBUILD flashrom-9999.ebuild 4423 BLAKE2B fc758295685fea683f2b7bdc07dc307525571b00745ced19910a95117a033964d037da53b86ddca9482c96b8dcb6f54e46eb6401e17e5268f2b565ed89bf6ee6 SHA512 b2ef614c5bee6c83a510306823ae34b2e32e8d03726479b6ceb89f29e51c2f9d6a91f7e6c1f24166fe572094299b3bbc49047ae4c865d3ca994be233cfa7d90e
MISC metadata.xml 4595 BLAKE2B 0a7c4f212c57dccca72a7da1172b8eb36a7027703fea6137be5eefbadf5592abaa6e9841befa3e8f8ef65b1b5057af3c0f162584f0db65addd362a0a8880e648 SHA512 25b118e1150b405d34081add86fa02c04094ada970ea2a121bf21a3047d1df2566383549df7d0138883bcfed31c2574a420e9357dccce993c93179e3e769b8ef
diff --git a/sys-apps/flashrom/files/flashrom-1.2_make-libflashrom-usable.patch b/sys-apps/flashrom/files/flashrom-1.2_make-libflashrom-usable.patch
new file mode 100644
index 000000000000..ea15a4230592
--- /dev/null
+++ b/sys-apps/flashrom/files/flashrom-1.2_make-libflashrom-usable.patch
@@ -0,0 +1,70 @@
+1. Add an (extremely primitive) rule for generating a pkgconfig file
+ for libflashrom, as fwupd cannot find it without one. Note that this
+ rule depends on several variables to be passed to make, see ebuilds
+ using this patch for details;
+2. Tweak the way library dependencies are passed around a bit to make it
+ easier to inject them into said pkgconfig file;
+3. Move print.o from CLI_OBJS to LIB_OBJS - it contains the array
+ 'boards_known' which is used in library code. Upstream have already
+ fixed this in Meson files but not in the Makefile.
+
+diff -urN a/flashrom.pc.in b/flashrom.pc.in
+--- a/flashrom.pc.in 1970-01-01 01:00:00.000000000 +0100
++++ b/flashrom.pc.in 2020-07-28 22:47:01.928679346 +0200
+@@ -0,0 +1,9 @@
++prefix=@PREFIX@
++libdir=${prefix}/@LIBDIR@
++includedir=${prefix}/@INCLUDEDIR@
++
++Name: libflashrom
++Description: library to interact with flashrom
++Version: @VERSION@
++Libs: -L${libdir} -lflashrom @LIBS@
++Cflags: -I${includedir}
+diff -urN a/Makefile b/Makefile
+--- a/Makefile 2019-12-31 18:25:41.000000000 +0100
++++ b/Makefile 2020-07-28 23:18:41.019492448 +0200
+@@ -570,12 +570,12 @@
+ ###############################################################################
+ # Library code.
+
+-LIB_OBJS = libflashrom.o layout.o flashrom.o udelay.o programmer.o helpers.o ich_descriptors.o fmap.o
++LIB_OBJS = libflashrom.o layout.o flashrom.o udelay.o programmer.o helpers.o ich_descriptors.o fmap.o print.o
+
+ ###############################################################################
+ # Frontend related stuff.
+
+-CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
++CLI_OBJS = cli_classic.o cli_output.o cli_common.o
+
+ # versioninfo.inc stores metadata required to build a packaged flashrom. It is generated by the export rule and
+ # imported below. If versioninfo.inc is not found and the variables are not defined by the user, the info will
+@@ -1130,11 +1130,16 @@
+ @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
+ endif
+
++ALL_LIBS = $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS) $(JAYLINKLIBS) $(NI845X_LIBS)
++
++flashrom.pc:
++ sed -e "s#@PREFIX@#$(PREFIX)#" -e "s#@LIBDIR@#$(LIBDIR)#" -e "s#@INCLUDEDIR@#$(INCLUDEDIR)#" -e "s#@VERSION@#$(VERSION)#" -e "s#@LIBS@#$(ALL_LIBS)#" < $@.in > $@.tmp && mv $@.tmp $@
++
+ $(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
+- $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS) $(JAYLINKLIBS) $(NI845X_LIBS)
++ $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(ALL_LIBS)
+
+-libflashrom.a: $(LIBFLASHROM_OBJS)
+- $(AR) rcs $@ $^
++libflashrom.a: $(LIBFLASHROM_OBJS) flashrom.pc
++ $(AR) rcs $@ $(LIBFLASHROM_OBJS)
+ $(RANLIB) $@
+
+ # TAROPTIONS reduces information leakage from the packager's system.
+@@ -1149,7 +1154,7 @@
+ # This includes all frontends and libflashrom.
+ # We don't use EXEC_SUFFIX here because we want to clean everything.
+ clean:
+- rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8 $(PROGRAM).8.html $(BUILD_DETAILS_FILE)
++ rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a flashrom.pc *.o *.d $(PROGRAM).8 $(PROGRAM).8.html $(BUILD_DETAILS_FILE)
+ @+$(MAKE) -C util/ich_descriptors_tool/ clean
+
+ distclean: clean
diff --git a/sys-apps/flashrom/flashrom-1.2-r2.ebuild b/sys-apps/flashrom/flashrom-1.2-r2.ebuild
new file mode 100644
index 000000000000..ae710e470315
--- /dev/null
+++ b/sys-apps/flashrom/flashrom-1.2-r2.ebuild
@@ -0,0 +1,180 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit flag-o-matic toolchain-funcs
+
+if [[ ${PV} == "9999" ]] ; then
+ EGIT_REPO_URI="https://review.coreboot.org/flashrom.git"
+ inherit git-r3
+else
+ MY_P="${PN}-v${PV}"
+ SRC_URI="https://download.flashrom.org/releases/${MY_P}.tar.bz2"
+ KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~sparc ~x86"
+ S="${WORKDIR}/${MY_P}"
+fi
+
+DESCRIPTION="Utility for reading, writing, erasing and verifying flash ROM chips"
+HOMEPAGE="https://flashrom.org/"
+
+LICENSE="GPL-2"
+SLOT="0"
+# The defaults match the upstream Makefile.
+# Note: Do not list bitbang_spi as it is not a programmer; it's a backend used
+# by some other spi programmers.
+IUSE_PROGRAMMERS="
+ atahpt
+ +atapromise
+ +atavia
+ +buspirate-spi
+ +ch341a-spi
+ +dediprog
+ +developerbox-spi
+ +digilent-spi
+ +drkaiser
+ +dummy
+ +ft2232-spi
+ +gfxnvidia
+ +internal
+ +it8212
+ jlink-spi
+ +linux-mtd
+ +linux-spi
+ mstarddc-spi
+ +nic3com
+ +nicintel
+ +nicintel-eeprom
+ +nicintel-spi
+ nicnatsemi
+ +nicrealtek
+ +ogp-spi
+ +pickit2-spi
+ +pony-spi
+ +rayer-spi
+ +satamv
+ +satasii
+ +serprog
+ stlinkv3-spi
+ +usbblaster-spi
+"
+
+IUSE="${IUSE_PROGRAMMERS} +internal-dmi static tools +wiki"
+
+LIB_DEPEND="
+ atahpt? ( sys-apps/pciutils[static-libs(+)] )
+ atapromise? ( sys-apps/pciutils[static-libs(+)] )
+ atavia? ( sys-apps/pciutils[static-libs(+)] )
+ ch341a-spi? ( virtual/libusb:1[static-libs(+)] )
+ dediprog? ( virtual/libusb:1[static-libs(+)] )
+ developerbox-spi? ( virtual/libusb:1[static-libs(+)] )
+ digilent-spi? ( virtual/libusb:1[static-libs(+)] )
+ drkaiser? ( sys-apps/pciutils[static-libs(+)] )
+ ft2232-spi? ( dev-embedded/libftdi:=[static-libs(+)] )
+ gfxnvidia? ( sys-apps/pciutils[static-libs(+)] )
+ internal? ( sys-apps/pciutils[static-libs(+)] )
+ it8212? ( sys-apps/pciutils[static-libs(+)] )
+ jlink-spi? ( dev-embedded/libjaylink[static-libs(+)] )
+ nic3com? ( sys-apps/pciutils[static-libs(+)] )
+ nicintel-eeprom? ( sys-apps/pciutils[static-libs(+)] )
+ nicintel-spi? ( sys-apps/pciutils[static-libs(+)] )
+ nicintel? ( sys-apps/pciutils[static-libs(+)] )
+ nicnatsemi? ( sys-apps/pciutils[static-libs(+)] )
+ nicrealtek? ( sys-apps/pciutils[static-libs(+)] )
+ ogp-spi? ( sys-apps/pciutils[static-libs(+)] )
+ pickit2-spi? ( virtual/libusb:0[static-libs(+)] )
+ rayer-spi? ( sys-apps/pciutils[static-libs(+)] )
+ satamv? ( sys-apps/pciutils[static-libs(+)] )
+ satasii? ( sys-apps/pciutils[static-libs(+)] )
+ stlinkv3-spi? ( virtual/libusb:1[static-libs(+)] )
+ usbblaster-spi? ( dev-embedded/libftdi:=[static-libs(+)] )
+"
+RDEPEND="!static? ( ${LIB_DEPEND//\[static-libs(+)]} )"
+DEPEND="${RDEPEND}
+ static? ( ${LIB_DEPEND} )
+ sys-apps/diffutils"
+RDEPEND+=" !internal-dmi? ( sys-apps/dmidecode )"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-1.2_make-libflashrom-usable.patch
+)
+
+_flashrom_enable() {
+ local c="CONFIG_${2:-$(echo "$1" | tr '[:lower:]-' '[:upper:]_')}"
+ args+=( "${c}=$(usex $1 yes no)" )
+}
+flashrom_enable() {
+ local u
+ for u ; do _flashrom_enable "${u}" ; done
+}
+
+src_prepare() {
+ # To make libflashrom.a actually useful
+ append-flags -fPIC
+
+ default
+}
+
+src_compile() {
+ # Help keep things in sync.
+ local sprogs=$(echo $(
+ grep -o 'CONFIG_[A-Z0-9_]*' flashrom.c | \
+ LC_ALL=C sort -u | \
+ sed 's:^CONFIG_::' | \
+ tr '[:upper:]_' '[:lower:]-' | \
+ grep -v ni845x-spi))
+ local eprogs=$(echo ${IUSE_PROGRAMMERS} | sed -E 's/\B[-+]\b//g')
+ if [[ ${sprogs} != "${eprogs}" ]] ; then
+ eerror "The ebuild needs to be kept in sync."
+ eerror "IUSE set to: ${eprogs}"
+ eerror "flashrom.c : ${sprogs}"
+ die "sync IUSE to the list of source programmers"
+ fi
+
+ # Turn USE flags into CONFIG_xxx settings.
+ local args=()
+ flashrom_enable ${eprogs}
+ _flashrom_enable wiki PRINT_WIKI
+ _flashrom_enable static STATIC
+
+ # You have to specify at least one programmer, and if you specify more than
+ # one programmer you have to include either dummy or internal in the list.
+ # We pick dummy as the default because internal requires libpci.
+ if ! use internal && ! use dummy ; then
+ if [[ ${#args[@]} -ne 1 ]] ; then
+ ewarn "You have to specify at least one programmer, and if you specify"
+ ewarn "more than one programmer, you have to enable either dummy or"
+ ewarn "internal as well. 'dummy' will be the default now."
+ args+=( CONFIG_DUMMY=yes )
+ fi
+ fi
+
+ tc-export AR CC PKG_CONFIG RANLIB
+ # PREFIX, INCLUDEDIR and LIBDIR are injected into the libflashrom pkgconfig
+ # file, which is why we pass them here even though src_install() puts all
+ # files in correct locations without employing make.
+ # VERSION too goes into the pkgconfig file, and we override the upstream
+ # value to get rid of the prefix 'v'.
+ emake \
+ INCLUDEDIR="include" \
+ LIBDIR="$(get_libdir)" \
+ PREFIX="${EPREFIX}/usr" \
+ VERSION="${PV}" \
+ WARNERROR=no "${args[@]}" \
+ all libflashrom.a
+}
+
+src_install() {
+ dosbin flashrom
+ doman flashrom.8
+ dodoc README Documentation/*.txt
+ dolib.a libflashrom.a
+ doheader libflashrom.h
+
+ insinto /usr/$(get_libdir)/pkgconfig
+ doins ${PN}.pc
+
+ if use tools; then
+ dosbin util/ich_descriptors_tool/ich_descriptors_tool
+ fi
+}