From 395515d1f7a4b037c56230e524746a6b25b65d9d Mon Sep 17 00:00:00 2001 From: Yuxiang Zhu Date: Fri, 4 May 2018 11:39:00 +0800 Subject: [PATCH] Create srpm and rpm targets to the Autotools build The new `srpm` target can be handled by Fedora Copr for automated builds. A `rpm` target is also added for alignment. --- .gitignore | 1 + Makefile.am | 4 ++-- configure.ac | 4 +++- rpm/Makefile.am | 8 ++++++++ rpm/genrpm.sh | 17 +++++++++++++++-- 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 rpm/Makefile.am diff --git a/.gitignore b/.gitignore index 8e260abd..2e289216 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ build/ .deps/ /Makefile src/Makefile +rpm/Makefile libev/Makefile libudns/Makefile libcork/Makefile diff --git a/Makefile.am b/Makefile.am index 12a0b0bd..e154d344 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ if USE_SYSTEM_SHARED_LIB -SUBDIRS = src +SUBDIRS = src rpm else -SUBDIRS = libcork libipset libbloom src +SUBDIRS = libcork libipset libbloom src rpm endif if ENABLE_DOCUMENTATION diff --git a/configure.ac b/configure.ac index 243a1a3f..7b76199f 100755 --- a/configure.ac +++ b/configure.ac @@ -10,6 +10,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_USE_SYSTEM_EXTENSIONS AM_INIT_AUTOMAKE([subdir-objects foreign -Wno-gnu -Werror]) +AM_EXTRA_RECURSIVE_TARGETS([rpm srpm]) m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AM_MAINTAINER_MODE @@ -239,7 +240,8 @@ AC_CHECK_LIB([ev], [ev_loop_destroy], [LIBS="-lev $LIBS"], [AC_MSG_ERROR([Couldn AC_CONFIG_FILES([shadowsocks-libev.pc Makefile doc/Makefile - src/Makefile]) + src/Makefile + rpm/Makefile]) AM_COND_IF([USE_SYSTEM_SHARED_LIB], [AC_DEFINE([USE_SYSTEM_SHARED_LIB], [1], [Define if use system shared lib.])], diff --git a/rpm/Makefile.am b/rpm/Makefile.am new file mode 100644 index 00000000..9aa27e6a --- /dev/null +++ b/rpm/Makefile.am @@ -0,0 +1,8 @@ +clean-local: + -rm -rf BUILD BUILDROOT RPMS SRPMS SPECS/*.spec SOURCES/*.tar SOURCES/*.gz +srpm: + -./genrpm.sh -S +rpm: + -./genrpm.sh + +.PHONY: srpm rpm diff --git a/rpm/genrpm.sh b/rpm/genrpm.sh index 877c66b7..57089047 100755 --- a/rpm/genrpm.sh +++ b/rpm/genrpm.sh @@ -4,6 +4,9 @@ set -e SELF=$(readlink -f -- "$0") HERE=$(dirname -- "$SELF") +RPMBUILD=rpmbuild +RPMBUILD_OPTS= + show_help() { echo -e "`basename $0` [OPTION...]" @@ -11,11 +14,13 @@ show_help() echo -e "Options:" echo -e " -h show this help." echo -e " -s use system shared libraries" + echo -e " -S build SRPMs only" } OPT_USE_SYSTEM_LIB=0 +OPT_SRPMS_ONLY=0 -while getopts "hs" opt +while getopts "hsS" opt do case ${opt} in h) @@ -26,6 +31,9 @@ do s) OPT_USE_SYSTEM_LIB=1 ;; + S) + OPT_SRPMS_ONLY=1 + ;; *) show_help exit 1 @@ -82,6 +90,11 @@ sed -e "s/^\(Version:\).*$/\1 ${TARGET_VERSION}/" \ "${TARGET_SPEC_PATH}".in > "${TARGET_SPEC_PATH}" # build rpms -rpmbuild -ba "$TARGET_SPEC_PATH" \ +if [ "$OPT_SRPMS_ONLY" -ne 0 ]; then + RPMBUILD_OPTS+=' -bs' +else + RPMBUILD_OPTS+=' -ba' +fi +"$RPMBUILD" $RPMBUILD_OPTS "$TARGET_SPEC_PATH" \ --define "%_topdir $HERE" \ --define "%use_system_lib $OPT_USE_SYSTEM_LIB"