Accepting request 525949 from science:HPC

- Add a dependency generator wrapper for binaries and libraries
  to avoid adding standard dependencies for HPC libraries.

- Removed unneeded BuildRequires: (forwarded request 525945 from eeich)

OBS-URL: https://build.opensuse.org/request/show/525949
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/suse-hpc?expand=0&rev=2
This commit is contained in:
Dominique Leuenberger 2017-09-15 20:30:52 +00:00 committed by Git OBS Bridge
commit 7cded75442
7 changed files with 152 additions and 6 deletions

27
dlinfo.c Normal file
View File

@ -0,0 +1,27 @@
#define _GNU_SOURCE
#include <dlfcn.h>
#include <link.h>
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
void *dlh;
struct link_map *linkmap;
if (argc != 2) {
fprintf(stderr, "Usage: %s <library>\n", argv[0]);
exit(EXIT_FAILURE);
}
if ((dlh = dlopen(argv[1], RTLD_NOW)) == NULL)
exit(EXIT_FAILURE);
if (dlinfo(dlh, RTLD_DI_LINKMAP, &linkmap) == -1)
exit(EXIT_FAILURE);
printf("%s\n",linkmap->l_name);
exit(EXIT_SUCCESS);
}

5
hpc_elf.attr Normal file
View File

@ -0,0 +1,5 @@
%__hpc_elf_provides %{_rpmconfigdir}/hpc_elf.pl --provides %{?__filter_GLIBC_PRIVATE:--filter-private} %{?hpc_dep_gen_attr}
%__hpc_elf_requires %{_rpmconfigdir}/hpc_elf.pl --requires %{?__filter_GLIBC_PRIVATE:--filter-private} %{?hpc_dep_gen_attr}
%__hpc_elf_magic ^(setuid )?(setgid )?(sticky )?ELF (32|64)-bit.*executable
%__hpc_elf_path %hpc_prefix
%__hpc_elf_flags exeonly

79
hpc_elf.pl Normal file
View File

@ -0,0 +1,79 @@
#! /usr/bin/perl
use Cwd 'abs_path';
use File::Basename;
$dir=dirname(abs_path($0));
$command=$dir . "/elfdeps";
$dlinfo=$dir . "/dlinfo";
$arglist = "";
sub usage {
my $message = <<EOF;
Usage: $0 [-?] [-P|--provides] [-R|--requires] [--filter-private]
[--soname-only] [--no-fake-soname] [--assume-exec] [-?|--help]
[--usage]
EOF
print $message;
exit (0);
}
sub help {
my $message = <<EOF;
Usage: $0 [OPTION...]
-P, --provides
-R, --requires
--filter-private
--soname-only
--no-fake-soname
--assume-exec
Help options:
-?, --help Show this help message
--usage Display brief usage message
EOF
print $message;
exit (0);
}
while ( $a = shift @ARGV ) {
if ( $a =~ /--assume-exec/ ||
$a =~ /--provides/ ||
$a =~ /-P/ ||
$a =~ /--requires/ ||
$a =~ /-R/ ||
$a =~ /--filter-private/ ||
$a =~ /--soname-only/ ||
$a =~ /--no-fake-soname/ ||
$a =~ /--filter-private/ ) {
$arglist .= " " . $a;
} elsif ( $a =~ /--help/ || $a =~ /-?/ ) {
help;
} elsif ( $a =~ /--usage/ ) {
usage;
# } elsif ( $a = ~ / / ) {
# } else {
}
}
open HANDLE, "$command $arglist |";
while ((chop($line = <HANDLE>))) {
$line =~ /([^\(]+)(.*)/;
$libs{$1}{$2} = 1;
}
foreach $lib ( keys %libs ) {
$full=`$dlinfo $lib`;
if (!$full) {
delete $libs{$lib};
}
}
foreach $lib ( keys %libs ) {
foreach $key ( keys %{ $libs{$lib} } ) {
print "$lib$key\n";
}
}

5
hpc_elflib.attr Normal file
View File

@ -0,0 +1,5 @@
%__hpc_elflib_provides %{_rpmconfigdir}/hpc_elf.pl --provides --assume-exec %{?__filter_GLIBC_PRIVATE:--filter-private} %{?hpc_dep_gen_attr}
%__hpc_elflib_requires %{_rpmconfigdir}/hpc_elf.pl --requires --assume-exec %{?__filter_GLIBC_PRIVATE:--filter-private} %{?hpc_dep_gen_attr}
%__hpc_elflib_magic ^(setuid )?(setgid )?(sticky )?ELF (32|64)-bit.*executable
%__hpc_elflib_path ^%hpc_prefix
%__hpc_elflib_flags exeonly

View File

@ -152,6 +152,7 @@ EOF\
%global hpc_mpi_dir %{?hpc_mpi_family:%%{hpc_%{hpc_mpi_family}_dir}/} \
%global hpc_mpi_pack_version %{?hpc_mpi_family:%%{hpc_%{hpc_mpi_family}_pack_version}} \
} \
# Preexpanded macros \
%{expand: %%global hpc_prefix %{-M:%hpc_mpi_install_path}%{-C:%hpc_cf_install_path}%{!-M:%{!-C:%{hpc_install_path}}}} \
%{?_hpc_build_mpi:%global _hpc_build_xx 1} \
%{?_hpc_build_compiler:%global _hpc_build_xx 1} \
@ -159,6 +160,13 @@ EOF\
%define _hpc_package_name_compiler %{?hpc_compiler_family:-%{hpc_compiler_family}%{?hpc_cf_pack_version}} \
%define _hpc_package_name_mpi %{?hpc_mpi_family:%{!?_hpc_build_mpi:-%{hpc_mpi_family}%{?hpc_mpi_pack_version}}} \
%global hpc_package_name_end %{_hpc_package_name_compiler}%{_hpc_package_name_mpi}-hpc \
# Dependency Generator \
%global tmp %__elf_exclude_path \
%global __elf_exclude_path (%tmp)|(^%hpc_base) \
%undefine tmp \
%global tmp %__elflib_exclude_path \
%global __elflib_exclude_path (%tmp)|(^%hpc_base) \
%undefine tmp \
%global _hpc_init_done 1
%hpc_init(Cc:Mm:v:V:e:) %{expand:%%_hpc_init %{**}}

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Wed Sep 13 19:27:49 UTC 2017 - eich@suse.com
- Add a dependency generator wrapper for binaries and libraries
to avoid adding standard dependencies for HPC libraries.
-------------------------------------------------------------------
Tue Sep 12 18:54:22 UTC 2017 - eich@suse.com
- Removed unneeded BuildRequires:
-------------------------------------------------------------------
Wed May 3 23:00:31 UTC 2017 - eich@suse.com

View File

@ -23,28 +23,39 @@ Name: suse-hpc
Version: 0.1
Release: 0
Source0: macros.hpc
Source1: LICENSE
Source1: dlinfo.c
Source2: hpc_elf.pl
Source3: hpc_elf.attr
Source4: hpc_elflib.attr
Source5: LICENSE
Url: http://www.suse.com/hpc
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: sed
%description
Provide rpm macros for building and installing SUSE HPC
packages.
%prep
cp %{S:1} .
%build
gcc -o dlinfo dlinfo.c -ldl
%install
mkdir -p %{buildroot}/%{_sysconfdir}/rpm
cp %{S:0} %{buildroot}/%{_sysconfdir}/rpm
%{__cp} %{S:1} .
mkdir -p %{buildroot}%{_sysconfdir}/rpm
install -m 644 %{S:0} %{buildroot}%{_sysconfdir}/rpm
mkdir -p %{buildroot}%{_rpmconfigdir}/fileattrs
install -m 755 %{S:2} dlinfo %{buildroot}%{_rpmconfigdir}
install -m 644 %{S:3} %{S:4} %{buildroot}%{_rpmconfigdir}/fileattrs
cp %{S:5} .
%files
%defattr(-,root,root,-)
%doc LICENSE
%config %{_sysconfdir}/rpm/macros.hpc
%{_rpmconfigdir}/dlinfo
%{_rpmconfigdir}/hpc_elf.pl
%{_rpmconfigdir}/fileattrs/*
%changelog