# ##############################################
# Do NOT Edit the Auto-generated Part!
# Generated by: spectacle version ${metadata.MyVersion}
# ##############################################

Name:       ${metadata.Name}

##
## Pre-defined const and functions
#set $str_newline = '\n'
#def arch_line($value, $pre='', $post='')
#set $rarch, $arch, $value = $arch_split($value)
#if $arch
%ifarch $arch
#end if
${pre}${value}${post}#slurp
#if $arch

%endif#slurp
#end if
#end def
###################
## Macros
# >> macros
#if $extra.content.has_key("macros") and $extra.content.macros.has_key("main")
$str_newline.join($extra.content.macros.main)
#end if
# << macros
#if $extra.HasStatic
%define keepstatic 1
#set $cfgstatic = ""
#else
#set $cfgstatic = "--disable-static"
#end if
#if $metadata.has_key("Macros")
#for $macro_key,$macro_value in $metadata.Macros.items()
%define $macro_key $macro_value
#end for
#end if
#if $metadata.has_key('Builder')
#set $Builder = $metadata.Builder
#else
## default
#set $Builder = 'make'
#end if

#if $Builder == 'python'
#if $metadata.has_key("BuildArch") and $metadata.BuildArch == 'noarch'
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
#else
%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
#end if
#end if
Summary:    ${metadata.Summary}
Version:    ${metadata.Version}
Release:    ${metadata.Release}
#if $metadata.has_key("Epoch")
Epoch:      ${metadata.Epoch}
#set $auto_depend = "%{epoch}:%{version}-%{release}"
#else
#set $auto_depend = "%{version}-%{release}"
#end if
Group:      ${metadata.Group}
License:    ${metadata.License}
#if $metadata.has_key("ExclusiveArch")
ExclusiveArch:  ${metadata.ExclusiveArch}
#end if
#if $metadata.has_key("BuildArch")
BuildArch:  ${metadata.BuildArch}
#end if
#if $metadata.has_key("Prefix")
Prefix:  ${metadata.Prefix}
#end if
#if $metadata.has_key("URL")
URL:        ${metadata.URL}
#end if
## Sources
#if $metadata.has_key("Sources")
#set $idx = 0
#for $source in $metadata.Sources
Source${idx}:    $source
#set $idx = $idx + 1
#end for
#end if
Source100:  ${metadata.Name}.yaml
#if $metadata.has_key("RpmLintIgnore")
Source101:  ${metadata.Name}-rpmlintrc
#end if
## Patches
#if $metadata.has_key("Patches")
#set $idx = 0
#for $patch in $metadata.Patches
$arch_line($patch, "Patch%d:     "%$idx)
#set $idx = $idx + 1
#end for ## each patch
#end if
#if 'NoAutoReq' in $metadata
AutoReq: 0
#end if
#if 'NoAutoReqProv' in $metadata
AutoReqProv:    0
#end if
## Requires
#if $Builder == 'perl'
Requires:   perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo \$version))
#end if
#if $metadata.has_key("Requires")
#for $req in $metadata.Requires
$arch_line($req, 'Requires:   ')
#end for ## each req
#end if
#if $metadata.has_key("RequiresPre")
#for $req in $metadata.RequiresPre
Requires(pre): $req
#end for
#end if
#if $metadata.has_key("RequiresPreUn")
#for $req in $metadata.RequiresPreUn
Requires(preun): $req
#end for
#end if
#if $metadata.has_key("RequiresPost")
#for $req in $metadata.RequiresPost
Requires(post): $req
#end for
#end if
#if $metadata.has_key("RequiresPostUn")
#for $req in $metadata.RequiresPostUn
Requires(postun): $req
#end for
#end if
## BuildRequires
#if $metadata.has_key("PkgConfigBR")
#for $br in $metadata.PkgConfigBR
#set $br_comps = $br.split()
#if $len($br_comps) > 1
$arch_line($br_comps[0], "BuildRequires:  pkgconfig(", ")%s" % $br[$len($br_comps[0]):])
#else
$arch_line($br, "BuildRequires:  pkgconfig(", ")")
#end if
#end for ## each br
#end if
#if $metadata.has_key("PkgBR")
#for $br in $metadata.PkgBR
$arch_line($br, "BuildRequires:  ")
#end for ## each br
#end if
## BuildConflicts
#if $metadata.has_key("BuildConflicts")
#for $bcfl in $metadata.BuildConflicts
BuildConflicts: $bcfl
#end for
#end if
#if $metadata.has_key("RunFdupes")
BuildRequires:  fdupes
#end if
#if $Builder == 'cmake'
BuildRequires:  cmake
#end if
#if 'NoAutoProv' in $metadata
AutoProv: 0
#end if
## Provides
#if $metadata.has_key("Provides")
#for $prd in $metadata.Provides
Provides:   $prd
#end for
#end if
## Conflicts
#if $metadata.has_key("Conflicts")
#for $cfl in $metadata.Conflicts
Conflicts:   $cfl
#end for
#end if
## Obsoletes
#if $metadata.has_key("Obsoletes")
#for $obs in $metadata.Obsoletes
Obsoletes:   $obs
#end for
#end if
#if 'SupportOtherDistros' in $metadata
BuildRoot:  %{_tmppath}/%{name}-%{version}-build
#end if

