[libssh2] Spec clean-up

Paul Howarth pghmcfc at fedoraproject.org
Fri Jan 13 16:36:30 UTC 2012


commit edbbfd779a6b589cab2c106707ae99724b22c72b
Author: Paul Howarth <paul at city-fan.org>
Date:   Fri Jan 13 16:01:35 2012 +0000

    Spec clean-up
    
    - make docs package noarch where possible
    - use patch rather than scripted iconv to fix character encoding
    - don't make assumptions about SELinux context types used for the ssh server
      in the test suite
    - skip the ssh test if /dev/tty isn't present, as in some versions of mock
    - make the %files list more explicit

 libssh2-1.2.9-utf8.patch |   11 ++++
 libssh2.spec             |  115 +++++++++++++++++++++++++++------------------
 2 files changed, 80 insertions(+), 46 deletions(-)
---
diff --git a/libssh2-1.2.9-utf8.patch b/libssh2-1.2.9-utf8.patch
new file mode 100644
index 0000000..b41f6a2
--- /dev/null
+++ b/libssh2-1.2.9-utf8.patch
@@ -0,0 +1,11 @@
+--- libssh2/NEWS
++++ libssh2/NEWS
+@@ -2507,7 +2507,7 @@
+ - support arcfour128 cipher per RFC 4345
+ 
+ Daniel Stenberg (21 Oct 2009)
+-- [Cristian Rodríguez brought this change]
++- [Cristian Rodríguez brought this change]
+ 
+   add support for GCC visibility features
+ 
diff --git a/libssh2.spec b/libssh2.spec
index e967115..ff49d36 100644
--- a/libssh2.spec
+++ b/libssh2.spec
@@ -1,19 +1,34 @@
+# Fedora 10 onwards support noarch subpackages; by using one, we can
+# put the arch-independent docs in a common subpackage and save lots
+# of space on the mirrors
+%if 0%{?fedora} > 9 || 0%{?rhel} > 5
+%global noarch_docs_package 1
+%else
+%global noarch_docs_package 0
+%endif
+
 Name:           libssh2
 Version:        1.3.0
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        A library implementing the SSH2 protocol
-
 Group:          System Environment/Libraries
 License:        BSD
-URL:            http://www.libssh2.org
+URL:            http://www.libssh2.org/
 Source0:        http://libssh2.org/download/libssh2-%{version}.tar.gz
-BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
+Patch0:         libssh2-1.2.9-utf8.patch
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -nu)
 BuildRequires:  openssl-devel
 BuildRequires:  zlib-devel
 
-# tests
+# Test suite requirements - we run the OpenSSH server and try to connect to it
 BuildRequires:  openssh-server
+# We use matchpathcon to get the correct SELinux context for the ssh server
+# initialization script so that it can transition correctly in an SELinux
+# environment; matchpathcon is only available from FC-4 and moved from the
+# libselinux to libselinux-utils package in F-10
+%if 0%{?fedora} >= 4 || 0%{?rhel} >= 5
+BuildRequires:  /usr/sbin/matchpathcon selinux-policy-targeted
+%endif
 
 %description
 libssh2 is a library implementing the SSH2 protocol as defined by
@@ -21,104 +36,112 @@ Internet Drafts: SECSH-TRANS(22), SECSH-USERAUTH(25),
 SECSH-CONNECTION(23), SECSH-ARCH(20), SECSH-FILEXFER(06)*,
 SECSH-DHGEX(04), and SECSH-NUMBERS(10).
 
-
 %package        devel
-Summary:        Development files for %{name}
+Summary:        Development files for libssh2
 Group:          Development/Libraries
 Requires:       %{name} = %{version}-%{release}
 Requires:       pkgconfig
 
 %description    devel
-The %{name}-devel package contains libraries and header files for
-developing applications that use %{name}.
+The libssh2-devel package contains libraries and header files for
+developing applications that use libssh2.
 
 %package        docs
-Summary:        Documentation for %{name}
+Summary:        Documentation for libssh2
 Group:          Development/Libraries
 Requires:       %{name} = %{version}-%{release}
+%if %{noarch_docs_package}
+BuildArch:      noarch
+%endif
 
 %description    docs
-The %{name}-docs package contains man pages and examples for
-developing applications that use %{name}.
-
+The libssh2-docs package contains man pages and examples for
+developing applications that use libssh2.
 
 %prep
 %setup -q
 
-# make sure things are UTF-8...
-for i in ChangeLog NEWS ; do
-    iconv --from=ISO-8859-1 --to=UTF-8 $i > new
-    mv new $i
-done
+# Make sure things are UTF-8...
+%patch0 -p1
 
