Package stlink: Specfile

%define _unpackaged_files_terminate_build 1
%def_without static

Name: stlink
Version: 1.6.1
Release: alt2
Epoch: 1

Summary: STM32 microcontrolles programmer and debuger, using STLINKv1/v2/v2-1/v3
License: BSD-3-Clause
Group: Development/Other

Source0: %name-%version.tar

BuildRequires: cmake
BuildRequires: libgtk+3-devel
BuildRequires: libusb-devel
BuildRequires: pandoc
BuildRequires: libpcre-devel
BuildRequires: libffi-devel
BuildRequires: bzlib-devel
BuildRequires: libbrotli-devel


Open source version of the STMicroelectronics STlink Tools

STLink is an open source toolset to program and debug STM32 devices and boards
manufactured by STMicroelectronics. It supports several so called STLINK
programmer boards (and clones thereof) which use a microcontroller chip to
translate commands from USB to JTAG/SWD. There are four generations available
on the market which are all supported by this toolset:

 STLINK/v1 (obsolete as of 21-11-2019, continued support by this toolset)
   transport layer: SCSI passthru commands over USB
   stand-alone programmer and present on STM32VL Discovery boards
   transport layer: raw USB commands
   stand-alone programmer and present on STM32L Discovery and Nucleo boards
   transport layer: raw USB commands
   present on some STM32 Nucleo boards
   transport layer: raw USB commands
   stand-alone programmer

On the user level there is no difference in handling or operation between these
different revisions.

%package -n lib%name
Summary: Shared library of %name
Group: System/Libraries

%description -n lib%name
Lib files for stlink

%package -n lib%name-devel
Summary: Development files of %name
Group: Development/C
Requires: lib%name = %EVR

%description -n lib%name-devel
Development files for libstlink

%package gui
Summary: GUI for %name
Group: Development/Other
Requires: %name = %EVR

%description gui
GUI for stlink

# restore pkgconfig generation
# FIXME: resulting pkgconfig is broken anyway
sed -i 's|#add_subdirectory(cmake\/pkgconfig)|add_subdirectory(cmake/pkgconfig)|' CMakeLists.txt
# NB: this may become way too generic in future
sed -i 's|\(.*DESTINATION.*\)\(${PROJECT_NAME}\/\)\(.*\)|\1\3|g' doc/man/CMakeLists.txt src/stlink-gui/CMakeLists.txt
# move stlink-gui.ui out of %%_bindir
sed -i 's|stlink-gui.ui DESTINATION ${CMAKE_INSTALL_BINDIR}|stlink-gui.ui DESTINATION %_datadir/%name|' src/stlink-gui/CMakeLists.txt
sed -i 's|STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/bin"|STLINK_UI_DIR="%_datadir/%name"|' src/stlink-gui/CMakeLists.txt

# sysconf/udev policy - /etc is for user
mkdir -p %buildroot%_udevrulesdir/
%cmake \
	-DINCLUDE_INSTALL_DIR=%_includedir \
	-DSTLINK_UDEV_RULES_DIR=%_udevrulesdir \

# parallel build is broken with NPROCS >=8 and even >=4 on ppc64le
export NPROCS=1


%if_without static
rm -f %buildroot/%_libdir/lib%name.a


%files gui
%dir %_datadir/%name

%files -n lib%name

%files -n lib%name-devel
%if_with static
%dir %_includedir/%name
# stm32.h:

* Mon Jan 29 2024 Alexey Sheplyakov <> 1:1.6.1-alt2
- Revived the package (no code changes). It's useful, and it has been deleted
  due to a bogus compiler warning:
  error: 'stlink_open_usb' accessing 64 bytes in a region of size 28 [-Werror=stringop-overflow=]
  This warning is a false positive. GCC 11, 12 are known to produce a lot of
  false positives with `-Wstringop-overflow`. As a result Linux (the kernel)
  disables `-Wstringop-overflow` when compiling with GCC 11, see the commit
  a5e0ace04fbf56c17 `init: Kconfig: Disable -Wstringop-overflow for GCC-11`.
  With GCC 13 `-Wstringop-overflow` is much better, so the (same) code
  compiles (and runs) just fine.

* Mon Feb 08 2021 Nikolai Kostrigin <> 1:1.6.1-alt1
- New version (closes: #34271)
  + switch to new upstream location
  + switch packaging scheme SRPM->gears
  + alter Epoch to change versioning scheme according to upstream
  + switch to use .gear/tags
  + extract gui into a separate package

* Thu Jul 12 2018 Igor Vlasenko <> 2018.04.18-alt2.qa1
- NMU (by repocop). See
- applied repocop fixes:
  * udev-files-in-etc for stlink

* Fri Apr 20 2018 Sergey Bolshakov <> 2018.04.18-alt2
- fix insane BRs
- fix packaging on 64bit arches other than x86_64

* Wed Apr 18 2018 Grigory Milev <> 2018.04.18-alt1
- Updated to latest git version
- devide package to libs, main tools and devel packages

* Wed Mar 05 2014 Grigory Milev <> 2014.03.05-alt2
- Change 0700 -> 0644 for file saved from flash

* Wed Mar 05 2014 Grigory Milev <> 2014.03.05-alt1
- Initial build.