%description
#if $metadata.has_key("Description")
${metadata.Description}
#else
Description: %{summary}
#end if

#if $metadata.has_key("SubPackages")
#for $sp in $metadata.SubPackages
#set $sub_extra = $extra.subpkgs[$sp.Name]
#if $sp.has_key("AsWholeName")
%package -n $sp.Name
#else
%package $sp.Name
#end if
Summary:    $sp.Summary
#if $sp.has_key("License")
License:    $sp.License
#end if
#if $sp.has_key("Group")
Group:      $sp.Group
#else
Group:      ${metadata.Group}
#end if
#if $sp.has_key("Version")
Version:    $sp.Version
#end if
#if $sp.has_key("Release")
Release:    $sp.Release
#end if
#if $sp.has_key("Epoch")
Epoch:    $sp.Epoch
#end if
#if $sp.has_key("URL")
URL:    $sp.URL
#end if
#if $sp.has_key("BuildArch")
BuildArch:    $sp.BuildArch
#end if
#if $sp.has_key("Prefix")
Prefix:    $sp.Prefix
#end if
#if 'NoAutoReq' in $sp
AutoReq:    0
#end if
#if 'NoAutoProv' in $sp
AutoProv:    0
#end if
#if 'NoAutoReqProv' in $sp
AutoReqProv:    0
#end if
#if $sp.has_key("AutoDepend") and not $metadata.has_key("NoFiles")
Requires:   %{name} = $auto_depend
#end if
#if $sp.has_key("Requires")
#for $req in $sp.Requires
$arch_line($req, "Requires:   ")
#end for ## each req
#end if
#if $sp.has_key("RequiresPre")
#for $req in $sp.RequiresPre
Requires(pre): $req
#end for
#end if
#if $sp.has_key("RequiresPreUn")
#for $req in $sp.RequiresPreUn
Requires(preun): $req
#end for
#end if
#if $sp.has_key("RequiresPost")
#for $req in $sp.RequiresPost
Requires(post): $req
#end for
#end if
#if $sp.has_key("RequiresPostUn")
#for $req in $sp.RequiresPostUn
Requires(postun): $req
#end for
#end if
## Provides
#if $sp.has_key("Provides")
#for $prd in $sp.Provides
Provides:   $prd
#end for
#end if
## Conflicts
#if $sp.has_key("Conflicts")
#for $cfl in $sp.Conflicts
Conflicts:   $cfl
#end for
#end if
## Obsoletes
#if $sp.has_key("Obsoletes")
#for $obs in $sp.Obsoletes
Obsoletes:   $obs
#end for
#end if
## BR
#if $sp.has_key("PkgBR")
#for $br in $sp.PkgBR
$arch_line($br, "BuildRequires:   ")
#end for ## each br
#end if
## PkgConfigBR
#if $sp.has_key("PkgConfigBR")
#for $br in $sp.PkgConfigBR
#set $br_comps = $br.split()
#if $len($br_comps) > 1
$arch_line($br_comps[0], "BuildRequires:  pkgconfig(", ")%s" % $br[$len($br_comps[0]):])
#else
$arch_line($br, "BuildRequires:  pkgconfig(", ")")
#end if
#end for ## each br
#end if
## BuildConflicts
#if $sp.has_key("BuildConflicts")
#for $bcfl in $sp.BuildConflicts
BuildConflicts: $bcfl
#end for
#end if

