]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add the --disable-ownership option to help packagers out.
authorSadie Powell <sadie@witchery.services>
Wed, 9 Jun 2021 03:20:09 +0000 (04:20 +0100)
committerSadie Powell <sadie@witchery.services>
Wed, 9 Jun 2021 03:20:09 +0000 (04:20 +0100)
configure
make/configure.pm
make/template/main.mk

index 5ccd47d9aadcb8abc512b4489c9899996eb202f6..a3631fa34ff358f593bb185150979c965b1be939 100755 (executable)
--- a/configure
+++ b/configure
@@ -52,6 +52,7 @@ my ($opt_binary_dir,
     $opt_development,
     $opt_disable_auto_extras,
     $opt_disable_interactive,
+    $opt_disable_ownership,
     $opt_distribution_label,
     $opt_example_dir,
     $opt_gid,
@@ -86,6 +87,7 @@ exit 1 unless GetOptions(
        'development'          => \$opt_development,
        'disable-auto-extras'  => \$opt_disable_auto_extras,
        'disable-interactive'  => \$opt_disable_interactive,
+       'disable-ownership'    => \$opt_disable_ownership,
        'distribution-label=s' => \$opt_distribution_label,
        'example-dir=s'        => \$opt_example_dir,
        'gid=s'                => \$opt_gid,
@@ -124,6 +126,7 @@ our $interactive = !(
        defined $opt_development ||
        defined $opt_disable_auto_extras ||
        defined $opt_disable_interactive ||
+       defined $opt_disable_ownership ||
        defined $opt_distribution_label ||
        defined $opt_example_dir ||
        defined $opt_gid ||
@@ -227,7 +230,10 @@ if (defined $opt_portable) {
 
 # Parse --gid=123 or --gid=foo and extract the group id.
 my @group;
-if (defined $opt_gid) {
+if (defined $opt_disable_ownership) {
+       @group = getgrgid(getgid());
+       print_error 'you can not use --disable-ownership and --gid at the same time!' if defined $opt_gid;
+} elsif (defined $opt_gid) {
        @group = $opt_gid =~ /^\d+$/ ? getgrgid($opt_gid) : getgrnam($opt_gid);
        print_error "there is no '$opt_gid' group on this system!" unless @group;
 } else {
@@ -243,7 +249,7 @@ unprivileged user/group to build and run as or pass the '--gid [id|name]' flag
 to specify an unprivileged group to run as.
 EOW
                if (!prompt_bool $interactive, "Are you sure you want to build as the $group[0] group?", 0) {
-                       # PACKAGERS: You do not need to delete this check. Use `--gid $(id -g)` or `--gid 0` instead.
+                       # PACKAGERS: You do not need to delete this check. Use `--disable-ownership` instead.
                        say STDERR "If you are sure you want to build as the $group[0] group pass the --gid $group[2] flag." unless $interactive;
                        exit 1;
                }
@@ -254,7 +260,10 @@ $config{GID}   = $group[2];
 
 # Parse --uid=123 or --uid=foo and extract the user id.
 my @user;
-if (defined $opt_uid) {
+if (defined $opt_disable_ownership) {
+       @user = getpwuid(getuid());
+       print_error 'you can not use --disable-ownership and --uid at the same time!' if defined $opt_uid;
+} elsif (defined $opt_uid) {
        @user = $opt_uid =~ /^\d+$/ ? getpwuid($opt_uid) : getpwnam($opt_uid);
        print_error "there is no '$opt_uid' user on this system!" unless @user;
 } else {
@@ -270,7 +279,7 @@ unprivileged user/group to build and run as or pass the '--uid [id|name]' flag
 to specify an unprivileged user to run as.
 EOW
                if (!prompt_bool $interactive, "Are you sure you want to build as the $user[0] user?", 0) {
-                       # PACKAGERS: You do not need to delete this check. Use `--uid $(id -u)` or `--uid 0` instead.
+                       # PACKAGERS: You do not need to delete this check. Use `--disable-ownership` instead.
                        say STDERR "If you are sure you want to build as the $user[0] user pass the --uid $user[2] flag." unless $interactive;
                        exit 1;
                }
@@ -448,6 +457,7 @@ EOM
 
 # Cache the distribution label so that its not lost when --update is run.
 $config{DISTRIBUTION} = $opt_distribution_label if $opt_distribution_label;
+$config{DISABLE_OWNERSHIP} = $opt_disable_ownership // 0;
 
 write_configure_cache %config;
 parse_templates \%config, \%compiler, \%version;
index a49ad13186f864995e2c5c36e649530b929df3cc..ce3988c9bc71482561ebdf565484c284b0119266 100644 (file)
@@ -160,6 +160,7 @@ non-interactive configuration is started and any omitted values are defaulted.
   <|BOLD --disable-auto-extras|>         Disables automatically enabling extra modules
                                 for which the dependencies are available.
   <|BOLD --disable-interactive|>         Disables the interactive configuration wizard.
+  <|BOLD --disable-ownership|>           Disables setting file ownership on install.
   <|BOLD --distribution-label <TEXT>|>   Sets a distribution specific version label in
                                 the build configuration.
   <|BOLD --gid <ID|NAME>|>               Sets the group to run InspIRCd as.
index 319d39c08f24fb92d9ae7a0f073d61f6af4dd8c6..3cc0f1200ad4e79e7a1a365c67015727dabedf85 100644 (file)
@@ -67,6 +67,13 @@ INSTMODE_BIN ?= 0755
 INSTMODE_TXT ?= 0644
 INSTMODE_PRV ?= 0640
 
+DISABLE_OWNERSHIP=@DISABLE_OWNERSHIP@
+ifeq ($(DISABLE_OWNERSHIP), 1)
+  INSTFLAGS =
+else
+  INSTFLAGS = -g @GID@ -o @UID@
+endif
+
 ifneq ($(COMPILER), Intel)
   CORECXXFLAGS += -Woverloaded-virtual -Wshadow
 ifneq ($(SYSTEM), openbsd)
@@ -212,41 +219,41 @@ finishmessage: target
        @echo "*************************************"
 
 install: target
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(BINPATH)
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(CONPATH)
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(DATPATH)
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/codepages
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/providers
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/services
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/sql
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(LOGPATH)
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(MANPATH)
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(MODPATH)
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(RUNPATH)
-       @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(SCRPATH)
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH)
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) "$(BUILDPATH)/modules/"*.so $(MODPATH)
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(SCRPATH) 2>/dev/null
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/apparmor $(SCRPATH) 2>/dev/null
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/logrotate $(SCRPATH) 2>/dev/null
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(BINPATH)
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(CONPATH)
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(DATPATH)
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(EXAPATH)/codepages
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(EXAPATH)/providers
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(EXAPATH)/services
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(EXAPATH)/sql
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(LOGPATH)
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(MANPATH)
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(MODPATH)
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(RUNPATH)
+       @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(SCRPATH)
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH)
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) "$(BUILDPATH)/modules/"*.so $(MODPATH)
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(SCRPATH) 2>/dev/null
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/apparmor $(SCRPATH) 2>/dev/null
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/logrotate $(SCRPATH) 2>/dev/null
 ifeq ($(SYSTEM), darwin)
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(SCRPATH) 2>/dev/null
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(SCRPATH) 2>/dev/null
 endif
 ifeq ($(SYSTEM), linux)
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.service $(SCRPATH) 2>/dev/null
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.service $(SCRPATH) 2>/dev/null
 endif
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-testssl.1 $(MANPATH) 2>/dev/null
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) tools/testssl $(BINPATH)/inspircd-testssl 2>/dev/null
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/*.example $(EXAPATH)
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/codepages/*.example $(EXAPATH)/codepages
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/providers/*.example $(EXAPATH)/providers
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/services/*.example $(EXAPATH)/services
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/sql/*.sql $(EXAPATH)/sql
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/help.txt $(CONPATH)
-       -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_PRV) @CONFIGURE_DIRECTORY@/*.pem $(CONPATH) 2>/dev/null
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-testssl.1 $(MANPATH) 2>/dev/null
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) tools/testssl $(BINPATH)/inspircd-testssl 2>/dev/null
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) docs/conf/*.example $(EXAPATH)
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) docs/conf/codepages/*.example $(EXAPATH)/codepages
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) docs/conf/providers/*.example $(EXAPATH)/providers
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) docs/conf/services/*.example $(EXAPATH)/services
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) docs/sql/*.sql $(EXAPATH)/sql
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/help.txt $(CONPATH)
+       -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_PRV) @CONFIGURE_DIRECTORY@/*.pem $(CONPATH) 2>/dev/null
        @echo ""
        @echo "*************************************"
        @echo "*        INSTALL COMPLETE!          *"