-# make it possible to launch OpenSSH server for testing purposes
-chcon -t initrc_exec_t tests/ssh2.sh || :
-chcon -Rt etc_t tests/etc || :
-chcon -t sshd_key_t tests/etc/{host,user} || :
+# Make sshd transition appropriately if building in an SELinux environment
+chcon $(/usr/sbin/matchpathcon -n /etc/rc.d/init.d/sshd) tests/ssh2.sh || :
+chcon -R $(/usr/sbin/matchpathcon -n /etc) tests/etc || :
+chcon $(/usr/sbin/matchpathcon -n /etc/ssh/ssh_host_key) tests/etc/{host,user} || :
 
 %build
 %configure --disable-static --enable-shared
-
 make %{?_smp_mflags}
 
-
 %install
 rm -rf %{buildroot}
-
 make install DESTDIR=%{buildroot} INSTALL="install -p"
-find %{buildroot} -name '*.la' -exec rm -f {} +
+find %{buildroot} -name '*.la' -exec rm -f {} \;
 
 # clean things up a bit for packaging
-( cd example && make clean )
-find example/ -type d -name .deps -exec rm -rf {} +
-find example/ -type f '(' -name '*.am' -o -name '*.in' ')' -exec rm -v {} +
+make -C example clean
+rm -rf example/.deps
+find example/ -type f '(' -name '*.am' -o -name '*.in' ')' -exec rm -v {} \;
 
 # avoid multilib conflict on libssh2-docs
 mv -v example/Makefile example/Makefile.%{_arch}
 
 %check
-# sshd/loopback test fails under local build, with selinux enforcing 
-%{?_without_sshd_tests:echo "Skipping sshd tests" ; echo "exit 0" > tests/ssh2.sh }
-# sshd/loopback test fails in the sparc buildsystem
+# The SSH test will fail if we don't have /dev/tty, as is the case in some
+# versions of mock (#672713)
+if [ ! -c /dev/tty ]; then
+        echo Skipping SSH test due to missing /dev/tty
+        echo "exit 0" > tests/ssh2.sh
+fi
+# Apparently it fails in the sparc buildsystem too
 %ifarch %{sparc}
+echo Skipping SSH test on sparc
 echo "exit 0" > tests/ssh2.sh
 %endif
-(cd tests && make check)
+make -C tests check
 
 %clean
 rm -rf %{buildroot}
 
-
 %post -p /sbin/ldconfig
 
 %postun -p /sbin/ldconfig
 
-
 %files
 %defattr(-,root,root,-)
 %doc AUTHORS ChangeLog COPYING README NEWS
-%{_libdir}/*.so.*
+%{_libdir}/libssh2.so.1
+%{_libdir}/libssh2.so.1.*
 
 %files docs
 %defattr(-,root,root,-)
-%doc COPYING HACKING example/
-%{_mandir}/man?/*
+%doc HACKING example/
+%{_mandir}/man3/libssh2_*.3*
 
 %files devel
 %defattr(-,root,root,-)
-%doc COPYING
-%{_includedir}/*
-%{_libdir}/*.so
-%{_libdir}/pkgconfig/*
+%{_includedir}/libssh2.h
+%{_includedir}/libssh2_publickey.h
+%{_includedir}/libssh2_sftp.h
+%{_libdir}/libssh2.so
+%{_libdir}/pkgconfig/libssh2.pc
 
 %changelog
-* Fri Jan 13 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.3.0-2
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
+* Fri Jan 13 2012 Paul Howarth <paul at city-fan.org> 1.3.0-3
+- make docs package noarch where possible
+- use patch rather than scripted iconv to fix character encoding
+- don't make assumptions about SELinux context types used for the ssh server
+  in the test suite
+- skip the ssh test if /dev/tty isn't present, as in some versions of mock
+- make the %%files list more explicit
+
+* Fri Jan 13 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> 1.3.0-2
+- rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 
 * Thu Sep 08 2011 Kamil Dudka <kdudka at redhat.com> 1.3.0-1
 - update to 1.3.0
 
-* Sat Jun 25 2011 Dennis Gilmore <dennis at ausil.us> - 1.2.7-2
+* Sat Jun 25 2011 Dennis Gilmore <dennis at ausil.us> 1.2.7-2
 - sshd/loopback test fails in the sparc buildsystem
 
 * Tue Oct 12 2010 Kamil Dudka <kdudka at redhat.com> 1.2.7-1


More information about the scm-commits mailing list