Skip to content

Commit

Permalink
Updated Makefile user creation and cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
Krowemoh committed Sep 28, 2023
1 parent b15230e commit f37de22
Showing 1 changed file with 8 additions and 115 deletions.
123 changes: 8 additions & 115 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,79 +1,8 @@
# ScarletDME Makefile
#
# You are allowed to modify this file, so long as the derived file can
# be distributed under the same license as this file. You are allowed to copy
# and distribute verbatim copies of this document so long as you follow
# the licensing agreements contained within this document.
#
# This program 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, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Note - for some reason this makefile had the entire text of the GPLv3 license
# attached at the end. I've removed it as part of doing updates to this
# Makefile. The GPL v3 License can be found here:
# https://www.gnu.org/licenses/gpl-3.0.txt
#
# Changelog
# ---------
# 05Nov22 awy Fix systemd install for unified /usr
# 13Mar22 awy Update install target to create master account if required,
# and update NEWVOC
# $COMO is created on first use so remove it from master account.
# 16Jan22 awy Adding qm32 target to build 32-bit if required. BUILD64 now obsolete.
# 15Jan22 awy Adding code to create qmsys and qmuser if they don't exist.
# Adding scarletdme.service file to install target
#
# 12Jan22 gwb Fixed a typo that resulted in the $IPC directory being a mess and
# not having the dynamic files it needed.
# Cleaned up the datafiles installation process to make sure the things
# that needed to get copied were.
# Ensured correct permissions were being correctly set for the all the
# files within the subdirectories of the installation location.
# Incorrect permissions were causing issues with creating an account on
# the very first login to the system.
#
# 09Jan22 gwb Added the ability to more easily select a 32 vs 64 bit build target.
# Setting BUILD64 := Y will result in a 64 bit build.
# There was a bug in the command that creates the symbolic link to
# the qm binary. "@ln" was invalid, it should be "ln".
#
# 09Jan22 gwb Added $COMO directory to the list of things to be copied on install.
# Added the $FORMS directory to the list of things to be copied.
# Fixed dumb typo in a Makefile comment.
# 20Feb20 gwb Added -m32 $(ARCH) flag to ensure we're compiling with 32 bit
# libraries.
# I also inverted the timeline of these comments in order to make
# the format similar to the change logs in the source code files.
# 22Jun12 gwb Added individual source files to trigger recompile if revstamp.h
# has been changed.
# 20Jun12 gwb Added -Wl,--no-as-needed flags in order to enable proper linking
# under Ubuntu 12.04 LTS
# Added install target - copies binaries to $(INSTROOT)/bin
# Added datafiles target - copies all the system data files to
# $(INSTROOT) - note that this will overwrite an existing
# installation!!!
# 29Aug09 dat Added optional qmdev target wraps qm target, but stops and starts
# server
# 31Nov08 dat Amended to function with 2-6-6 -Diccon Tesson
# =====================================================================================
# Maintainer List
# ---------------
# dat - Diccon Tesson
# gwb - Gene Buckle (geneb@deltasoft.com)
# awy - Anthony (Wol) Youngman

# default target builds 64-bit, build qm32 target for a 32-bit build

# MAIN := ./
GROUPADD := $(shell command -v adduser 2> /dev/null || command -v groupadd 2> /dev/null)
USERADD := $(shell command -v addgroup 2> /dev/null || command -v useradd 2> /dev/null)

MAIN := $(shell pwd)/
GPLSRC := $(MAIN)gplsrc/
GPLDOTSRC := $(MAIN)gpl.src
Expand Down Expand Up @@ -105,11 +34,6 @@ else
SONAME_OPT := -soname
endif

# The -Wno-format-nonliteral flag prevents the compiler warning us about being unable to check the format
# strings the system uses for error message text.
# C_FLAGS := -Wall -Wformat=2 -Wno-format-nonliteral -DLINUX -D_FILE_OFFSET_BITS=64 -I$(GPLSRC) -DGPL -g $(ARCH)


RM := rm

QMHDRS := $(wildcard *.h)
Expand Down Expand Up @@ -217,15 +141,15 @@ sysseg.o: sysseg.c qm.h locks.h config.h revstamp.h
@echo Compiling $@, $(BITSIZE) bit target.
@$(COMP) $(C_FLAGS) -c $< -o $(GPLOBJ)$@

.PHONY: clean distclean install datafiles docs systemd qmdev qmstop
.PHONY: clean install qmdev qmstop

install:
ifeq ($(QMUSERS),)
@echo Creating qm system user and group
@groupadd --system qmusers
@($(GROUPADD)) --system qmusers
@usermod -a -G qmusers root
ifeq ($(QMSYS),)
@useradd --system qmsys --gid qmusers
@($(USERADD)) --system qmsys --gid qmusers
endif
endif

Expand All @@ -244,13 +168,13 @@ ifeq ($(wildcard $(INSTROOT)/.),)
else
# copy FILEs that need updating
# copy the contents of NEWVOC so the account will upgrade
@rm $(INSTROOT)/NEWVOC/*
@rm -f $(INSTROOT)/NEWVOC/*
@cp qmsys/NEWVOC/* $(INSTROOT)/NEWVOC
@chown qmsys:qmusers $(INSTROOT)/NEWVOC/*
@chmod 664 $(INSTROOT)/NEWVOC/*

# copy the contents of MESSAGES so the account will upgrade
@rm $(INSTROOT)/MESSAGES/*
@rm -f $(INSTROOT)/MESSAGES/*
@cp qmsys/MESSAGES/* $(INSTROOT)/MESSAGES
@chown qmsys:qmusers $(INSTROOT)/MESSAGES/*
@chmod 664 $(INSTROOT)/MESSAGES/*
Expand Down Expand Up @@ -305,40 +229,9 @@ endif
endif
endif

systemd:
@systemctl enable scarletdme.service
@systemctl enable scarletdmeclient.socket
@systemctl enable scarletdmeserver.socket

datafiles:
# you should never need this target ...
ifeq ($(wildcard $(INSTROOT)/.),)
cp -R qmsys $(INSTROOT)
else
cp -R qmsys/* $(INSTROOT)
endif
chown -R qmsys:qmusers $(INSTROOT)
chmod -R 664 $(INSTROOT)
find $(INSTROOT) -type d -print0 | xargs -0 chmod 775

@echo Data file copy completed!
clean:
@$(RM) $(GPLOBJ)*.o
# @$(RM) $(GPLOBJ)*.so
# no .so files are currently dropped into GPLOBJ...

distclean: clean
@$(RM) $(GPLBIN)*
@$(RM) $(GPLSRC)terminfo

docs:
$(MAKE) -C docs html

# Additional stop and start for developers, wraps qm build
qmdev: qmstop qm
@echo Attempting to start server
qm -start
qmstop:
@echo Attempting to stop server
qm -stop

0 comments on commit f37de22

Please sign in to comment.