#if $sp.has_key("AsWholeName")
%description -n $sp.Name
#else
%description $sp.Name
#end if
#if $sp.has_key('Description')
$sp.Description
#else
Description: %{summary}
#end if

#end for
#end if
###################
## Macros2
#if $metadata.has_key("Macros2") or $extra.content.has_key("macros2")

#if $extra.content.has_key("macros2") and $extra.content.macros2.has_key("main") and $extra.content.macros2.main
# >> macros2
$str_newline.join($extra.content.macros2.main)
# << macros2
#end if
#if $metadata.has_key("Macros2")
#for $macro_key,$macro_value in $metadata.Macros2.items()
%define $macro_key $macro_value
#end for
#end if
#end if

############################ prep scripts
%prep
#if $metadata.has_key("Sources")
#if $metadata.has_key("NoSetup")
# No setup
#else if $metadata.has_key("SetupOptions")
%setup $metadata.SetupOptions
#else
%setup -q -n $metadata.SourcePrefix
#end if

#end if ## has Sources
## Applying patches
#if $metadata.has_key("Patches")
#set $idx = 0
#for $patch in $metadata.Patches
#if "PatchCmts" in $metadata
$metadata.PatchCmts[$idx]
#end if
#if 'PatchOpts' in $metadata
$arch_line($patch, "# ", "\n%%patch%d %s"%($idx, $metadata.PatchOpts[$idx]))
#else
$arch_line($patch, "# ", "\n%%patch%d -p1"%$idx)
#end if
#set $idx = $idx + 1
#end for ## each patch
#end if
# >> setup
#if $extra.content.has_key("setup") and $extra.content.setup.has_key("main")
$str_newline.join($extra.content.setup.main)
#end if
# << setup

############################ build scripts
%build
#if not $metadata.has_key('UseAsNeeded')
unset LD_AS_NEEDED
#end if
# >> build pre
#if $extra.content.has_key("build") and $extra.content.build.has_key("pre")
$str_newline.join($extra.content.build.pre)
#end if
# << build pre

############################
#if $Builder == 'python'
CFLAGS="\$RPM_OPT_FLAGS" %{__python} setup.py build
#else if $Builder == 'qmake'
#set $Configure = 'none'
#if 'SupportOtherDistros' in $metadata
%if 0%{?moblin_version}
%qmake #slurp
#if 'QMakeOptions' in $metadata
 \
#else

#end if
%else
qmake -makefile -nocache \
  "QMAKE_CFLAGS_RELEASE=\${CFLAGS:-%optflags}" \
  "QMAKE_CFLAGS_DEBUG=\${CFLAGS:-%optflags}" \
  "QMAKE_CXXFLAGS_RELEASE=\${CXXFLAGS:-%optflags}" \
  "QMAKE_CXXFLAGS_DEBUG=\${CXXFLAGS:-%optflags}" \
  QMAKE_STRIP=: \
  PREFIX=%{_prefix} #slurp
#if 'QMakeOptions' in $metadata
 \
#else

#end if
%endif
#else
%qmake #slurp
#if 'QMakeOptions' in $metadata
 \
#else

#end if
#end if
#if 'QMakeOptions' in $metadata
#set $length = len($metadata.QMakeOptions)
#set $idx = 1
#for $opt in $metadata.QMakeOptions
#if $idx == $length
$arch_line($opt, "    ")
#else
$arch_line($opt, "    ", " \\")
#end if
#set $idx = $idx + 1
#end for
#end if  ## QMakeOptions

make %{?jobs:-j%jobs}
#else if $Builder == 'perl'
if test -f Makefile.PL; then
%{__perl} Makefile.PL INSTALLDIRS=vendor
make %{?jobs:-j%jobs}
else
%{__perl} Build.PL  --installdirs vendor
./Build
fi
#else
#######
#if $metadata.has_key('Configure')
#set $Configure = $metadata.Configure
#######
#else
## default
#if $Builder == 'cmake'
#set $Configure = 'cmake'
#else
#set $Configure = 'configure'
#end if
#end if
#######
#if $Configure == 'autogen'
%autogen $cfgstatic
%configure $cfgstatic#slurp
#else if $Configure == 'cmake'
%cmake . #slurp
#else if $Configure == 'configure'
%configure $cfgstatic#slurp
#else if $Configure == 'reconfigure'
%reconfigure $cfgstatic#slurp
#end if
## any other values fall thru to 'noconfigure'
#if ( $Configure != 'noconfigure' or $Configure != 'none' ) and $metadata.has_key("ConfigOptions")
 \
#set $length = len($metadata.ConfigOptions)
#set $idx = 1
#for $opt in $metadata.ConfigOptions
## checking arch namespace prefix
#if $idx == $length
$arch_line($opt, "    ")
#else
$arch_line($opt, "    ", " \\")
#end if
#set $idx = $idx + 1
#end for
#end if ## ConfigOptions

#if $Builder == 'make' or $Builder == 'cmake'
make %{?jobs:-j%jobs}
#else if $Builder == 'single-make'
make
#else if $Builder != 'no-make' and $Builder != 'none' and $Builder != 'no-builder'
$Builder
#end if
#end if ## Builder == python
############################

# >> build post
#if $extra.content.has_key("build") and  $extra.content.build.has_key("post")
$str_newline.join($extra.content.build.post)
#end if
# << build post

############################ installation scripts
%install
#if 'SupportOtherDistros' in $metadata
rm -rf \$RPM_BUILD_ROOT
#else
rm -rf %{buildroot}
#end if
# >> install pre
#if $extra.content.has_key("install") and  $extra.content.install.has_key("pre")
$str_newline.join($extra.content.install.pre)
#end if
# << install pre
#if $Builder == 'python'
#if 'SupportOtherDistros' in $metadata
%if 0%{?suse_version}
%{__python} setup.py install --root=\$RPM_BUILD_ROOT --prefix=%{_prefix}
%else
%{__python} setup.py install --root=\$RPM_BUILD_ROOT -O1
%endif
#else
%{__python} setup.py install --root=%{buildroot} -O1
#end if
#else if $Builder == 'perl'
if test -f Makefile.PL; then
make pure_install PERL_INSTALL_ROOT=%{buildroot}
else
./Build install --installdirs vendor
fi
find %{buildroot} -type f -name .packlist -exec rm -f {} ';'
find %{buildroot} -depth -type d -exec rmdir {} 2>/dev/null ';'
find %{buildroot} -type f -name '*.bs' -empty -exec rm -f {} ';'
%{_fixperms} %{buildroot}/*
#else if $Builder == 'qmake'
#if 'SupportOtherDistros' in $metadata
%if 0%{?moblin_version}
%qmake_install
%else
%makeinstall
%endif
#else
%qmake_install
#end if
#else if $Builder == 'make' or $Builder == 'single-make' or $Builder == 'cmake'
#if 'SupportOtherDistros' in $metadata
%if 0%{?moblin_version}
%make_install
%else
%makeinstall
%endif
#else
%make_install
#end if ## SupportOtherDistros
#end if ## of Builder == 'make' ...
#if $metadata.has_key("ExtraInstall")
$metadata.ExtraInstall
#end if

# >> install post
#if $extra.content.has_key("install") and $extra.content.install.has_key("post")
$str_newline.join($extra.content.install.post)
#end if
# << install post

#if $extra.Desktop
desktop-file-install --delete-original       \
  --dir %{buildroot}%{_datadir}/applications             \
   %{buildroot}%{_datadir}/applications/*.desktop
#end if
#if $metadata.has_key("LocaleName")
#if $metadata.has_key("LocaleOptions")
#set $localeopt_str = $metadata["LocaleOptions"]
%find_lang ${metadata.LocaleName} $localeopt_str
#else
%find_lang ${metadata.LocaleName}
#end if
#end if
############################ run fdupes
#if $metadata.has_key("RunFdupes")
#for $fditem in $metadata.RunFdupes
%fdupes  %{buildroot}/$fditem
#end for
#end if
############################ optional check scripts
#if $metadata.has_key("Check")

%check
# >> check
#if $extra.content.has_key("check")
$str_newline.join($extra.content.check.main)
#else
#if  $Builder == 'perl'
if test -f Makefile.PL; then
make test
else
./Build test
fi
#else
make check
#end if
#end if
# << check
#end if
############################ Pre
#set $has_extra_pre = $extra.content.has_key("pre") and $extra.content.pre.has_key("main")
#if $extra.Schema or $has_extra_pre

%pre
## -Schema
#if $extra.Schema
if [ "$1" -gt 1 ]; then
#for $schema in $extra.Schemas
  export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
  gconftool-2 --makefile-uninstall-rule \
    $schema \
    > /dev/null || :
#end for
fi
#end if
## -Extra pre
#if $has_extra_pre
# >> pre
$str_newline.join($extra.content.pre.main)
# << pre
#end if
#end if
############################ PreUn
#set $has_extra_preun = $extra.content.has_key("preun") and $extra.content.preun.has_key("main")
#if $extra.Schema or $extra.SystemdService or $has_extra_preun

%preun
## -Schema
#if $extra.Schema
if [ "$1" -eq 0 ]; then
#for $schema in $extra.Schemas
  export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
  gconftool-2 --makefile-uninstall-rule \
    $schema \
    > /dev/null || :
#end for
fi
#end if
## -SystemdService (systemd)
#if $extra.SystemdService
if [ "$1" -eq 0 ]; then
#for $srv in $extra.SystemdServices
systemctl stop $srv
#end for
fi
#end if
## -Extra preun
#if $has_extra_preun
# >> preun
$str_newline.join($extra.content.preun.main)
# << preun
#end if
#end if
############################ Post
#set $has_extra_post = $extra.content.has_key("post") and $extra.content.post.has_key("main") and $extra.content.post.main
#if $extra.Lib or $extra.Info or $extra.Schema or $extra.Icon or $extra.DesktopDB or $extra.SystemdService or $has_extra_post

#set $only_Lib = not ($extra.Info or $extra.Schema or $extra.Icon or $extra.DesktopDB or $extra.SystemdService or $has_extra_post)
#if $only_Lib
%post -p /sbin/ldconfig
#else
%post
#end if
## -Lib
#if $extra.Lib and not $only_Lib
/sbin/ldconfig
#end if
## -Schema
#if $extra.Schema
#for $schema in $extra.Schemas
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
gconftool-2 --makefile-install-rule \
    $schema  > /dev/null || :
#end for
#end if
## -Info
#if $extra.Info
#for $inf in $extra.Infos
%install_info --info-dir=%_infodir $inf
#end for
#end if
## -Icon
#if $extra.Icon
/bin/touch --no-create %{_datadir}/icons/hicolor || :
%{_bindir}/gtk-update-icon-cache \
  --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
#end if
## -DesktopDB
#if $extra.DesktopDB
update-desktop-database %{_datadir}/applications &> /dev/null || :
#end if
## -SystemdService (systemd)
#if $extra.SystemdService
systemctl daemon-reload
#for $srv in $extra.SystemdServices
systemctl reload-or-try-restart $srv
#end for
#end if
## -Extra Post Script
#if $has_extra_post
# >> post
$str_newline.join($extra.content.post.main)
# << post
#end if
#end if ## need post
############################ PostUn
#set $has_extra_postun = $extra.content.has_key("postun") and $extra.content.postun.has_key("main") and $extra.content.postun.main
#if $extra.Lib or $extra.Info or $extra.Icon or $extra.DesktopDB or $extra.SystemdService or $has_extra_postun

#set $only_Lib = not ($extra.Info or $extra.Icon or $extra.DesktopDB or $extra.SystemdService or $has_extra_postun)
#if $only_Lib
%postun -p /sbin/ldconfig
#else
%postun
#end if
#if $extra.Lib and not $only_Lib
/sbin/ldconfig
#end if
## -Info
#if $extra.Info
if [ $1 = 0 ] ;then
#for $inf in $extra.Infos
%install_info_delete --info-dir=%{_infodir} $inf
#end for
fi
#end if
## -Icon
#if $extra.Icon
/bin/touch --no-create %{_datadir}/icons/hicolor || :
%{_bindir}/gtk-update-icon-cache \
  --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
#end if
## -DesktopDB
#if $extra.DesktopDB
update-desktop-database %{_datadir}/applications &> /dev/null || :
#end if
## -SystemdService (systemd)
#if $extra.SystemdService
systemctl daemon-reload
#end if
## -Extra Postun Script
#if $has_extra_postun
# >> postun
$str_newline.join($extra.content.postun.main)
# << postun
#end if
#end if ## need postun
########################################
## Pre/Preun/Post/Postun for SubPackages
#if $metadata.has_key("SubPackages")
#for $sp in $metadata.SubPackages
#if $sp.has_key("AsWholeName")
#set $pkg_name = "-n " + $sp.Name
#else
#set $pkg_name = $sp.Name
#end if
#set $sub_extra = $extra.subpkgs[$sp.Name]
#######################
## Pre for SubPackages
#set $has_extra_pre = $extra.content.has_key("pre") and $extra.content.pre.has_key($sp.Name)
#if $sub_extra.Schema or $has_extra_pre

%pre $pkg_name
## -Schema
#if $sub_extra.Schema
if [ "$1" -gt 1 ]; then
#for $schema in $sub_extra.Schemas
  export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
  gconftool-2 --makefile-uninstall-rule \
    $schema \
    > /dev/null || :
#end for
fi
#end if
## -Extra pre
#if $has_extra_pre
# >> pre $sp.Name
$str_newline.join($extra.content.pre[$sp.Name])
# << pre $sp.Name
#end if
#end if
#######################
## Preun for SubPackages
#set $has_extra_preun = $extra.content.has_key("preun") and $extra.content.preun.has_key($sp.Name)
#if $sub_extra.Schema or $sub_extra.SystemdService or $has_extra_preun

%preun $pkg_name
## -Schema
#if $sub_extra.Schema
if [ "$1" -eq 0 ]; then
#for $schema in $sub_extra.Schemas
  export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
  gconftool-2 --makefile-uninstall-rule \
    $schema \
    > /dev/null || :
#end for
fi
#end if
## -SystemdService (systemd)
#if $sub_extra.SystemdService
if [ "$1" -eq 0 ]; then
#for $srv in $sub_extra.SystemdServices
systemctl stop $srv
#end for
fi
#end if
## -Extra preun
#if $has_extra_preun
# >> preun $sp.Name
$str_newline.join($extra.content.preun[$sp.Name])
# << preun $sp.Name
#end if
#end if
#######################
## Post for SubPackages
#set $has_extra_post = $extra.content.has_key("post") and $extra.content.post.has_key($sp.Name) and $extra.content.post[$sp.Name]
#if $sub_extra.Lib or $sub_extra.Info or $sub_extra.Icon or $sub_extra.Schema or $sub_extra.DesktopDB or $sub_extra.SystemdService or $has_extra_post

#set $only_Lib = not ($sub_extra.Info or $sub_extra.Icon or $sub_extra.Schema or $sub_extra.DesktopDB or $sub_extra.SystemdService or $has_extra_post)
#if $only_Lib
%post $pkg_name -p /sbin/ldconfig
#else
%post $pkg_name
#end if
## -Lib
#if $sub_extra.Lib and not $only_Lib
/sbin/ldconfig
#end if
## -Schema
#if $sub_extra.Schema
#for $schema in $sub_extra.Schemas
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
gconftool-2 --makefile-install-rule \
    $schema  > /dev/null || :
#end for
#end if
## -Info
#if $sub_extra.Info
#for $inf in $sub_extra.Infos
%install_info --info-dir=%_infodir $inf
#end for
#end if ## Info
## -Icon
#if $sub_extra.Icon
/bin/touch --no-create %{_datadir}/icons/hicolor || :
%{_bindir}/gtk-update-icon-cache \
  --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
#end if
## -DesktopDB
#if $sub_extra.DesktopDB
update-desktop-database %{_datadir}/applications &> /dev/null || :
#end if
## -SystemdService (systemd)
#if $sub_extra.SystemdService
systemctl daemon-reload
#for $srv in $sub_extra.SystemdServices
systemctl reload-or-try-restart $srv
#end for
#end if
## -Extra Post Script
#if $has_extra_post
# >> post $sp.Name
$str_newline.join($extra.content.post[$sp.Name])
# << post $sp.Name
#end if
#end if ## need post
#######################
## PostUn for SubPackages
#set $has_extra_postun = $extra.content.has_key("postun") and $extra.content.postun.has_key($sp.Name) and $extra.content.postun[$sp.Name]
#if  $sub_extra.Lib or $sub_extra.Info or $sub_extra.Icon or $sub_extra.DesktopDB or $sub_extra.SystemdService or $has_extra_postun

#set $only_Lib = not ($sub_extra.Info or $sub_extra.Icon or $sub_extra.DesktopDB or $sub_extra.SystemdService or $has_extra_postun)
#if $only_Lib
%postun $pkg_name -p /sbin/ldconfig
#else
%postun $pkg_name
#end if
#if $sub_extra.Lib and not $only_Lib
/sbin/ldconfig
#end if
#if $sub_extra.Info
if [ $1 = 0 ] ;then
#for $inf in $sub_extra.Infos
%install_info_delete --info-dir=%{_infodir} $inf
#end for
fi
#end if ## Info
## -Icon
#if $sub_extra.Icon
/bin/touch --no-create %{_datadir}/icons/hicolor || :
%{_bindir}/gtk-update-icon-cache \
  --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
#end if
## -DesktopDB
#if $sub_extra.DesktopDB
update-desktop-database %{_datadir}/applications &> /dev/null || :
#end if
## -SystemdService (systemd)
#if $sub_extra.SystemdService
systemctl daemon-reload
#end if
## -Extra Postun Script
#if $has_extra_postun
# >> postun $sp.Name
$str_newline.join($extra.content.postun[$sp.Name])
# << postun $sp.Name
#end if
#end if ## need postun
#end for ## per subpackage
#end if ## has subpackages
#if not $metadata.has_key("NoFiles")

#if (not $metadata.has_key('LocaleFilesPkgName') or $metadata.LocaleFilesPkgName == $metadata.Name) and $metadata.has_key("LocaleName")
%files -f ${metadata.LocaleName}.lang
#else if $metadata.has_key('FilesInput')
%files -f $metadata.FilesInput
#else
%files
#end if
%defattr(-,root,root,-)
## TODO to be cleanup
#if $metadata.has_key("Documents")
#for $doc in $metadata.Documents
%doc $doc
#end for
#end if
#if "Files" in $metadata:
#for $f in $metadata.Files
$arch_line($f)
#end for
#end if
# >> files
#if $extra.content.has_key("files") and $extra.content.files.has_key("main")
$str_newline.join($extra.content.files.main)
#end if
# << files
#end if ## not NoFiles
## files for subpkgs
#if $metadata.has_key("SubPackages")
#for $sp in $metadata.SubPackages
#if $sp.has_key("AsWholeName")
#set $pkg_name = "-n " + $sp.Name
#else
#set $pkg_name = $sp.Name
#end if

#if $metadata.has_key("LocaleName") and $metadata.has_key('LocaleFilesPkgName') and $metadata.LocaleFilesPkgName == $pkg_name
%files $pkg_name -f ${metadata.LocaleName}.lang
#else if $sp.has_key('FilesInput')
%files $pkg_name -f $sp.FilesInput
#else
%files $pkg_name
#end if
%defattr(-,root,root,-)
## TODO to be cleanup
#if $sp.has_key("Documents")
#for $doc in $sp.Documents
%doc $doc
#end for
#end if
#if "Files" in $sp:
#for $f in $sp.Files
$arch_line($f)
#end for
#end if
# >> files $sp.Name
#if $extra.content.has_key("files") and $extra.content.files.has_key($sp.Name)
$str_newline.join($extra.content.files[$sp.Name])
#end if
# << files $sp.Name
#end for
#end if
