rpm/rpm-suse_macros

470 lines
16 KiB
Plaintext

%suse_check \
%{?buildroot:RPM_BUILD_ROOT=\"%{buildroot}\"\
export RPM_BUILD_ROOT}\
test -x /usr/sbin/Check -a $UID = 0 -o -x /usr/sbin/Check -a ! -z "$RPM_BUILD_ROOT" && {\
echo "I call /usr/sbin/Check..."\
/usr/sbin/Check\
}
# directories
%_infodir %{_prefix}/share/info
%_mandir %{_prefix}/share/man
%_sysconfdir /etc
%_localstatedir /var
%_defaultdocdir %{_usr}/share/doc/packages
# package build macros
%makeinstall make DESTDIR=%{buildroot} install
%tcl_version %(echo 'puts [package require Tcl]' | tclsh)
%insserv_prereq insserv
%fillup_prereq fillup fileutils
%install_info_prereq info
%__os_install_post \
%{suse_check} \
/usr/lib/rpm/brp-compress \
%{nil}
# perl_vendorarch is defined
# perl_vendorlib is defined
%perl_make_install make DESTDIR=$RPM_BUILD_ROOT install_vendor
%perl_process_packlist(n:) \
mkdir -p $RPM_BUILD_ROOT/var/adm/perl-modules \
test -f $RPM_BUILD_ROOT%{perl_archlib}/perllocal.pod && { sed -e "s@$RPM_BUILD_ROOT@@g" < $RPM_BUILD_ROOT%{perl_archlib}/perllocal.pod > $RPM_BUILD_ROOT/var/adm/perl-modules/%{-n:%{-n*}}%{!-n:%{name}} ; } ; \
test -n "$RPM_BUILD_ROOT" -a -d $RPM_BUILD_ROOT/%perl_sitearch/auto && find $RPM_BUILD_ROOT/%perl_sitearch/auto -name .packlist -print0 | xargs -0 -r perl -spi -e "s@$RPM_BUILD_ROOT@@g" ; \
test -n "$RPM_BUILD_ROOT" -a -d $RPM_BUILD_ROOT/%perl_vendorarch/auto && find $RPM_BUILD_ROOT/%perl_vendorarch/auto -name .packlist -print0 | xargs -0 -r perl -spi -e "s@$RPM_BUILD_ROOT@@g" ; \
rm -f $RPM_BUILD_ROOT%{perl_archlib}/perllocal.pod \
%nil
# macro: %suse_update_desktop_file
# Used to add easily a category to .desktop files according to XDG
# standard.
%suse_update_desktop_file(:-:) \
/usr/lib/rpm/suse_update_desktop_file.sh %{**} || exit 1 \
%nil
# macro: %restart_on_update()
# Used to restart a service in postun section, if we are
# not running from YaST2 in instsys on update.
%restart_on_update() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
if test "$FIRST_ARG" -ge 1 ; then \
test -f /etc/sysconfig/services && . /etc/sysconfig/services \
if test "$YAST_IS_RUNNING" != "instsys" -a "$DISABLE_RESTART_ON_UPDATE" != yes ; then \
for service in %{?*} ; do \
/etc/init.d/$service try-restart > /dev/null || : \
done \
fi \
fi \
%nil
# macro: %stop_on_removal()
# Used to stop a service in preun section, if we are
# not running from YaST2 in instsys on removal of this package.
%stop_on_removal() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
if test "$FIRST_ARG" = "0" ; then \
test -f /etc/sysconfig/services && . /etc/sysconfig/services \
if test "$YAST_IS_RUNNING" != "instsys" -a "$DISABLE_STOP_ON_REMOVAL" != yes ; then \
for service in %{?*} ; do \
/etc/init.d/$service stop > /dev/null \
done \
fi \
fi \
%nil
# macro: %configure_kernel_source
#
#
%configure_kernel_source() \
if test -d /usr/src/linux ; then \
pushd /usr/src/linux \
test -f .config || cp arch/%_arch/defconfig.default .config \
yes "" | make oldconfig \
make dep \
popd \
fi \
%nil
%is_plus %(if test -f /.buildenv ; then source /.buildenv ; if [[ "$BUILD_BASENAME" == *+kde ]] ; then echo 1 ; else echo 0 ; fi ; else echo 0 ; fi)
%run_permissions() \
if test "$YAST_IS_RUNNING" != "instsys" ; then \
if test -x /sbin/SuSEconfig -a -f /sbin/conf.d/SuSEconfig.permissions ; then \
/sbin/SuSEconfig --module permissions \
fi \
fi \
%nil
%run_suseconfig(m:) \
%{!-m:echo -e "\\nERROR: missing parameter for macro run_suseconfig\\n" ; exit 1 ; } \
if test "$YAST_IS_RUNNING" != "instsys" ; then \
if test -x /sbin/SuSEconfig -a -f /sbin/conf.d/SuSEconfig.%{-m*} ; then \
/sbin/SuSEconfig --module %{-m*} \
else \
echo -e "\\nERROR: SuSEconfig or requested SuSEconfig module not present!\\n" ; exit 1 \
fi \
fi \
%nil
%verify_permissions(:-:) \
if test -f /etc/sysconfig/security ; then \
source /etc/sysconfig/security \
fi \
PERMFILES="/etc/permissions" \
for PERMEXT in $PERMISSION_SECURITY ; do \
if test -f /etc/permissions.$PERMEXT ; then \
PERMFILES="$PERMFILES /etc/permissions.$PERMEXT" \
fi \
done \
/usr/bin/chkstat -n %{**} $PERMFILES 1>&2 \
%nil
# %{suse_update_config [-fcl] [dirs...]}
# -f: force, ignore timestamp
# -c: no config.guess,config.sub
# -l: no ltconfig,ltmain.sh
%suse_update_config(fcl) \
AUTOMAKE_DIR=/usr/share/automake \
[ -d $AUTOMAKE_DIR ] || AUTOMAKE_DIR=/usr/share/automake* \
%{!-c:\
[ -d $AUTOMAKE_DIR ] || { \
echo 'Please, install automake.' \
exit 1 \
} \
} \
for d in . %{?*}; do \
%{!-c:\
for f in config.sub config.guess; do \
if test -f $d/$f -a ! $d/$f -ef $AUTOMAKE_DIR/$f ; then \
%{!-f:[ $d/$f -nt $AUTOMAKE_DIR/$f ] ||} cp -f $AUTOMAKE_DIR/$f $d/$f \
fi \
if test -d $d -a ! -f $d/depcomp -a -f $AUTOMAKE_DIR/depcomp ; then \
cp -f $AUTOMAKE_DIR/depcomp $d/depcomp \
echo "please add depcomp to sources for new automake!" \
fi \
if test -f $d/missing -a ! $d/missing -ef $AUTOMAKE_DIR/missing ; then \
cp -f $AUTOMAKE_DIR/missing $d/missing \
fi \
done \
} \
%{!-l:\
for f in ltconfig ltmain.sh; do \
if test -f $d/$f; then \
sed 's/linux-gnu\\([^*][^*]*\\)\\*/linux*\\1*/g; s/linux-gnu/linux/g; s,/lib\\\>,/%_lib,g; s,/%_lib\\([\$-]\\),/lib\\1,g' $d/$f > $d/$f-$$ && \
mv -f $d/$f-$$ $d/$f \
chmod +x $d/$f \
fi \
done \
} \
done \
%suse_update_libdir() \
if [ %_lib != lib ]; then \
for file in %{?*} ; do \
[ ! -e $file ] && echo "Error: $file does not exist!" && exit -1 \
[ -e $file.nolib64 ] && echo "Error: $file.nolib64 already exists!" && exit -1 \
cp $file $file.nolib64 \
echo "patching $file" \
sed -e "s,/lib\\\>,/%_lib,g" $file.nolib64 | sed -e "s,/%_lib/cpp,/lib/cpp,; s,/usr/%_lib/perl,/usr/lib/perl, ; s,/%_lib\\([\$-]\\),/lib\\1,g" > $file \
rm -f $file.nolib64 \
done; \
fi ; \
# macro: fillup_and_insserv
# do the fillup and insserv calls for postinstall
# options:
# -n (use first argument as name for fillup template filenames
# instead of package name)
# -f (skip fillup parts)
# -i (skip insserv parts)
# -s (specify START_ variable names, otherwise tr a-z A-Z is used)
# -y (default start-variable value to yes)
# Used only if X-UnitedLinux-Default-Enabled is not specified
# in the init script
# -p (ignored for backwards compatibility)
# -Y (force_yes: always activate, discard setting before update)
# arguments:
# [if "-n" first argument as package name]
# Pairs of:
# main script name
# and
# name of (old) START variable (unless -s is given)
#
# template for variables into etc/sysconfig/package:
# var/adm/fillup-templates/sysconfig.package
# template for variables into etc/rc.config:
# var/adm/fillup-templates/rc.config.package
%fillup_and_insserv(finpsyY) \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
%{-Y:FORCE_YES=1}%{!-Y:FORCE_YES=0} \
REMOVED_START=no \
set -- %{?*} \
%{-n:PNAME=$1 ; shift }%{!-n:PNAME=%{name}} \
INSSRV_ARRAY="" \
while [ ${#*} -gt 0 ] ; do \
SCRIPTNAME=$1 \
shift \
%{-s:STARTVAR=$1 ; shift} \
%{!-s:STARTVAR=START_`echo $SCRIPTNAME | tr a-z.- A-Z__`} \
SV_B='^### BEGIN INIT INFO' \
SV_E='^### END INIT INFO' \
SV_KW=X-UnitedLinux-Default-Enabled \
SV_VAL=`sed -n -e "/$SV_B/,/$SV_E/{/^# $SV_KW:[[:space:]]*\\([^[:space:]]*\\).*/s//\\1/p;}" < etc/init.d/$SCRIPTNAME` \
test -n "$SV_VAL" || SV_VAL=%{-y:"yes"}%{!-y:"no"} \
eval $STARTVAR=$SV_VAL \
test -n "$STARTVAR" -a -n "$SCRIPTNAME" || { \
echo "STARTVARIABLE or SCRIPTNAME unknown" \
exit 1 \
} \
INSSRV_ARRAY="$INSSRV_ARRAY $SCRIPTNAME $STARTVAR" \
%{!-f:%{!-i:grep -q "$STARTVAR=" var/adm/fillup-templates/rc.config.$PNAME.del 2>/dev/null || \
echo -e "#\\n# Start service $SCRIPTNAME\\n#\\n$STARTVAR=\\"${!STARTVAR}\\"\\n\\n" >> var/adm/fillup-templates/rc.config.$PNAME.del } } \
done \
%{!-f: %{do_real_fillup}} \
%{!-i: %{add_start_if_needed $INSSRV_ARRAY } }
# do_real_fillup: internal macro
# this part really calls fillup for the appropriate files
#
%do_real_fillup() \
TEMPLATE_DIR=var/adm/fillup-templates \
SYSC_TEMPLATE=$TEMPLATE_DIR/sysconfig.$PNAME \
RC_TEMPLATE=$TEMPLATE_DIR/rc.config.$PNAME \
SD_NAME="" \
if [ -x bin/fillup ] ; then \
%{sysc_fillup} \
# remove the START_ variables from the base fillup template \
if [ -f $RC_TEMPLATE.del -a -f $RC_TEMPLATE ] ; then \
bin/fillup -q -r -i $RC_TEMPLATE $RC_TEMPLATE.del /dev/null \
mv $RC_TEMPLATE.new $RC_TEMPLATE \
fi \
if [ -f etc/rc.config ] ; then \
%{rc_fillup} \
# remove the deprecated START_ variables from rc.config \
if [ -f $TEMPLATE_DIR/rc.config.$PNAME.del ] ; then \
rm -f etc/rc.config.xtract \
bin/fillup -q -r -i etc/rc.config $RC_TEMPLATE.del etc/rc.config.xtract \
if [ -f etc/rc.config.xtract ] ; then \
. etc/rc.config.xtract \
fi \
rm -f etc/rc.config.xtract $RC_TEMPLATE.del \
if [ -f etc/rc.config.new ] ; then \
cmp -s etc/rc.config.new etc/rc.config || REMOVED_START=yes \
mv etc/rc.config.new etc/rc.config \
fi \
fi \
fi \
else \
echo "ERROR: fillup not found. This should not happen. Please compare" \
echo "etc/rc.config and $TEMPLATE_DIR/rc.config.$PNAME and" \
echo "update by hand." \
fi
# add_start_if_needed: internally used by fillup_and_insserv
%add_start_if_needed() \
set -- %{?*} \
while [ ${#*} -gt 0 ] ; do \
SCRIPTNAME=$1 \
STARTVAR=$2 \
shift 2 \
test -n "$STARTVAR" -a -n "$SCRIPTNAME" || { \
echo "STARTVAR or SCRIPTNAME unknown" \
exit 1 \
} \
if test "$FIRST_ARG" = "1" -o "$REMOVED_START" = "yes" -o "$FORCE_YES" = "1" ; then \
if test -n "$YAST_IS_RUNNING" ; then \
INSSERV_FORCE="-f" \
else \
INSSERV_FORCE="" \
fi \
if test "${!STARTVAR}" = "yes" -o "$FORCE_YES" = "1" ; then \
sbin/insserv $INSSERV_FORCE etc/init.d/$SCRIPTNAME \
else \
sbin/insserv $INSSERV_FORCE -r etc/init.d/$SCRIPTNAME \
fi \
fi \
done
# macro: insserv_cleanup
# only here to be able to define this to nil
# for versions prior to 7.1
%insserv_cleanup() \
sbin/insserv etc/init.d
# macro: fillup_only
# do the fillup for sysconfig files and if needed extraction
# of older variables from rc.config and rc.config.d
# template naming convention:
# .../fillup-templates/sysconfig.$NAME1[-$NAME2]
# NAME1: the name of the sysconfig-file
# NAME2: if needed (if more packages fill the
# same sysconfig file) the package name
# options:
# -n set sysconfig name manually
# -a use package name as $NAME2
# -s use second arg as package-name
# -d use a subdirectory of sysconfig
# (last arg as directory name)
%fillup_only(dans) \
%{-n:PNAME=%{1}}%{!-n:PNAME=%{name}} \
%{-s:SUBPNAME=-%{2}}%{!-s:SUBPNAME=%{-a:-%{name}}} \
TEMPLATE_DIR=var/adm/fillup-templates \
SYSC_TEMPLATE=$TEMPLATE_DIR/sysconfig.$PNAME$SUBPNAME \
RC_TEMPLATE=$TEMPLATE_DIR/rc.config.$PNAME \
SD_NAME="" \
%{-d:%{-s:SD_NAME=%{3}/}%{!-s:SD_NAME=%{2}/}} \
if [ -x bin/fillup ] ; then \
%{sysc_fillup} \
%{rc_fillup} \
else \
echo "ERROR: fillup not found. This should not happen. Please compare" \
echo "etc/rc.config and $RC_TEMPLATE and" \
echo "update by hand." \
fi
# internal only: rc_fillup
%rc_fillup() \
# maybe the fillup template for rc.config is old, make sure we do not readd stuff here \
if [ -f $SYSC_TEMPLATE -a -f $RC_TEMPLATE ] ; then \
bin/fillup -q -r -i $RC_TEMPLATE $SYSC_TEMPLATE /dev/null \
mv $RC_TEMPLATE.new $RC_TEMPLATE \
fi \
# do the normal fillup for the rc.config variables \
if [ -f $RC_TEMPLATE ] ; then \
bin/fillup -q -d = etc/rc.config $RC_TEMPLATE \
fi
# internal only: sysc_fillup
%sysc_fillup() \
if [ -f $SYSC_TEMPLATE ] ; then \
echo "Updating etc/sysconfig/$SD_NAME$PNAME..." \
if [ ! -d etc/sysconfig/$SD_NAME ] ; then \
mkdir -p etc/sysconfig/$SD_NAME \
fi \
if [ -f etc/rc.config.d/$PNAME.rc.config ] ; then \
if [ -f etc/sysconfig/$SD_NAME$PNAME ] ; then \
bin/fillup -q etc/sysconfig/$SD_NAME$PNAME etc/rc.config.d/$PNAME.rc.config \
rm -f etc/rc.config.d/$PNAME.rc.config \
else \
mv etc/rc.config.d/$PNAME.rc.config etc/sysconfig/$SD_NAME$PNAME \
fi \
fi \
if [ ! -f etc/rc.config ] ; then \
test -f etc/sysconfig/$SD_NAME$PNAME || touch etc/sysconfig/$SD_NAME$PNAME \
bin/fillup -q etc/sysconfig/$SD_NAME$PNAME $SYSC_TEMPLATE \
else \
if [ ! -f etc/sysconfig/$SD_NAME$PNAME ] ; then \
bin/fillup -q -r -i etc/rc.config $SYSC_TEMPLATE etc/sysconfig/$SD_NAME$PNAME \
else \
bin/fillup -q -r -i etc/rc.config $SYSC_TEMPLATE etc/sysconfig/$SD_NAME$PNAME.tmp \
bin/fillup -q etc/sysconfig/$SD_NAME$PNAME etc/sysconfig/$SD_NAME$PNAME.tmp \
rm -f etc/sysconfig/$SD_NAME$PNAME.tmp \
fi \
if [ -f etc/rc.config.new ] ; then \
mv etc/rc.config.new etc/rc.config \
fi \
fi\
fi
# macro: rename_sysconfig_variable
# as the name says, rename a variable in rc.config
# or with -f in the given file
%rename_sysconfig_variable(f:) \
%{!-f:FILE=etc/rc.config}%{-f:FILE=%{-f*}} \
if [ -f $FILE ] ; then \
sed -e "s/^%{1}=/%{2}=/" $FILE > $FILE.new \
mv $FILE.new $FILE \
fi
# macro: save_rc_config_d_was_in_filelist
# only used for packages that erroneously had the rc.config.d file
# in their filelist
%save_rc_config_d_was_in_filelist(n) \
%{-n:PNAME=%{?*}}%{!-n:PNAME=%{name}} \
mkdir -p etc/sysconfig \
if [ -f etc/rc.config.d/$PNAME.rc.config -a ! -f etc/sysconfig/$PNAME ] ; then \
cp etc/rc.config.d/$PNAME.rc.config etc/sysconfig/$PNAME \
fi
# macro: remove_and_set
# remove variables from rc.config and sysconfig.$NAME
# (both if existant) and set them in the environment
# for further handling in postinstall
# options: -n set package name
# -y default to yes if not found (otherwise no)
%remove_and_set(n:y) \
%{-n:PNAME=%{-n*}}%{!-n:PNAME=%{name}} \
DEF_VAL=%{-y:"yes"}%{!-y:"no"} \
DEL_TEMPL=var/adm/fillup-templates/$PNAME.del \
rm -f $DEL_TEMPL \
for var in %{?*} ; do \
echo -e "#\\n$var=$DEF_VAL\\n" >> $DEL_TEMPL \
done \
if [ -f etc/rc.config ] ; then \
bin/fillup -q -t -r -i -d "=" etc/rc.config $DEL_TEMPL etc/rc.config.xtract \
test -f etc/rc.config.new && mv etc/rc.config.new etc/rc.config \
fi \
if [ -f etc/sysconfig/$PNAME ] ; then \
bin/fillup -q -t -r -i -d "=" etc/sysconfig/$PNAME $DEL_TEMPL etc/rc.config.xtract.too \
test -f etc/sysconfig/$PNAME.new && mv etc/sysconfig/$PNAME.new etc/sysconfig/$PNAME \
fi \
for i in $DEL_TEMPL etc/rc.config.xtract etc/rc.config.xtract.too ; do \
if [ -f $i ] ; then \
. $i \
rm -f $i \
fi \
done
%insserv_force_if_yast() \
if test -n "$YAST_IS_RUNNING" ; then \
INSSERV_FORCE="-f" \
else \
INSSERV_FORCE="" \
fi \
sbin/insserv $INSSERV_FORCE %{?*}
%run_ldconfig /sbin/ldconfig
%install_info(:-:) \
ALL_ARGS=(%{**}) \
NUM_ARGS=${#ALL_ARGS[@]} \
if test -x sbin/install-info ; then \
if test -e "${ALL_ARGS[$((NUM_ARGS-1))]}" ; then \
sbin/install-info "${ALL_ARGS[@]}" \
fi \
fi ;
%install_info_delete(:-:) \
ALL_ARGS=(%{**}) \
NUM_ARGS=${#ALL_ARGS[@]} \
if test -x sbin/install-info ; then \
if ! test -e "${ALL_ARGS[$((NUM_ARGS-1))]}" ; then \
sbin/install-info --quiet --delete "${ALL_ARGS[@]}" \
fi ; \
fi ;
%suse_version 901
%sles_version 0
%ul_version 0
%do_profiling 1
%cflags_profile_generate -fprofile-generate
%cflags_profile_feedback -fprofile-use
# find-supplements.ksyms parses this macro directly out of the spec file:
%supplements_kernel_module() \
%{expand:%(if ! rpm -q kernel-syms > /dev/null; then echo "%fail Please add the kernel-syms package to BuildRequires"; fi)}
# Template for lang sub-package.
%lang_package \
%package lang\
Summary: Languages for package %{name}\
Group: System/Localization\
Requires: %{name} = %{version}\
%description lang\
Provides translations to the package %{name}.