diff --git a/dlinfo.c b/dlinfo.c new file mode 100644 index 0000000..cfe3f3e --- /dev/null +++ b/dlinfo.c @@ -0,0 +1,27 @@ +#define _GNU_SOURCE +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + void *dlh; + struct link_map *linkmap; + + if (argc != 2) { + fprintf(stderr, "Usage: %s \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); +} diff --git a/hpc_elf.attr b/hpc_elf.attr new file mode 100644 index 0000000..699960d --- /dev/null +++ b/hpc_elf.attr @@ -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 diff --git a/hpc_elf.pl b/hpc_elf.pl new file mode 100644 index 0000000..4383c8c --- /dev/null +++ b/hpc_elf.pl @@ -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 = <))) { + $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"; + } +} + diff --git a/hpc_elflib.attr b/hpc_elflib.attr new file mode 100644 index 0000000..8518a89 --- /dev/null +++ b/hpc_elflib.attr @@ -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 diff --git a/macros.hpc b/macros.hpc index db20315..5905839 100644 --- a/macros.hpc +++ b/macros.hpc @@ -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 %{**}} diff --git a/suse-hpc.changes b/suse-hpc.changes index aecdf63..21f4fe4 100644 --- a/suse-hpc.changes +++ b/suse-hpc.changes @@ -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 diff --git a/suse-hpc.spec b/suse-hpc.spec index 0e9ac01..f23981f 100644 --- a/suse-hpc.spec +++ b/suse-hpc.spec @@ -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