Outils pour utilisateurs

Outils du site


tech:un_makefile_pour_rpmbuild

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tech:un_makefile_pour_rpmbuild [2025/05/31 18:46] Jean-Baptistetech:un_makefile_pour_rpmbuild [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>rpm}}
 +
 +# Un MakeFile pour rpmbuild
 +
 +Voir aussi : 
 +  * https://blog.mornati.net/build-rpms-using-jenkinshudson/
 +  * Python invoke https://www.pyinvoke.org/
 +  * o-task https://taskfile.dev/
 +  * Make.rules
 +
 +
 +
 +`Makefile`
 +~~~make
 +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 :
 +~~~make
 +all:    build clean
 +~~~
 +
 +Etait 
 +~~~make
 +all:    build
 +~~~
 +
 +Solution :
 +
 +`Makefile`
 +~~~Make
 +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
 +
 +
 +~~~bash
 +mkdir -p ~/rpm/ROOT
 +cd ~/rpm
 +~~~
 +
 +Déposez le Makefile dans ~/rpm/
 +
 +`~/rpm/mycli.spec`
 +~~~
 +%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)
 +~~~
 +
 +~~~bash
 +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
 +~~~
 +
 +`~/rpm/ROOT/usr/local/bin/mycli`
 +~~~bash
 +#!/bin/sh
 +
 +env PYTHONPATH=/opt/mycli/lib/python3.8/site-packages/ /opt/mycli/bin/mycli "$@"
 +~~~
 +
 +~~~bash
 +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
 +
 +~~~bash
 +sed -i.bak -e 's/^[ ]\+/\t/g' Makefile
 +~~~
 +
 +
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki