%bcond_with unpackaged_dirs
%bcond_with unpackaged_files
%bcond_with owned_dir
%bcond_with crossdir_links

Summary:          Testing hard link behavior
Name:             hlinktest
Version:          1.0
Release:          1
License:          Testing
Group:            Testing
BuildArch:	  noarch
Provides: /bin/sh
%description
  
%install
mkdir -p $RPM_BUILD_ROOT/foo
cat << EOF >> $RPM_BUILD_ROOT/foo/hello
#!/bin/sh
echo %{name}-%{version}
EOF

cd $RPM_BUILD_ROOT/foo
cat hello > copyllo
cat hello > aaaa
ln aaaa zzzz
chmod a+x hello copyllo
for f in foo bar world; do
    ln hello hello-${f}
done

%if %{with crossdir_links}
mkdir -p $RPM_BUILD_ROOT/xmark
ln $RPM_BUILD_ROOT/foo/aaaa $RPM_BUILD_ROOT/xmark/
ln $RPM_BUILD_ROOT/foo/hello $RPM_BUILD_ROOT/xmark/
%endif

%if %{with unpackaged_dirs}
mkdir -p $RPM_BUILD_ROOT/zoo/
%endif

%if %{with unpackaged_files}
touch $RPM_BUILD_ROOT/toot
%endif

%files
%defattr(-,root,root)
%if %{with owned_dir}
%dir /foo
%endif
%if %{with crossdir_links}
/xmark
%endif
/foo/*
