Skip to content

Instantly share code, notes, and snippets.

@brandt
Last active December 19, 2015 01:08
Show Gist options
  • Save brandt/5873345 to your computer and use it in GitHub Desktop.
Save brandt/5873345 to your computer and use it in GitHub Desktop.
Use portable arguments so that `rpmrebuild` can build on systems that don't have GNU Coreutils installed.
diff --git c/src/Makefile.include w/src/Makefile.include
index b6384ff..b75516c 100644
--- c/src/Makefile.include
+++ w/src/Makefile.include
@@ -1,11 +1,11 @@
-INSTALL_RUN := install --mode=555
-INSTALL_RO := install --mode=444
-INSTALL_MAN := install --mode=644
-INSTALL_LOCALE := install --mode=644
-LN := ln --symbolic --force --no-dereference
+INSTALL_RUN := install -m 555
+INSTALL_RO := install -m 444
+INSTALL_MAN := install -m 644
+INSTALL_LOCALE := install -m 644
+LN := ln -sfn
MKDIR := mkdir -p
-RM := rm --force
-RMDIR := rm --force --recursive
+RM := rm -f
+RMDIR := rm -rf
TARGET_DIR := $(DESTDIR)/usr/bin
TARGET_LIB := $(DESTDIR)/usr/lib/rpmrebuild
@@ -18,7 +18,7 @@ LANGS := en fr_FR fr_FR.UTF-8
# add current version in man pages
define MakeManPage
@$(RM) $@
- @read VERSION < $(TOP_DIR)/Version && sed -e "s/@VERSION@/$$VERSION/g" < $< > $@ || { $(RM) $@; exit 1; }
+ @read VERSION < $(TOP_DIR)/Version && LC_ALL=C sed -e "s/@VERSION@/$$VERSION/g" < $< > $@ || { $(RM) $@; exit 1; }
endef
# install man pages
diff --git c/src/rpmrebuild_parser.src w/src/rpmrebuild_parser.src
index 5b25842..3407ea1 100644
--- c/src/rpmrebuild_parser.src
+++ w/src/rpmrebuild_parser.src
@@ -1091,7 +1091,7 @@ function ProcessLongOptions
version)
set -e
- source $MY_LIB_DIR/VERSION
+ cat $MY_LIB_DIR/VERSION
set +e
echo "$VERSION"
NEED_EXIT=0
diff --git c/src/Makefile w/src/Makefile
index 86759ab..f70d241 100644
--- c/src/Makefile
+++ w/src/Makefile
@@ -18,7 +18,7 @@ RPM_DEFINES := \
--define '_srcrpmdir $(RPM_SRPMS_DIR)' \
--define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
-VERSION=$(shell cat Version)
+VERSION=$(shell cat Version.master)
TAR_FILE := $(RPM_SOURCE_DIR)/rpmrebuild-$(VERSION).tar.gz
SCRIPTS := rpmrebuild
@@ -64,23 +64,22 @@ SOURCES := \
$(SCRIPTS) \
$(LIB_SCRIPTS) \
$(INCLUDE_SCRIPTS) \
- $(SPEC_SCRIPTS) \
- $(MANPAGES_SRC) \
- $(LOCALES) \
+ $(MANPAGES_SRC) \
+ $(LOCALES) \
$(DOC_FILES) \
Makefile \
Makefile.include \
Changelog \
rpmrebuild.spc \
rpmrebuild.files \
- Version \
+ Version.master \
Release \
TAR_NAMES_PLUGINS := $(shell $(MAKE) --quiet -C plugins tar_names)
TAR_NAMES := $(SOURCES) rpmrebuild.spec $(TAR_NAMES_PLUGINS)
define Spec
- Version="`cat Version`" && \
+ Version="`cat Version.master`" && \
Release="`cat Release`" && \
{ \
echo "Version: $$Version" && \
@@ -95,14 +94,14 @@ endef
all: rpmrebuild.spec VERSION $(MANPAGES)
$(MAKE) -C plugins $@
-rpmrebuild.spec: rpmrebuild.spc Version Release Changelog
+rpmrebuild.spec: rpmrebuild.spc Version.master Release Changelog
$(RM) $@
$(Spec) > $@ || { $(RM) $@; exit 1; }
-$(MANPAGES): %: %.in $(TOP_DIR)/Version
+$(MANPAGES): %: %.in $(TOP_DIR)/Version.master
$(MakeManPage)
-VERSION: Version
+VERSION: Version.master
$(RM) $@
read VERSION < $< && echo "VERSION='$$VERSION'" > $@ || { $(RM) $@; exit 1; }
@@ -129,7 +128,7 @@ rpmbuild: tar
rpm --resign rpmrebuild*.rpm
clean:
- $(RMDIR) $(ROOT) $(RPM_BUILD_DIR)
+ $(RMDIR) $(RPM_BUILD_DIR)
$(RM) VERSION rpmrebuild.spec *.rpm rpmrebuild.tar.gz rpmrebuild.tar.gz.sig
$(RM) $(MANPAGES)
$(MAKE) -C plugins $@
diff --git c/src/Version w/src/Version.master
similarity index 100%
rename from src/Version
rename to src/Version.master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment