def MACRO_EXTRACT_TARBALL for source in %{sources}; do %{MACRO_EXTRACT} %{DIR_DL}/${source} || exit 1 done unset source [ -d "%{DIR_APP}" ] && cd %{DIR_APP} end def MACRO_INSTALL_FILES %{MACRO_INSTALL_DEFAULT_FILES} %{MACRO_INSTALL_SYSTEMD_FILES} %{MACRO_INSTALL_SYSTEMD_SYSUSERS} %{MACRO_INSTALL_SYSTEMD_TMPFILES} %{MACRO_INSTALL_PAM_FILES} end # XXX to be removed soon def MACRO_INSTALL_DEFAULT_FILES for file in %{DIR_SOURCE}/default/*; do [ -e "${file}" ] || continue mkdir -p %{BUILDROOT}/etc/default cp -vf ${file} %{BUILDROOT}/etc/default/$(basename ${file}) done unset file end def MACRO_INSTALL_PAM_FILES for file in %{DIR_SOURCE}/{*.pam,pam.d/*}; do [ -e "${file}" ] || continue mkdir -p %{BUILDROOT}/etc/pam.d cp -vf ${file} %{BUILDROOT}/etc/pam.d/$(basename ${file%*.pam}) done unset file end def MACRO_PYTHON_COMPILE __python_compile() { if [ -x "%{python3}" ]; then %{python3} -m compileall -f \ %{BUILDROOT}%{python3_sitearch} %{BUILDROOT}%{python3_sitelib} $@ fi } # Compile any Python modules __python_compile end def MACRO_FIX_AUTOTOOLS for i in $(find %{DIR_SRC} -name config.guess -or -name config.sub); do if [ -e "/usr/share/libtool/build-aux/$(basename ${i})" ]; then cp -vf /usr/share/libtool/build-aux/$(basename ${i}) $(dirname ${i}) fi done end def MACRO_PATCHES __patch() { local paths=() local path local patches=() local patch while [ $# -gt 0 ]; do case "${1}" in --search-path=*) paths+=( "${1#--search-path=}" ) ;; *) patches+=( "${1}" ) ;; esac shift done # Apply all patches given on command line. for patch in ${patches[@]}; do case "${patch}" in /*) ;; *) for path in ${paths[@]}; do if [ -e "${path}/${patch}" ]; then patch="${path}/${patch}" break fi done ;; esac # Check if patch file does exist. if ! [ -e "${patch}" ]; then echo >&2 " ERROR: Patch file does not exist: ${patch}" return 1 fi # Options applied to patch command. options="-N" # Get right -p1 option. case "${patch}" in *.patch[0-9]|*.patch[0-9]R) _patch="${patch}" # Get patch level from file name. while [ ${#_patch} -gt 0 ]; do last_pos=$(( ${#_patch} - 1 )) last_char=${_patch:${last_pos}} _patch=${_patch:0:${last_pos}} case "${last_char}" in [0-9]) options="${options} -p${last_char}" break ;; R) options="${options} -R" ;; esac done ;; *.patch|*.diff) # Default is -p1. options="${options} -p1" ;; *) echo >&2 " WARNING: Ignoring unknown file: ${patch}" continue ;; esac echo " Applying ${patch} (${options})..." patch ${options} -i ${patch} || return $? done return 0 } __patch --search-path=%{DIR_PATCHES} "%{patches}" end # Pre-defined build scripts. build DIR_BUILD = %{DIR_APP}/%{BUILD_DIR} configure = [ -x "%{DIR_APP}/%{CONFIGURE_SCRIPT}" ] && %{DIR_APP}/%{CONFIGURE_SCRIPT} %{configure_options} # GNU Make Stuff __make = make -O # Default "make" command make_build = %{__make} %{PARALLELISMFLAGS} %{make_build_targets} # Default "make install" command make_install = %{__make} DESTDIR=%{BUILDROOT} %{make_install_targets} # These variables are used if you have to add some targets directly to the make command # LEGACY: DO NOT USE ANY MORE make_build_targets = make_install_targets = install def _prepare rm -rf %{BUILDROOT}/* mkdir -p %{DIR_SRC} && cd %{DIR_SRC} %{prepare} # Create the build directory mkdir -pv %{DIR_BUILD} end def prepare # Extract source tarball. %{MACRO_EXTRACT_TARBALL} # Apply all patches. %{MACRO_PATCHES} # Run custom commands. %{prepare_cmds} end def prepare_cmds end def _build [ -d "%{DIR_BUILD}" ] && cd %{DIR_BUILD} %{build} end def build # Run configure %{configure} # Remove any RPATH stuff from locally installed libtool %{MACRO_FIX_LIBTOOL} # Run custom commands %{configure_cmds} # Run build %{make_build} # Run more custom commands. %{build_cmds} end def configure_cmds end def build_cmds end def _test [ -d "%{DIR_BUILD}" ] && cd %{DIR_BUILD} %{test} end def test end def _install [ -d "%{DIR_BUILD}" ] && cd %{DIR_BUILD} # Create BUILDROOT mkdir -pv %{BUILDROOT} %{install} %{MACRO_INSTALL_FILES} %{MACRO_PYTHON_COMPILE} # Cleanup perl modules %{perl_cleanup} %{install_post} end def install # Install %{make_install} %{MACRO_APPLY_SYSTEMD_SYSUSERS} # Run custom commands %{install_cmds} end end