]> bicyclesonthemoon.info Git - ott/bsta-tools/commitdiff
add updater; improve uploader diff
authorb <rowerynaksiezycu@gmail.com>
Sat, 29 Mar 2025 20:45:41 +0000 (21:45 +0100)
committerb <rowerynaksiezycu@gmail.com>
Sat, 29 Mar 2025 20:45:41 +0000 (21:45 +0100)
makefile
remote.txt
update.1.pl [new file with mode: 0644]
upload.1.pl

index 0e58e39c13e2dfc2de55a1f24c4414e932624481..b310e672b3e18fb3c9454869e59e2a7f237ea214 100644 (file)
--- a/makefile
+++ b/makefile
@@ -39,14 +39,17 @@ CONFIGURE_CMD = $(PERL) ./configure.pl --do perl=$(PERL) _base_path=$(BASE_PATH)
 # keep these 2 lists in the same order!:
 GENERATE_FROM=\
 makedata.1.pl\
+update.1.pl\
 upload.1.pl
 
 TO_GENERATE=\
 makedata.pl\
+update.pl\
 upload.pl
 
 EXEC=\
 makedata.pl\
+update.pl\
 upload.pl
 
 BIN=\
index 51a9ec11b0d5e88bdea90f3485aa54beba71b39d..fe7592ae2ed127c8270d1f31b16dc598cac945e3 100644 (file)
@@ -1,5 +1,8 @@
 user: b
 server: bicyclesonthemoon.info
 data-test: /botm/data/test-bsta
+bin-test: /botm/bin/test-bsta
 data-bsta: /botm/data/bsta
+bin-bsta: /botm/bin/bsta
 data-again: /botm/data/bstagain
+bin-again: /botm/bin/bstagain
diff --git a/update.1.pl b/update.1.pl
new file mode 100644 (file)
index 0000000..d787f21
--- /dev/null
@@ -0,0 +1,77 @@
+###RUN_PERL: #!/usr/bin/perl
+
+# update.pl is generated from update.1.pl.
+#
+# run update on BSTA server
+#
+# Copyright (C) 2025  Balthasar Szczepański
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+use utf8;
+use Encode::Locale ('decode_argv');
+use Encode ('encode', 'decode');
+
+###PERL_LIB: use lib ~/ott/bsta/lib
+use botm_common (
+       'join_path',
+       'read_data_file',
+       'system_encoded'
+);
+
+binmode STDIN,  ':encoding(UTF-8)';
+binmode STDOUT, ':encoding(UTF-8)';
+binmode STDERR, ':encoding(UTF-8)';
+decode_argv();
+
+my $time = time();
+srand ($time-$$);
+
+###PERL_ETC_REMOTE_PATH:    ETC_REMOTE_PATH    = ~/ott/bsta/etc/remote.txt
+
+my %remote;
+my $target;
+my $server;
+
+print $time." UPDATE\n";
+
+if (@ARGV < 1) {
+       print STDERR "no remote target\n";
+       print "FAIL\n";
+       exit 1;
+}
+
+$target = 'bin-'.shift(@ARGV);
+
+%remote = read_data_file(ETC_REMOTE_PATH());
+unless (
+       (exists $remote{'server'}) and
+       (exists $remote{'user'  }) and
+       (exists $remote{$target })
+) {
+       print STDERR "didn't get remote target\n";
+       print "FAIL\n";
+       exit 1;
+}
+
+$server  = $remote{'user'}.'@'.$remote{'server'};
+$target  = $remote{$target };
+
+my $r = system_encoded('ssh', (
+       'ssh', '-q', '-T', $server, '-t',
+       join_path('/', $target, 'update.pl').' '.join(' ', @ARGV)
+));
+
+print(($r == 0) ? "OK\n" : "FAIL\n");
index 8e187f6c777875bc6df2b3571adf7b5b0ee20053..9fad7108ccc52a96e731736c386b6a8ff94a6b48 100644 (file)
@@ -2,7 +2,7 @@
 
 # upload.pl is generated from upload.1.pl.
 #
-# make data files from chapter files
+# upload frames, attachment & stuff
 #
 # Copyright (C) 2025  Balthasar Szczepański
 #
@@ -367,18 +367,17 @@ foreach my $upload (@upload_list) {
                }
                foreach my $key (keys %keys) {
                        unless (exists $local_data{$key}) {
-                               push(@differences, '--> '.$key);
+                               push(@differences, '--> '.$key.': '.$remote_data{$key});
                                next;
                        }
                        unless (exists $remote_data{$key}) {
-                               push(@differences, '<-- '.$key);
+                               push(@differences, '<-- '.$key.': '.$local_data{$key});
                                next;
                        }
                        unless ($local_data{$key} eq $remote_data{$key}) {
-                               push(@differences, '=/= '.$key);
-                               push(@differences, '<== '.$local_data{$key}.' <==');
-                               push(@differences, '==> '.$remote_data{$key}.' ==>');
-                               push(@differences, '=\=');
+                               push(@differences, '=/= '.$key.':');
+                               push(@differences, '<== '.$local_data{$key});
+                               push(@differences, '==> '.$remote_data{$key});
                                next;
                        }
                }