diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-09-15 18:56:44 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-09-15 18:56:44 +0200 |
commit | 0a31d853df17ab05389d1d699b0104899c771e16 (patch) | |
tree | 9e28b5e4d69c638f8079eafa2af9f5314b487fc7 | |
parent | 278b76fabf31abe8fc4fbe6ca1c0ad6af830fcb7 (diff) |
moved srcdist to actions
moved install to build.ninja
removed bindist
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | MANIFEST.BIN.m4 | 74 | ||||
-rwxr-xr-x | actions | 26 | ||||
-rwxr-xr-x | configure | 21 | ||||
-rw-r--r-- | confninja.sh | 147 | ||||
-rw-r--r-- | lib/JWebmail.pm | 2 | ||||
-rw-r--r-- | t/Webmail.t | 7 |
7 files changed, 163 insertions, 116 deletions
@@ -2,11 +2,11 @@ blib/ log/ MYMETA.* Makefile +JWebmail-*.tgz JWebmail-*.tar.gz JWebmail-*.tar.zstd *.old .vscode/ -t/testdata/ extract/ *.bak __pycache__/ diff --git a/MANIFEST.BIN.m4 b/MANIFEST.BIN.m4 deleted file mode 100644 index 4b87f31..0000000 --- a/MANIFEST.BIN.m4 +++ /dev/null @@ -1,74 +0,0 @@ -b/extract.pl - -ifelse(MAILDIR_EXTRACTOR_NAME, `extractrs', `bin/jwebmail-extract') -ifelse(MAILDIR_EXTRACTOR_NAME, `extractpy', `script/qmauth.py') -ifelse(MAILDIR_EXTRACTOR_NAME, `extractpl', `script/qmauth.pl') - -script/jwebmail -script/testauthenticator.pl - -lib/JWebmail/Controller/Webmail.pm -lib/JWebmail/I18N/de.pm -lib/JWebmail/I18N/en.pm -lib/JWebmail/Model/ReadMails/QMailAuthuser.pm -lib/JWebmail/Model/ReadMails/Role.pm -lib/JWebmail/Model/WriteMails.pm -lib/JWebmail/Plugin/I18N2/INI.pm -lib/JWebmail/Plugin/I18N2/Maketext.pm -lib/JWebmail/Plugin/I18N2/Role.pm -lib/JWebmail/Plugin/I18N2.pm -lib/JWebmail/Plugin/INIConfig.pm -lib/JWebmail/Plugin/Paginate.pm -lib/JWebmail/Plugin/ServerSideSessionData.pm -lib/JWebmail/Plugin/TOMLConfig.pm -lib/JWebmail/View/RenderMail.pm -lib/JWebmail/View/Webmail.pm -lib/JWebmail/Config.pm -lib/JWebmail/I18N.pm -lib/JWebmail.pm - -public/css/my_bulma.css -ifelse(JWM_MODE, `development', `public/css/my_bulma.css.map') -public/src/displayheaders.js -ifelse(JWM_MODE, `development', `public/src/displayheaders.js.map') - -ifelse(JWM_LOGIN_SCHEME, `cram_md5', -`public/src/login_cram.js -ifelse(JWM_MODE, `development', `public/src/login_cram.js.map')') - -public/src/rendermail.js -ifelse(JWM_MODE, `development', `public/src/rendermail.js.map') - -t/Extract.t -t/I18N2.t -t/INI.t -t/Pagination.t -t/ViewWebmail.t -t/Webmail.t - -templates/displayheaders/_bot_nav.html.ep -templates/displayheaders/_folders.html.ep -templates/displayheaders/_main_table.html.ep -templates/displayheaders/_pagination1.html.ep -templates/displayheaders/_pagination2.html.ep -templates/displayheaders/_pagination3.html.ep -templates/displayheaders/_top_nav.html.ep -templates/layouts/mainlayout.html.ep -templates/webmail/about.html.ep -templates/webmail/displayheaders.html.ep -templates/webmail/login.html.ep -templates/webmail/readmail.html.ep -templates/webmail/writemail.html.ep -templates/exception_.html.ep -templates/not_found.html.ep - -actions -CHANGES.md -build.ninja -jwebmail.development.toml -jwebmail.production.toml -jwebmail.service -LICENSE -Makefile.PL -MANIFEST.BIN -README.md @@ -6,13 +6,23 @@ help_text= help_text="$help_text build\t[]\t\n" dev_config () { - ./configure -e extractrs + mkdir -p blib + ./configure -e extractrs -d blib } help_text="$help_text unconfigure\t[]\tresets the build\n" unconfigure () { - rm build.ninja lib/JWebmail/Config.pm MANIFEST.BIN - rm -r JWebmail-srcdist/ JWebmail-bindist/ + ninja -t clean || true + rm build.ninja lib/JWebmail/Config.pm + rm -r blib +} + +help_text="$help_text srcdist\t[]\tcreate a source distribution\n" +srcdist () { + if tar --version | head -n1 | grep -q GNU + then tar --posix -czf JWebmail-srcdist.tgz -T MANIFEST + else xargs tar -czf JWebmail-srcdist.tgz <MANIFEST + fi } help_text="$help_text build\t[]\t\n" @@ -20,16 +30,6 @@ build () { env PATH="node_modules/.bin/:$PATH" ninja "$@" } -help_text="$help_text install\t[]\t\n" -install () { - perl Makefile.PL - make - if readlink /bin/init | grep -q 'systemd' - then install -m 644 jwebmail.service /etc/systemd/system - fi - install -m 644 jwebmail.toml /etc -} - help_text="$help_text start_dev\t[]\tstarts a hot reloading dev server\n" start_dev () { morbo script/jwebmail @@ -40,15 +40,22 @@ check_ninja_version () { rm "$ninja_file" } +if readlink /bin/init | grep -q systemd +then JWM_INIT=systemd +fi + allargs="$*" -while getopts 'c:e:hm:' opt +while getopts 'c:d:e:i:hm:p:' opt do case $opt in (e) JWM_MAILDIR_EXTRACTOR="$OPTARG";; (m) JWM_MODE="$OPTARG";; (c) JWM_LOGIN_SCHEME="$OPTARG";; + (d) DESTDIR="$OPTARG";; + (p) PREFIX="$OPTARG";; + (i) JWM_INIT="$OPTARG";; (h) t="$(printf '\t')" - expand -t 70 <<END + expand -t 37 <<END usage: $0 configure [options...] OPTIONS @@ -56,6 +63,9 @@ usage: $0 configure [options...] -e MAILDIR_EXTRACTOR extractpy {extractpy,extractpl,extractrs} -m MODE development {development,production} -c LOGIN_SCHEME plain {plain,cram_md5} The login scheme (don't use plain unless over TLS) + -d DESTDIR / Install root + -p PREFIX usr/local {usr,usr/local} Install prefix + -i INIT $JWM_INIT$t {,systemd} Init system to install service files for END exit ;; @@ -67,6 +77,8 @@ shift $((OPTIND-1)) : "${JWM_MAILDIR_EXTRACTOR=extractpy}" && echo "$JWM_MAILDIR_EXTRACTOR" | grep -Eq '^extract(pl|py|rs)$' : "${JWM_MODE=development}" && [ "$JWM_MODE" = development -o "$JWM_MODE" = production ] : "${JWM_LOGIN_SCHEME=plain}" && [ "$JWM_LOGIN_SCHEME" = plain -o "$JWM_LOGIN_SCHEME" = cram_md5 ] +: "${DESTDIR=/}" && [ -d "$DESTDIR" ] +: "${PREFIX=usr/local}" PATH="$(pwd)/node_modules/.bin${PATH:+:$PATH}" @@ -78,7 +90,6 @@ check_command hypnotoad check_command npm check_command esbuild check_command sass -check_command m4 check_command ninja check_ninja_version 1.11 @@ -117,7 +128,9 @@ export MAILDIR_EXTRACTOR_NAME="$JWM_MAILDIR_EXTRACTOR" export MAILDIR_EXTRACTOR_BIN export JWM_EXTRACTRS_DIR export JWM_MODE +export JWM_INIT +export DESTDIR +export PREFIX perl -pe 's/@(\w+)@/$ENV{$1}/ga' lib/JWebmail/Config.pm.in >|lib/JWebmail/Config.pm -m4 -DJWM_LOGIN_SCHEME="$JWM_LOGIN_SCHEME" -DJWM_MODE="$JWM_MODE" -DMAILDIR_EXTRACTOR_NAME="$MAILDIR_EXTRACTOR_NAME" MANIFEST.BIN.m4 >|MANIFEST.BIN sh confninja.sh >|build.ninja diff --git a/confninja.sh b/confninja.sh index fc5fbcf..c5f8c1a 100644 --- a/confninja.sh +++ b/confninja.sh @@ -14,17 +14,25 @@ rule scss description = SCSS $out rule bundle - command = esbuild --bundle $bundle_mode --outfile=$out $in + command = esbuild --log-level=warning --bundle $bundle_mode --outfile=$out $in description = BUNDLE $out rule dist - command = tar --posix --zstd -cf $out $in + command = tar -a -cf $out $in description = DIST $out rule cpy command = cp $in $out description = CPY $out +rule instexec + command = install -T $in $out + description = INSTEXEC $out + +rule instdata + command = install -m0644 -T $in $out + description = INSTDATA $out + rule perltest command = prove -l t/ description = PERLTEST @@ -37,8 +45,10 @@ rule configure build test: perltest END +# CONFIGURE + echo "confargs = $CONFARGS" -echo "build build.ninja lib/JWebmail/Config.pm MANIFEST.BIN: configure configure confninja.sh lib/JWebmail/Config.pm.in MANIFEST MANIFEST.BIN.m4" +echo "build build.ninja lib/JWebmail/Config.pm: configure configure confninja.sh lib/JWebmail/Config.pm.in" case "$JWM_MODE" in (development) @@ -53,10 +63,12 @@ case "$JWM_MODE" in ;; esac +# EXTRACTRS + case "$MAILDIR_EXTRACTOR_NAME" in (extractrs) echo "extractrs_dir = $JWM_EXTRACTRS_DIR" - echo -n 'build bin/jwebmail-extract: cargo' + echo -n 'build bin/jwebmail-extract: cargo $extractrs_dir/Cargo.toml' FILES_RS='arguments.rs cmd.rs error.rs main.rs rfc822.rs cmd/count.rs cmd/folders.rs cmd/list.rs cmd/raw.rs' for f in $FILES_RS do @@ -66,6 +78,8 @@ case "$MAILDIR_EXTRACTOR_NAME" in ;; esac +# PUBLIC + FILES_JS='src/displayheaders.js src/rendermail.js' if [ "$LOGIN_SCHEME" = cram_md5 ] then FILES_JS="$FILES_JS src/login_cram.js" @@ -85,22 +99,119 @@ do case "$JWM_MODE" in esac done -while read f -do [ -n "$f" ] && echo "build JWebmail-srcdist/$f: cpy $f" -done <MANIFEST +# BINDIST + +#while read f +#do [ -n "$f" ] && echo "build JWebmail-bindist/$f: cpy $f" +#done <MANIFEST.BIN +# +#if command -v zstd >/dev/null +#then echo -n "build JWebmail-bindist.tar.zstd: dist" +#else echo -n "build JWebmail-bindist.tar.gz: dist" +#fi +#while read f +#do [ -n "$f" ] && echo -n " JWebmail-bindist/$f" +#done <MANIFEST.BIN +#echo + +# INSTALL + +install_file () { echo "build \$destdir/\$$2/$4: $1 $3/$4"; ALL_INST="$ALL_INST \$destdir/\$$2/$4"; } + +echo "destdir = $DESTDIR" + +echo "prefix = $PREFIX" +echo "bindir = \$prefix/bin" +echo "scriptdir = \$prefix/bin" +echo "perldir = \$prefix/lib/perl5" +if [ "$PREFIX" = usr ] +then echo "confdir = \$prefix/../etc" +else echo "confdir = \$prefix/etc" +fi +echo "datadir = \$prefix/share/jwebmail" +echo "docdir = \$prefix/share/doc/jwebmail" -echo -n "build JWebmail-srcdist.tar.zstd: dist" -while read f -do [ -n "$f" ] && echo -n " JWebmail-srcdist/$f" -done <MANIFEST -echo +ALL_INST= + +case "$MAILDIR_EXTRACTOR_NAME" in + (extractrs) install_file instexec bindir bin jwebmail-extract;; + (extractpy) install_file instexec scriptdir script qmauth.py;; + (extractpl) install_file instexec scriptdir script qmauth.pl;; +esac + +install_file instexec scriptdir script jwebmail +install_file instexec scriptdir script testauthenticator.pl while read f -do [ -n "$f" ] && echo "build JWebmail-bindist/$f: cpy $f" -done <MANIFEST.BIN +do + install_file instdata perldir lib "$f" +done <<'END' +JWebmail/Controller/Webmail.pm +JWebmail/I18N/de.pm +JWebmail/I18N/en.pm +JWebmail/Model/ReadMails/QMailAuthuser.pm +JWebmail/Model/ReadMails/Role.pm +JWebmail/Model/WriteMails.pm +JWebmail/Plugin/I18N2/INI.pm +JWebmail/Plugin/I18N2/Maketext.pm +JWebmail/Plugin/I18N2/Role.pm +JWebmail/Plugin/I18N2.pm +JWebmail/Plugin/INIConfig.pm +JWebmail/Plugin/Paginate.pm +JWebmail/Plugin/ServerSideSessionData.pm +JWebmail/Plugin/TOMLConfig.pm +JWebmail/View/RenderMail.pm +JWebmail/View/Webmail.pm +JWebmail/Config.pm +JWebmail/I18N.pm +JWebmail.pm +END + +install_file instdata datadir . public/css/my_bulma.css +[ "$JWM_MODE" = development ] && install_file instdata datadir . public/css/my_bulma.css.map +install_file instdata datadir . public/src/displayheaders.js +[ "$JWM_MODE" = development ] && install_file instdata datadir . public/src/displayheaders.js.map +install_file instdata datadir . public/src/rendermail.js +[ "$JWM_MODE" = development ] && install_file instdata datadir . public/src/rendermail.js.map + +if [ "$LOGIN_SCHEME" = cram_md5 ] +then + install_file instdata datadir . public/src/login_cram.js + [ "$JWM_MODE" = development ] && install_file instdata datadir . public/src/login_cram.js.map +fi -echo -n "build JWebmail-bindist.tar.zstd: dist" while read f -do [ -n "$f" ] && echo -n " JWebmail-bindist/$f" -done <MANIFEST.BIN -echo +do + install_file instdata datadir . "$f" +done <<'END' +templates/displayheaders/_bot_nav.html.ep +templates/displayheaders/_folders.html.ep +templates/displayheaders/_main_table.html.ep +templates/displayheaders/_pagination1.html.ep +templates/displayheaders/_pagination2.html.ep +templates/displayheaders/_pagination3.html.ep +templates/displayheaders/_top_nav.html.ep +templates/layouts/mainlayout.html.ep +templates/webmail/about.html.ep +templates/webmail/displayheaders.html.ep +templates/webmail/login.html.ep +templates/webmail/readmail.html.ep +templates/webmail/writemail.html.ep +templates/exception_.html.ep +templates/not_found.html.ep +END + +install_file instdata confdir . jwebmail.development.toml +install_file instdata confdir . jwebmail.production.toml + +for f in CHANGES.md LICENSE README.md +do install_file instdata docdir . "$f" +done + +if [ "$JWM_INIT" = systemd ] +then + echo "build \$destdir/\$confdir/systemd/system/jwebmail.service: instdata jwebmail.service" + ALL_INST="$ALL_INST \$destdir/\$confdir/systemd/system/jwebmail.service" +fi + +echo "build install: phony $ALL_INST" diff --git a/lib/JWebmail.pm b/lib/JWebmail.pm index b829191..11c66db 100644 --- a/lib/JWebmail.pm +++ b/lib/JWebmail.pm @@ -1,4 +1,4 @@ -package JWebmail v1.2.2; +package JWebmail v1.2.3; use Mojo::Base Mojolicious; diff --git a/t/Webmail.t b/t/Webmail.t index 5346d2c..970b7bf 100644 --- a/t/Webmail.t +++ b/t/Webmail.t @@ -5,12 +5,10 @@ use utf8; use Test::More; use Test::Mojo; -use JWebmail::Model::ReadMails::MockJSON; - use constant DEFAULT_LANGUAGE => 'en'; -my $user = JWebmail::Model::ReadMails::MockJSON::VALID_USER; -my $pw = JWebmail::Model::ReadMails::MockJSON::VALID_PW; +my $user = 'mockmaildir@example.org'; +my $pw = '12345'; my $t = Test::Mojo->new('JWebmail', { @@ -19,7 +17,6 @@ my $t = Test::Mojo->new('JWebmail', { i18n => { default_language => DEFAULT_LANGUAGE }, admin_mail => 'test@example.org', }); -$t->app->helper(users => sub { state $read = 'JWebmail::Model::ReadMails::MockJSON'->new($t->app->config->{model}{read}) }); $t->get_ok('/')->status_is(200); |