WIP: prepare to split scripts

This commit is contained in:
GenZmeY 2020-07-29 19:16:01 +03:00
parent e351f31f23
commit 430258b6df
7 changed files with 80 additions and 13 deletions

79
Makefile Normal file
View File

@ -0,0 +1,79 @@
# kf2-srv is a command line tool for managing a set of Killing Floor 2 servers.
# Copyright (C) 2019, 2020 GenZmeY
# mailto: genzmey@gmail.com
#
# This file is part of kf2-srv.
#
# kf2-srv is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
NAME := "kf2-srv"
RPMBUILDDIR := "$$HOME/rpmbuild"
ACTIVEDIR := $(shell readlink -e "$$HOME/rpmbuild")
WORKDIR := $(shell readlink -e ".")
BUILDDIR := $(WORKDIR)/BUILD
BUILDROOTDIR := $(WORKDIR)/BUILDROOT
RPMSDIR := $(WORKDIR)/RPMS
SOURCESDIR := $(WORKDIR)/SOURCES
SPECSDIR := $(WORKDIR)/SPECS
SRPMSDIR := $(WORKDIR)/SRPMS
SCRIPTSDIR := $(SOURCESDIR)/scripts
SPEC := $(SPECSDIR)/$(NAME).spec
SOURCETARBALL := $(SOURCESDIR)$(NAME)-$(VERSION).tar.gz
VERSION := $(shell grep -Fi 'Version:' $(SPEC) | awk '{ print $$2 }')
.PHONY: all prep rpm srpm activate check-activate clean-tmp clean-pkg clean
all: check-activate prep
rpmbuild -ba $(SPEC)
$(MAKE) clean-tmp
prep: clean-tmp
tar czf $(SOURCETARBALL) -C $(SCRIPTSDIR) .
rpm: check-activate prep
rpmbuild -bb $(SPEC)
$(MAKE) clean-tmp
srpm: check-activate prep
rpmbuild -bs $(SPEC)
$(MAKE) clean-tmp
activate:
ifeq ($(shell test -d $(RPMBUILDDIR); echo $$?), 0)
mv -f $(RPMBUILDDIR) $(RPMBUILDDIR).old
else
rm -f $(RPMBUILDDIR)
endif
ln -s $(WORKDIR) $(RPMBUILDDIR)
check-activate:
ifneq ($(ACTIVEDIR), $(WORKDIR))
$(error project is not active)
endif
clean-tmp:
rm -rf $(BUILDDIR)
rm -rf $(BUILDROOTDIR)
rm -rf $(SOURCETARBALL)
clean-pkg:
rm -rf $(RPMSDIR)
rm -rf $(SRPMSDIR)
clean: clean-tmp clean-pkg

View File

@ -8,6 +8,7 @@ Group: Amusements/Games
License: GNU GPLv3 License: GNU GPLv3
BuildArch: noarch BuildArch: noarch
Source0: %{name}-%{version}.tar.gz
Source1: %{name} Source1: %{name}
Source2: %{name}-beta Source2: %{name}-beta
Source3: %{name}.xml Source3: %{name}.xml

View File

@ -1,13 +0,0 @@
#!/bin/bash
ScriptFullname=$(readlink -e "$0")
SrpmProjectDir=$(dirname "$ScriptFullname")
RpmBuild="$HOME/rpmbuild"
if [[ -d "$RpmBuild" ]]; then
rm -rf "$RpmBuild"
else
rm -f "$RpmBuild"
fi
ln -s "$SrpmProjectDir" "$RpmBuild"