Announcement

Collapse
No announcement yet.

It Soon May Be Easier Building Debian Packages On Fedora

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Originally posted by hreindl View Post
    a proper rpm-spec can be written by a trained monkey from scratch

    Code:
    [builduser@testserver:~]$ cat /rpmbuild/SPECS/lame.spec
    # Paket ist nicht auf alten Systemen im Einsatz
    %global optflags $(sed "s/sandybridge/%{mtune2}/g" <<< "%{optflags}")
    %global optflags $(sed "s/-mavx/-m%{mavx2}/g" <<< "%{optflags}")
    
    Name: lame
    Version: 3.100
    Release: 7%{?dist}.%{mtune2}
    Summary: Free MP3 audio compressor
    License: GPLv2+
    URL: http://lame.sourceforge.net/
    Source0: %{name}/%{name}-%{version}.tar.gz
    Patch1: %{name}-noexecstack.patch
    BuildRequires: ncurses-devel
    BuildRequires: pkgconfig
    BuildRequires: yasm
    Requires: %{name}-libs = %{version}-%{release}
    
    %description
    LAME is an open source MP3 encoder whose quality and speed matches
    commercial encoders. LAME handles MPEG1,2 and 2.5 layer III encoding
    with both constant and variable bitrates
    
    %package libs
    Summary: LAME MP3 encoding library
    %description libs
    
    %package devel
    Summary: Development files for %{name}
    Requires: %{name}-libs = %{version}-%{release}
    %description devel
    
    %prep
    %setup -q
    %patch1 -p1 -b .noexec
    iconv -f ISO-8859-1 -t UTF8 ChangeLog > ChangeLog.tmp && touch -r ChangeLog ChangeLog.tmp && mv ChangeLog.tmp ChangeLog
    
    %build
    sed -i -e 's/^\(\s*hardcode_libdir_flag_spec\s*=\).*/\1/' configure
    export CFLAGS="%{optflags} %{O3_flags} %{OS_flags} -fPIC -fno-fast-math -fno-unsafe-math-optimizations -fuse-ld=gold -fuse-linker-plugin"
    export CXXFLAGS="$CFLAGS"
    export CPPFLAGS="$CFLAGS"
    export CC="gcc $CFLAGS"
    export SH_LDFLAGS="-Wl,--as-needed -Wl,-z,now -Wl,-z,relro -Wl,-z,noexecstack %{optflags} %{O3_flags} %{OS_flags} -fno-fast-math -fno-unsafe-math-optimizations -fuse-ld=gold -fuse-linker-plugin"
    export LDFLAGS="$SH_LDFLAGS -pie -fPIE"
    %configure --disable-static --disable-mp3x --enable-mp3rtp --enable-expopt=norm
    %{__make} %{?_smp_mflags}
    
    %install
    make install-strip INSTALL="install -p" DESTDIR=%{buildroot}
    rm -f %{buildroot}%{_libdir}/*.la
    ln -sf %{name}/%{name}.h %{buildroot}%{_includedir}/%{name}.h
    rm -rf %{buildroot}%{_docdir}/%{name}
    
    %ldconfig_scriptlets
    
    %files
    %{_bindir}/%{name}
    %{_bindir}/mp3rtp
    %{_mandir}/man1/%{name}.1*
    
    %files libs
    %{_libdir}/libmp3lame.so.*
    
    %files devel
    %{_libdir}/libmp3lame.so
    %{_includedir}/%{name}/
    %{_includedir}/%{name}.h
    Your RPM SPEC is not bad, but you could improve it a little bit.

    Instead of this:
    Code:
    Source0:           %{name}/%{name}-%{version}.tar.gz
    you should consider something like this:
    Code:
    Source0:           http://downloads.sourceforge.net/lame/%{name}-%{version}.tar.gz

    Then you can download sources using the spectool command:
    Code:
    spectool -g -R lame.spec


    Replace this:
    Code:
    BuildRequires:     ncurses-devel
    with this:
    Code:
    BuildRequires:     pkgconfig(ncurses)

    Moreover, for Fedora >= 29 you should also specify this:
    Code:
    BuildRequires:     gcc


    Code:
    %description       libs
    Empty description?

    You should use something like this:
    Code:
    %description       libs
    LAME library.
    or:
    Code:
    %description       libs
    Libraries needed to run %{name}.
    or:
    Code:
    %description       libs
    Shared libraries used by the LAME MP3 encoder.
    or:
    Code:
    %description       libs
    This package contains libraries used by the LAME MP3 encoder.
    or:
    Code:
    %description       libs
    This package contains library files for LAME.


    Code:
    %description       devel
    The same as above.
    You can use something like this:
    Code:
    %description       devel
    This package contains development files for LAME.


    Instead of:
    Code:
    %setup -q
    %patch1 -p1 -b .noexec
    you can use this:
    Code:
    %autosetup -p1


    Instead of:
    Code:
    sed
    you can use this:
    Code:
    %{__sed}


    Code:
    export CXXFLAGS="$CFLAGS"
    export CPPFLAGS="$CFLAGS"
    export CC="gcc $CFLAGS"
    export SH_LDFLAGS="-Wl,--as-needed -Wl,-z,now -Wl,-z,relro -Wl,-z,noexecstack %{optflags} %{O3_flags} %{OS_flags} -fno-fast-math -fno-unsafe-math-optimizations -fuse-ld=gold -fuse-linker-plugin"
    export LDFLAGS="$SH_LDFLAGS -pie -fPIE"
    Probably not needed.



    Replace this:
    Code:
    %{__make} %{?_smp_mflags}
    with this:
    Code:
    %make_build


    Replace this:
    Code:
    make install-strip INSTALL="install -p" DESTDIR=%{buildroot}
    with this:
    Code:
    %make_install INSTALL="install -p"


    Instead of:
    Code:
    rm -f %{buildroot}%{_libdir}/*.la
    you can use this:
    Code:
    %{__rm} -f "%{buildroot}%{_libdir}"/*.la
    or (better) this:
    Code:
    find "%{buildroot}" -xtype f -name '*.la' -delete


    Instead of:
    Code:
    ln -sf %{name}/%{name}.h %{buildroot}%{_includedir}/%{name}.h
    you can use this:
    Code:
    %{__ln_s} "%{name}/%{name}.h" "%{buildroot}%{_includedir}/%{name}.h"


    Code:
    %ldconfig_scriptlets
    This macro was introduced in Fedora 28.

    To keep compatible with EL <= 7 you should use something like this:
    Code:
    %post -p /sbin/ldconfig
    
    %postun -p /sbin/ldconfig
    Moreover, in this example, the ldconfig should be used in the libs subpackage instead of main package:
    Code:
    %post libs -p /sbin/ldconfig
    
    %postun libs -p /sbin/ldconfig


    You should make use of %doc and %license macros in the %files section.
    For example:
    Code:
    %doc README
    %license COPYING


    You should also consider specifying Group:
    - for the main package:
    Code:
    Group:             Applications/Multimedia
    - for the libs subpackage:
    Code:
    Group:             System Environment/Libraries
    - for the devel subpackage:
    Code:
    Group:             Development/Libraries
    Although this is obsoleted in Fedora, it is still used in EL.

    Comment

    Working...
    X