Un MakeFile pour rpmbuild

Voir aussi : https://blog.mornati.net/build-rpms-using-jenkinshudson/

clean: SHELL:=/bin/bash build: SHELL:=/bin/bash FicSpec = $(shell echo *.spec) RpmName = $(shell grep -e '^%define name' $(FicSpec) |awk '{print $$3}') RpmVersion = $(shell grep -e '^%define version' $(FicSpec) |awk '{print $$3}') RpmRelease = $(shell grep -e '^%define release' $(FicSpec) |awk '{print $$3}') StringRpmFullname = $(RpmName)-$(RpmVersion)-$(RpmRelease).$(shell uname -m) all: build clean clean: rm -rf $$HOME/rpmbuild cleanall: clean rm -f *.rpm copy: cleanall mkdir -p $$HOME/rpmbuild/{BUILDROOT,SPECS} mkdir -p $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname) cp -a ROOT/* $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname) cp -p $(FicSpec) ~/rpmbuild/SPECS/ build: copy rpmbuild -bb ~/rpmbuild/SPECS/*.spec mv ~/rpmbuild/RPMS/*/*.rpm .

Le clean se fait bien avant, mais pas après le build.

C'est comme si :

all: build clean

Etait

all: build

Solution :

clean: SHELL:=/bin/bash build: SHELL:=/bin/bash FicSpec = $(shell echo *.spec) RpmName = $(shell grep -e '^%define name' $(FicSpec) |awk '{print $$3}') RpmVersion = $(shell grep -e '^%define version' $(FicSpec) |awk '{print $$3}') RpmRelease = $(shell grep -e '^%define release' $(FicSpec) |awk '{print $$3}') StringRpmFullname = $(RpmName)-$(RpmVersion)-$(RpmRelease).$(shell uname -m) all: build cleanagain clean: rm -rf $$HOME/rpmbuild cleanall: clean rm -f *.rpm cleanagain: ${MAKE} clean copy: cleanall mkdir -p $$HOME/rpmbuild/{BUILDROOT,SPECS} mkdir -p $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname) cp -a ROOT/* $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname) cp -p $(FicSpec) ~/rpmbuild/SPECS/ build: copy rpmbuild -bb ~/rpmbuild/SPECS/*.spec mv ~/rpmbuild/RPMS/*/*.rpm .

Exemple avec le paquet Python mycli

mkdir -p ~/rpm/ROOT cd ~/rpm

Déposez le Makefile dans ~/rpm/

%define name mycli
%define version 1.21.1
%define release 1
%define debug_package %{nil}
Summary: CLI for MySQL/MariaDB
Name: %{name}
Version: %{version}
Release: %{release}
Vendor: NC
Group: Database
License: MIT License
URL: https://www.mycli.net
Source0: https://github.com/dbcli/mycli
BuildRequires: rpm-build
Requires: python38
#BuildArch: noarch
%description
This is a command line interface for MySQL, MariaDB, and Percona with
auto-completion and syntax highlighting. The CLI is also capable of pretty
printing tabular data.
#%post
#set -e
%doc
#%changelog
%files
%defattr(755,root,root,644)

export http_proxy=http://127.0.0.1:3128 export https_proxy=http://127.0.0.1:3128 pip3 install --user mycli mkdir -p ~/rpm/ROOT/opt/mycli cp -a ~/.local/* ~/rpm/ROOT/opt/mycli/ mkdir -p ~/rpm/ROOT/usr/local/bin/ find /home/etudes/rpm/ROOT/ -type f -name "*.pyc" -delete
#!/bin/sh env PYTHONPATH=/opt/mycli/lib/python3.8/site-packages/ /opt/mycli/bin/mycli "$@"
cd ~/rpm/ROOT find . -type f |sed -e 's/^\.//' >> ../mycli.spec cd ~/rpm/ make

Pb

did you mean TAB instead of 8 spaces?

$ make
Makefile:18: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.

Solution

sed -i.bak -e 's/^[ ]\+/\t/g' Makefile