diff --git a/INSTALL.md b/INSTALL.md index 86311db8fecc5bbaf97fd48b4a8f762a26f4782c..29c0583dd2d9c551f5c093b712227c28bd376531 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,11 +5,11 @@ Build Instructions - A POSIX-compliant C development environment - GNU make version 3.81 or later -- skalibs version 2.10.0.0 or later: http://skarnet.org/software/skalibs/ -- execline version 2.7.0.0 or later: http://skarnet.org/software/execline/ -- s6 version 2.10.0.0 or later: http://skarnet.org/software/s6/ -- s6-rc version 0.5.2.1 or later: http://skarnet.org/software/s6-rc/ -- oblibs version 0.1.3.0 or later: https://framagit.org/Obarun/oblibs/ +- skalibs version 2.10.0.3: http://skarnet.org/software/skalibs/ +- execline version 2.8.0.1: http://skarnet.org/software/execline/ +- s6 version 2.10.0.3: http://skarnet.org/software/s6/ +- s6-rc version 0.5.2.2: http://skarnet.org/software/s6-rc/ +- oblibs version 0.1.3.0: https://framagit.org/Obarun/oblibs/ - lowdown version 0.6.4 or later for man and html pages: https://kristaps.bsd.lv/lowdown/ - linux-api-headers 5.8 or later: https://www.gnu.org/software/libc (only for linux system) @@ -64,27 +64,6 @@ cross-compiled skalibs, the rest is easy. - Make sure to use the correct version of skalibs for your target, and the correct sysdeps directory, making use of the *--with-include*, *--with-lib*, *--with-dynlib* and *--with-sysdeps* options as necessary. -## The slashpackage convention - -The [slashpackage convention](http://cr.yp.to/slashpackage.html) is a package installation scheme that provides a few guarantees over other conventions such as the FHS, for instance fixed absolute pathnames. obarun.org packages support it: use the *--enable-slashpackage* option to configure, or *--enable-slashpackage=DIR* for a prefixed DIR/package tree. This option will activate slashpackage support during the build and set slashpackage-compatible installation directories. If -$version is the current 66 version number: - -- *--bindir* will be set to /package/prog/66-$version/command -- *--includedir* will be set to /package/prog/66-$version/include -- *--libdir* will be set to /package/prog/66-$version/library -- *--dynlibdir* will be set to /package/prog/66-$version/library.so - - -Note that *--datadir* will be unchanged, because the data exported by 66, i.e. the leap second table, is system-wide. You should manually specify *--datadir=...* if you want to deviate from the default. - -*--prefix* is pretty much ignored when you use *--enable-slashpackage*: it will only impact *--datadir*. You should probably not use both *--enable-slashpackage* and *--prefix*. - -When using slashpackage, two additional Makefile targets are available after `make install`: -- `make -L update` changes the default version of the software to the freshly installed one. (This is useful when you have several installed versions of the same software, which slashpackage supports.) -- `make -L global-links` adds links from DIR/command and DIR/library.so to the default version of the binaries and shared libraries. -The `-L` option to make is necessary because targets are symbolic links, and the default make behaviour is to check the pointed file's timestamp and not the symlink's timestamp. - - ## Out-of-tree builds obarun.org packages do not support out-of-tree builds. They are small, so it does not cost much to duplicate the entire source tree if parallel builds are needed. diff --git a/Makefile b/Makefile index f4bc0b053fb15211c7bbe177c2dc8a0c46f21508..48062d4723f98bf20f1d9fa776158681f7599ed4 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ ifneq ($(strip $(ALL_BINS)$(SHARED_LIBS)),) exec $(STRIP) -R .note -R .comment $(ALL_BINS) $(SHARED_LIBS) endif -install: install-dynlib install-libexec install-bin install-lib install-include install-data install-conf install-html install-man +install: install-dynlib install-libexec install-bin install-lib install-include install-data install-html install-man install-dynlib: $(SHARED_LIBS:lib%.so.xyzzy=$(DESTDIR)$(dynlibdir)/lib%.so) install-libexec: $(LIBEXEC_TARGETS:%=$(DESTDIR)$(libexecdir)/%) install-bin: $(BIN_TARGETS:%=$(DESTDIR)$(bindir)/%) diff --git a/configure b/configure index 4f4eff605d70fdd7aac3fa869365a0bcfd9824ff..f620da78e9ad3c0fdffe25370277a6312fe7170b 100755 --- a/configure +++ b/configure @@ -76,9 +76,6 @@ Optional features: --disable-allstatic do not prefer linking against static libraries [enabled] --enable-static-libc make entirely static binaries [disabled] --disable-all-pic do not build static libraries as PIC [enabled] - --enable-slashpackage[=ROOT] assume /package installation at ROOT [disabled] - --enable-absolute-paths do not rely on PATH to access this package's binaries, - hardcode absolute BINDIR/foobar paths instead [disabled] If no --prefix option is given, by default sysdeps will be fetched from /usr/lib/skalibs/sysdeps. @@ -93,69 +90,70 @@ exit 0 # generally not a good idea to use echo. # See http://www.etalabs.net/sh_tricks.html echo () { - IFS=" " - printf %s\\n "$*" + IFS=" " + printf %s\\n "$*" } quote () { - tr '\n' ' ' <<EOF | grep '^[-[:alnum:]_=,./:]* $' >/dev/null 2>&1 && { echo "$1" ; return 0 ; } + tr '\n' ' ' <<EOF | grep '^[-[:alnum:]_=,./:]* $' >/dev/null 2>&1 && { echo "$1" ; return 0 ; } $1 EOF - echo "$1" | sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" -e "s#^'\([-[:alnum:]_,./:]*\)=\(.*\)\$#\1='\2#" -e "s|\*/|* /|g" + echo "$1" | sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" -e "s#^'\([-[:alnum:]_,./:]*\)=\(.*\)\$#\1='\2#" -e "s|\*/|* /|g" } fail () { - echo "$*" - exit 1 + echo "$*" + exit 1 } fnmatch () { - eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" + eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" } cmdexists () { - type "$1" >/dev/null 2>&1 + type "$1" >/dev/null 2>&1 } trycc () { - test -z "$CC_AUTO" && cmdexists "$1" && CC_AUTO="$*" + test -z "$CC_AUTO" && cmdexists "$1" && CC_AUTO="$*" } stripdir () { - while eval "fnmatch '*/' \"\${$1}\"" ; do - eval "$1=\${$1%/}" - done + while eval "fnmatch '*/' \"\${$1}\"" ; do + eval "$1=\${$1%/}" + done } tryflag () { - echo "Checking whether compiler accepts $2 ..." - echo "typedef int x;" > "$tmpc" - if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST "$2" -c -o "$tmpo" "$tmpc" >/dev/null 2>&1 ; then - echo " ... yes" - eval "$1=\"\${$1} \$2\"" - eval "$1=\${$1# }" - return 0 - else - echo " ... no" - return 1 - fi + echo "Checking whether compiler accepts $2 ..." + echo "typedef int x;" > "$tmpc" + if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST "$2" -c -o "$tmpo" "$tmpc" >/dev/null 2>&1 ; then + echo " ... yes" + eval "$1=\"\${$1} \$2\"" + eval "$1=\${$1# }" + return 0 + else + echo " ... no" + return 1 + fi } tryldflag () { - echo "Checking whether linker accepts $2 ..." - echo "typedef int x;" > "$tmpc" - if $CC_AUTO $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -nostdlib "$2" -o "$tmpe" "$tmpc" >/dev/null 2>&1 ; then - echo " ... yes" - eval "$1=\"\${$1} \$2\"" - eval "$1=\${$1# }" - return 0 - else - echo " ... no" - return 1 - fi + echo "Checking whether linker accepts $2 ..." + echo "typedef int x;" > "$tmpc" + if $CC_AUTO $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -nostdlib "$2" -o "$tmpe" "$tmpc" >/dev/null 2>&1 ; then + echo " ... yes" + eval "$1=\"\${$1} \$2\"" + eval "$1=\${$1# }" + return 0 + else + echo " ... no" + return 1 + fi } + # Actual script CC_AUTO= @@ -205,11 +203,6 @@ manualsysdeps=false shared=false static=true allpic=true -slashpackage=false -abspath=false -sproot= -home= -exthome= allstatic=true evenmorestatic=false addincpath='' @@ -267,11 +260,6 @@ for arg ; do --disable-static-libc|--enable-static-libc=no) evenmorestatic=false ;; --enable-all-pic|--enable-all-pic=yes) allpic=true ;; --disable-all-pic|--enable-all-pic=no) allpic=false ;; - --enable-slashpackage=*) sproot=${arg#*=} ; slashpackage=true ; ;; - --enable-slashpackage) sproot= ; slashpackage=true ;; - --disable-slashpackage) sproot= ; slashpackage=false ;; - --enable-absolute-paths|--enable-absolute-paths=yes) abspath=true ;; - --disable-absolute-paths|--enable-absolute-paths=no) abspath=false ;; --enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;; --host=*|--target=*) target=${arg#*=} ;; --build=*) build=${arg#*=} ;; @@ -317,7 +305,7 @@ fi stripdir prefix for i in exec_prefix dynlibdir libexecdir bindir libdir includedir sysconfdir \ datarootdir mandir shebangdir livedir skel system_dir system_log \ - service_system module_system script_system service_adm module_adm service_admconf sproot sysdeps ; do + service_system module_system script_system service_adm module_adm service_admconf sysdeps ; do eval tmp=\${$i} eval $i=$tmp stripdir $i @@ -368,55 +356,10 @@ while : ; do 2>|/dev/null > "$tmpe" && break test "$i" -gt 50 && fail "$0: cannot create temporary files" done + set +C trap 'rm -f "$tmpc" "$tmpo" "$tmpe"' EXIT ABRT INT QUIT TERM HUP -# Set slashpackage values -if $slashpackage ; then - home=${sproot}/package/${category}/${package}-${version} - exthome=${sproot}/package/${category}/${package} - if $manualsysdeps ; then - : - else - sysdeps=${sproot}/package/prog/skalibs/sysdeps - fi - extbinprefix=${exthome}/command - dynlibdir=${home}/library.so - bindir=${home}/command - libdir=${home}/library - libexecdir=$bindir - includedir=${home}/include - sysconfdir=${home}/etc - datarootdir=${home}/data - mandir=${dataroodir}/doc/man - skel=${skel} - system_dir=${home}/${system_dir} - system_log=${datarootdir}/${system_log} - service_system=${home}/${service_system} - module_system=${home}/${module_system} - script_system=${home}/${script_system} - service_adm=${home}/${sysconfdir}/${service_adm} - module_adm=${home}/${sysconfdir}/${module_adm} - service_admconf=${home}/${sysconfdir}/${service_admconf} - if $shebangisdefault ; then - shebangdir=${extbinprefix} - fi - while read dep condvar ; do - if test -n "$condvar" ; then - eval "cond=$condvar" - else - cond=true - fi - if $cond ; then - addincpath="$addincpath -I${sproot}${dep}/include" - vpaths="$vpaths ${sproot}${dep}/library" - addlibspath="$addlibspath -L${sproot}${dep}/library" - vpathd="$vpathd ${sproot}${dep}/library.so" - addlibdpath="$addlibdpath -L${sproot}${dep}/library.so" - fi - done < package/deps-build -fi - # Find a C compiler to use if test -n "$target" && test x${build} != x${target} ; then cross=${target}- @@ -498,6 +441,8 @@ tryflag CPPFLAGS_AUTO -Wno-unused-value tryflag CPPFLAGS_AUTO -Wno-parentheses tryflag CFLAGS_AUTO -ffunction-sections tryflag CFLAGS_AUTO -fdata-sections + +tryldflag LDFLAGS_AUTO -Wl,--as-needed tryldflag LDFLAGS_AUTO -Wl,--sort-section=alignment tryldflag LDFLAGS_AUTO -Wl,--sort-common @@ -569,11 +514,8 @@ script_user := $script_user service_userconf := $service_userconf user_log := $user_log sysdeps := $sysdeps -slashpackage := $slashpackage -sproot := $sproot version := $version -home := $home -exthome := $exthome + SPAWN_LIB := ${spawn_lib} SOCKET_LIB := ${socket_lib} SYSCLOCK_LIB := ${sysclock_lib} @@ -658,19 +600,10 @@ All rights reserved.*/ #define ${package_macro_name}_SCRIPT_USERDIR "$script_user/" EOF -if $slashpackage ; then - echo "#define ${package_macro_name}_BINPREFIX \"$bindir/\"" - echo "#define ${package_macro_name}_EXTBINPREFIX \"$extbinprefix/\"" - echo "#define ${package_macro_name}_EXTLIBEXECPREFIX \"$extbinprefix/\"" -elif $abspath ; then - echo "#define ${package_macro_name}_BINPREFIX \"$bindir/\"" - echo "#define ${package_macro_name}_EXTBINPREFIX \"$bindir/\"" - echo "#define ${package_macro_name}_EXTLIBEXECPREFIX \"$libexecdir/\"" -else - echo "#define ${package_macro_name}_BINPREFIX \"\"" - echo "#define ${package_macro_name}_EXTBINPREFIX \"\"" - echo "#define ${package_macro_name}_EXTLIBEXECPREFIX \"$libexecdir/\"" -fi + +echo "#define ${package_macro_name}_BINPREFIX \"\"" +echo "#define ${package_macro_name}_EXTBINPREFIX \"\"" +echo "#define ${package_macro_name}_EXTLIBEXECPREFIX \"$libexecdir/\"" echo "#define ${package_macro_name}_LIBEXECPREFIX \"$libexecdir/\"" echo "#define ${package_macro_name}_EXECLINE_SHEBANGPREFIX \"$shebangdir/\"" echo diff --git a/doc/upgrade.md b/doc/upgrade.md index 9f94257370cc9952fe4bfa2dada2968683007c25..8efd907816c02f6109f8582a20fcfbe6dafa37a3 100644 --- a/doc/upgrade.md +++ b/doc/upgrade.md @@ -11,6 +11,24 @@ author: Eric Vidal <eric@obarun.org> --- +# In 0.6.1.3 + +- Adapt to skalibs 2.10.0.3. + +- Adapt to execline 2.8.0.1. + +- Adapt to s6 2.10.0.3. + +- Adapt to s6-rc 0.5.2.2. + +- Bugs Fix: + - 66-boot: fix call of 66-scandir -c option. + - configure script: fix installation of skel/init.conf file. + +- Configure script: remove the slashpackage convention. + +--- + # In 0.6.1.2 - Bugs fix: diff --git a/package/info b/package/info index 245780d63b34be7fdd3f6ea499b2316fa319ea50..131592d58c7e4241d2970d8e073c3d9aeec5220e 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=66 -version=0.6.1.2 +version=0.6.1.3 category=admin package_macro_name=SS diff --git a/src/66/66-boot.c b/src/66/66-boot.c index 566b31c77ec4f507ee9f3afb4c5b125f503d6241..66d8d67be86e5ebdfbd44ea8c84772c46cb942aa 100644 --- a/src/66/66-boot.c +++ b/src/66/66-boot.c @@ -663,7 +663,8 @@ int main(int argc, char const *const *argv,char const *const *envp) if (setenv("PATH", path, 1) == -1) sulogin("set initial PATH: ",path) ; /** create scandir */ { - size_t nargc = 6 + catch_log ; + size_t ncatch = !catch_log ? 1 : 0 ; + size_t nargc = 6 + ncatch ; unsigned int m = 0 ; char const *t[nargc] ; diff --git a/src/66/66-hpr.c b/src/66/66-hpr.c index ca093be1129ecdf509aefd5f125acca032633713..24757b6fd6c9a19801da2078fa7301d91af5c9d9 100644 --- a/src/66/66-hpr.c +++ b/src/66/66-hpr.c @@ -44,6 +44,11 @@ #ifndef _PATH_WTMP #define _PATH_WTMP "/dev/null/wtmp" +# ifdef WTMPX_FILE +# define _PATH_WTMP WTMPX_FILE +# else +# define _PATH_WTMP "/var/log/wtmp" +# endif #endif #define USAGE "66-hpr [ -H ] [ -l live ] [ -b banner ] [ -f ] [ -h | -p | -r ] [ -n ] [ -d | -w ] [ -W ]" diff --git a/src/66/66-shutdownd.c b/src/66/66-shutdownd.c index 940fcc24ddb37ed1cfb9f6d95c88434f10b96d31..1f577c66a97f59397edd8e65b1126ddbbd7be4f3 100644 --- a/src/66/66-shutdownd.c +++ b/src/66/66-shutdownd.c @@ -157,7 +157,7 @@ static void parse_conf(char const *confile,char *rcshut,char const *key) stralloc_free(&src) ; } -static inline void run_rcshut (char const *const *envp) +static inline void run_rcshut (void) { log_flow() ; @@ -168,7 +168,7 @@ static inline void run_rcshut (char const *const *envp) auto_conf(confile,conflen) ; parse_conf(confile,rcshut,"RCSHUTDOWN") ; char const *rcshut_argv[3] = { rcshut, confile, 0 } ; - pid = child_spawn0(rcshut_argv[0], rcshut_argv, envp) ; + pid = child_spawn0(rcshut_argv[0], rcshut_argv,(char const *const *)environ) ; if (pid) { int wstat ; @@ -270,8 +270,7 @@ static inline void prepare_stage4 (char what) || buffer_puts(&b, S6_EXTBINPREFIX "66-scanctl ") < 0 || buffer_puts(&b, "-l ") < 0 || buffer_puts(&b, live) < 0 - || buffer_put(&b, what == 'h' ? "s" : &what, 1) < 0 - || buffer_putsflush(&b, "b\n}\n") < 0) + || buffer_putsflush(&b, " b\n}\n") < 0) log_dieusys(LOG_EXIT_SYS, "write to ", STAGE4_FILE ".new") ; } else @@ -345,7 +344,7 @@ static inline void unsupervise_tree (void) if (errno) log_dieusys(LOG_EXIT_SYS, "readdir: ",tmp) ; } -int main (int argc, char const *const *argv, char const *const *envp) +int main (int argc, char const *const *argv) { unsigned int grace_time = 3000 ; tain_t deadline ; @@ -382,9 +381,36 @@ int main (int argc, char const *const *argv, char const *const *envp) /* if we're in stage 4, exec it immediately */ { char const *stage4_argv[2] = { "./" STAGE4_FILE, 0 } ; - restore_console() ; - execve(stage4_argv[0], (char **)stage4_argv, (char *const *)envp) ; - if (errno != ENOENT) log_warnusys("exec ", stage4_argv[0]) ; + + if (!inns && !nologger) { + + int fd[2] ; + int e ; + fd[0] = fcntl(1, F_DUPFD_CLOEXEC, 0) ; + + if (fd[0] < 0) + log_dieusys(LOG_EXIT_SYS, "dup stdout") ; + + fd[1] = fcntl(2, F_DUPFD_CLOEXEC, 0) ; + + if (fd[1] < 0) + log_dieusys(LOG_EXIT_SYS, "dup stderr") ; + + restore_console() ; + + execv(stage4_argv[0], (char **)stage4_argv) ; + + e = errno ; + if (fd_move2(1, fd[0], 2, fd[1]) < 0) + log_warnusys("restore fds") ; + errno = e ; + + } else { + + execv(stage4_argv[0], (char **)stage4_argv) ; + if (errno != ENOENT) + log_warnusys("exec ", stage4_argv[0]) ; + } } fdr = open_read(SHUTDOWND_FIFO) ; @@ -406,7 +432,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (r == -1) log_dieusys(LOG_EXIT_SYS, "iopause") ; if (!r) { - run_rcshut(envp) ; + run_rcshut() ; tain_now_g() ; if (what != 'S') break ; tain_add_g(&deadline, &tain_infinite_relative) ; @@ -419,7 +445,8 @@ int main (int argc, char const *const *argv, char const *const *envp) fd_close(fdw) ; fd_close(fdr) ; fd_close(1) ; - restore_console() ; + if (!inns && !nologger) + restore_console() ; /* The end is coming! */ prepare_stage4(what) ;