summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/note/mount/mount.txt17
-rw-r--r--doc/note/qemu/qemu.txt21
-rw-r--r--doc/note/samba/samba.txt5
-rw-r--r--doc/note/setup/setup-debian.txt4
-rw-r--r--doc/note/xorg/xrandr.txt34
-rw-r--r--src/main/lua/paisa-logs/DigHoustonLogs.lua4
-rw-r--r--src/main/lua/paisa-logs/PaisaLogParser.lua25
-rw-r--r--src/main/paisa-nonslim/README.txt58
-rw-r--r--src/main/paisa-nonslim/foo.js19
-rw-r--r--src/main/paisa-nonslim/patches/thor.patch22
-rw-r--r--src/main/paisa/JenkinsReBuild.c115
11 files changed, 279 insertions, 45 deletions
diff --git a/doc/note/mount/mount.txt b/doc/note/mount/mount.txt
index 99e1521..45c5637 100644
--- a/doc/note/mount/mount.txt
+++ b/doc/note/mount/mount.txt
@@ -1,4 +1,21 @@
+
+## Mount options
+
+/src /dst ext4 options,go=here 0 0
+ ^^^^^^^^^^^^^^^-- example in "fstab"
+
+mount -o options,go=here /src /dst
+ ^^^^^^^^^^^^^^^----------- example in mount command
+
+ password= SMB/nfs passwords (plaintext!)
+ uid=1000,gid=1000 What user/grp NTFS files shall have
+ user noroot is allowed to mount this fstab entry.
+ vers=3.0 Which SMB version to use
+ nofail Boot anyway, if fstab entry fails.
+ errors=remount-ro mount readonly if errors occur.
+
+
## tmpfs / ramfs
TODO: it seems as 'size' has no effect, and system may run OOM instead.
diff --git a/doc/note/qemu/qemu.txt b/doc/note/qemu/qemu.txt
index 944d4cb..19313a9 100644
--- a/doc/note/qemu/qemu.txt
+++ b/doc/note/qemu/qemu.txt
@@ -2,13 +2,6 @@
Qemu
================
-## TODO move this to the NFS section
-
-Example fstab entries:
-
-//10.0.2.2/sharename /mnt/cee-misc-lib nfs user,noauto,forceuid,uid=1000,vers=3.0 0 0
-
-
## Qemu Setup
apt install qemu-system-aarch64 qemu-efi-aarch64
@@ -121,7 +114,7 @@ true \
(see also "../../../doc/note/rasbpi/rasbpi.txt")
# Example Raspi
-qemu-system-aarch64
+qemu-system-aarch64 \
-nodefaults -accel tcg,thread=multi `# TODO confirm thread=multi works ` \
-machine type=raspi3b -cpu cortex-a53 -smp 4 -m 1G \
-kernel kernel8.img -dtb bcm2710-rpi-3-b.dtb -sd "$(dirname "$(realpath "$0")")/sd.qcow2" \
@@ -137,14 +130,14 @@ qemu-system-aarch64
&& hostpath=/path/to/host/dir \
&& sharename=work \
&& apt install --no-install-recommends -y samba \
- && printf '[%s]\npath = %s\npublic = no\nwriteable = yes\nguest ok = yes\nforce user = andreas\n' "${sharename:?}" "${hostpath:?}" | $SUDO tee -a /etc/samba/smb.conf >/dev/null \
+ && printf '[%s]\npath = %s\npublic = no\nallow hosts = 127.0.0.1\nwriteable = yes\nguest ok = yes\nforce user = andreas\n' "${sharename:?}" "${hostpath:?}" | $SUDO tee -a /etc/samba/smb.conf >/dev/null \
&& $SUDO /etc/init.d/smbd restart \
&& true
TODO: SMB server windoof
DoesNotWork: "https://serverfault.com/questions/442664/virtualization-linux-kvm-qemu-host-windows-vm-guest-how-to-access-data-drive#comment479177_442678"
-true `# SMB client debian` \
+ && `# SMB client debian` \
&& hostUsername=yourHostUser \
&& smbServer=10.0.2.2 \
&& sharename=work \
@@ -154,14 +147,13 @@ true `# SMB client debian` \
&& true \
&& $SUDO mkdir -p "${mountpoint:?}" \
&& $SUDO apt install --no-install-recommends -y cifs-utils psmisc \
- && $SUDO mount -t cifs -o username=${hostUsername:?},uid=${guestUid:?},gid=${guestGid:?} "//${smbServer:?}/${sharename:?}" "${mountpoint:?}" \
- && true
## Example smb config for smb server (TODO verify)
[vm-share]
path = /path/to/vm-share
+ allow hosts = 127.0.0.1, 169.254.42.42
browseable = yes
read only = no
guest ok = yes
@@ -214,11 +206,6 @@ In GUEST to access it do:
&& printf 'user:12345\n' | chpasswd \
&& /etc/init.d/sshd restart \
- && `# host auto-mount helper script ` \
- && mkdir ~/.local ~/.local/bin \
- && echo H4sIAAUQ5GYAA0WOsQ7CMAxE93yFCUgFiTbQEaliYWArA8wRFJNkaFI1CR2Af8cpSJ1sv/P5PJ+Jm7HCa+YxQI7s2R6dDxePfXWuD7XsYpCaiIyEpMYemY+nYRJVRFJ754Lsht9CNPeKL5bmDnlccaamUdGIjXbAF690Zv/h8AYfIfkhbyBrXbTUBWjMw0PuIOXaa4tVRp7pO3Jm6xSUMNXdCNQfqD8ALsR2U2yKsijF+LLX1x7TPU5aa8OPjqmdMzbwjH0BleXnHxQBAAA= |base64 -d|gzip -d > ~/.local/bin/setup \
- && printf '\n TODO: Resolve the todos in %s\n\n' ~/.local/bin/setup \
-
## Debian PostInstall
diff --git a/doc/note/samba/samba.txt b/doc/note/samba/samba.txt
index 92c89fd..a388035 100644
--- a/doc/note/samba/samba.txt
+++ b/doc/note/samba/samba.txt
@@ -12,11 +12,12 @@ Samba (aka SMB, ServerMessageBlock)
smbclient -NL //10.0.2.2
-## Mount a share
+## Example fstab entries (HINT: mkdir /mnt/sharename)
Variant for "/etc/fstab" (make sure mount dir exists):
-//10.0.2.2/sharename /mnt/sharename cifs password=,uid=1000,gid=1000,user,vers=3.0 0 0
+//10.0.2.2/sharename /mnt/sharename nfs nofail,user,noauto,forceuid,uid=1000,vers=3.0 0 0
+//10.0.2.2/sharename /mnt/sharename cifs nofail,password=,uid=1000,gid=1000,user,vers=3.0 0 0
## Fix silly resolve issues (smb.conf)
diff --git a/doc/note/setup/setup-debian.txt b/doc/note/setup/setup-debian.txt
index 5980f38..582764e 100644
--- a/doc/note/setup/setup-debian.txt
+++ b/doc/note/setup/setup-debian.txt
@@ -96,10 +96,12 @@ Populate "/etc/environment" as described by "./etc-environment".
vim htop pv openssh-client iptables iptables-persistent xxd zip unzip xz-utils p7zip-full \
file trash-cli ncat curl \
`# basic UI (vim-gtk required for system clipboard)` \
- vim-gtk3 firefox-esr file-roller thunderbird chromium okular \
+ vim-gtk3 firefox-esr pcmanfm file-roller thunderbird chromium okular \
`# software devel` \
git sqlite3 manpages-dev gdb qemu-utils qemu-system-x86 qemu-system-arm wireshark samba \
tigervnc-viewer jq universal-ctags \
+ `# network config` \
+ iwgtk \
`# server` \
nginx-light avahi-daemon \
`# mDNS client & tools` \
diff --git a/doc/note/xorg/xrandr.txt b/doc/note/xorg/xrandr.txt
new file mode 100644
index 0000000..109cb67
--- /dev/null
+++ b/doc/note/xorg/xrandr.txt
@@ -0,0 +1,34 @@
+
+## Tuxbook reset to solo screen
+
+xrandr --dpi 142 --fb 1920x1080 \
+ --output HDMI-1 --off \
+ --output eDP-1 \
+ --mode 1920x1080 --rate 60.01 \
+ --pos 0x0 \
+ --scale 1x1 \
+ --primary \
+
+
+## Tuxbook home 4k 40" dual-mon setup
+
+# TODO could fb be smaller?
+xrandr --dpi 157 --fb 9600x3600 \
+ --output HDMI-1 \
+ --mode 3840x2160 --rate 25 \
+ --pos 0x0 \
+ --scale 0.5x0.5 \
+ --primary \
+ --output eDP-1 \
+ --mode 1920x1080 --rate 60.01 \
+ --pos 1920x540 \
+ --scale 0.5x0.5 \
+
+
+## Try fix annoying app scaling issues
+
+ GDK_DPI_SCALE=1
+ GDK_SCALE=1
+ QT_AUTO_SCREEN_SCALE_FACTOR=1
+ QT_SCALE_FACTOR=0.6
+
diff --git a/src/main/lua/paisa-logs/DigHoustonLogs.lua b/src/main/lua/paisa-logs/DigHoustonLogs.lua
index 1bc8dbf..74be98a 100644
--- a/src/main/lua/paisa-logs/DigHoustonLogs.lua
+++ b/src/main/lua/paisa-logs/DigHoustonLogs.lua
@@ -40,8 +40,8 @@ function loadFilters( that )
-- { action = "drop", afterDate = "2024-01-31 23:59:59.999", },
- -- { action = "keep", level = "WARN", file = "BlockedThreadChecker",
- -- msgPattern = " blocked for %d%d%d+", stackPattern = "%.twimba%." },
+ -- { action = "keep",
+ -- msgPattern = "Connection ", stackPattern = "Connection " },
-- { action = "drop" },
{ action = "drop", level = "TRACE" },
diff --git a/src/main/lua/paisa-logs/PaisaLogParser.lua b/src/main/lua/paisa-logs/PaisaLogParser.lua
index f6ac0ce..fc4faa4 100644
--- a/src/main/lua/paisa-logs/PaisaLogParser.lua
+++ b/src/main/lua/paisa-logs/PaisaLogParser.lua
@@ -64,18 +64,26 @@ end
function LogParse:tryParseLogs()
+ self.numBrokenLogLines = 0
+ self.thisEntryIsBroken = false
while true do
self.line = io.read("l");
- if self.line==nil then -- EOF
- self:publishLogEntry();
+ if self.line == nil then -- EOF
+ self:publishLogEntry()
break;
end
--io.write( "\nBUF: ", self.line, "\n\n" );
--io.flush()
- if self.line:match("%d%d%d%d%-%d%d%-%d%d[ T]%d%d:%d%d:%d%d,%d%d%d ") then
+ if self.line:match("^%d%d%d%d%-%d%d%-%d%d[ T]%d%d:%d%d:%d%d,%d%d%d ") then
-- Looks like the beginning of a new log entry.
+ self.thisEntryIsBroken = false
+ self:initLogEntryFromLine();
+ elseif self.line:match("^%d%d:%d%d:%d%d[,.]%d%d%d %[") then
+ -- FUCK THIS SHIT!!
+ self.thisEntryIsBroken = true
+ self.numBrokenLogLines = self.numBrokenLogLines + 1
self:initLogEntryFromLine();
elseif self.line:match("^%s+at [^ ]") then
-- Looks like a line from exception stack
@@ -93,13 +101,18 @@ function LogParse:tryParseLogs()
-- Probably msg containing newlines.
self:appendLogMsg();
end
-
+ ::nextLine::
+ end
+ if self.numBrokenLogLines ~= 0 then
+ stderr:write("[WARN ] Skiped ".. self.numBrokenLogLines .." entries with broken dates\n")
end
end
function LogParse:initLogEntryFromLine()
- self:publishLogEntry();
+ if self.thisEntryIsBroken then return end
+
+ self:publishLogEntry()
local log = self:getOrNewLogEntry();
-- Try some alternative parsers
@@ -369,7 +382,7 @@ end
function LogParse:publishLogEntry()
local log = self.log
- if not log then
+ if not log or self.thisEntryIsBroken then
return -- nothing to do
end
if not log.raw then
diff --git a/src/main/paisa-nonslim/README.txt b/src/main/paisa-nonslim/README.txt
index 21cf57a..7ee49bd 100644
--- a/src/main/paisa-nonslim/README.txt
+++ b/src/main/paisa-nonslim/README.txt
@@ -20,8 +20,62 @@ Evtl für diese services den jssc als "provided" angeben.
&& PATH_TO_THE_ONLY_REAL_BROWSER="C:/Users/fankhauseand/.opt/FirefoxPortable-105.0.1/FirefoxPortable.exe" \
&& "${PATH_TO_THE_ONLY_REAL_BROWSER:?}" \
- `# Remaining builds` \
- https://jenkinspaisa-temp.tools.pnet.ch/job/SERVICE/job/SDCISA-15648-RemoveSlimPackaging-n1/ \
+ `# waiting for jenkins build ` \
+ `# waiting for feedback from rudins ` \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/colin/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ `# LastSuccessfull build at 20240919 ` \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/slarti/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/captain/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/megacamel/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/guide/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/allitnil/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/babelfish/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/barman/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/benjy/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/bentstick/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/blart/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/caveman/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/deep/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/drdan/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/hooli/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/jeltz/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/kwaltz/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/loon/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/magician/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/minetti/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/mown/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/poodoo/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/prosser/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/streetmentioner/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/towel/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/vannharl/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/vogon/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/vroom/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/zaphake/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/heimdall/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ `# LastSuccessfull build at 20240920 ` \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/thor/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/rob/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/pobble/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/nowwhat/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/zem/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/trillian/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/deep/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+ `# Just here to have them somewhere ` \
+ https://jenkinspaisa-temp.tools.pnet.ch/job/platform/job/SDCISA-15648-RemoveSlimPackaging-n2/ \
+
+
+ && for S in rob thor pobble colin nowwhat zem slarti captain megacamel guide allitnil babelfish barman benjy bentstick blart caveman deep drdan hooli jeltz kwaltz loon magician minetti mown poodoo prosser streetmentioner towel vannharl vogon vroom zaphake heimdall platform trillian deep;
+ do \
+ printf '%-20s%s\n' "$S" "$(/c/work/tmp/bin/JenkinsReBuild.exe --cookie "${COOKIE?}" --branch SDCISA-15648-RemoveSlimPackaging-n2 --service "$S" 2>&1)"; \
+ done \
+
+
+## TaskQueue
+
+- await feedback for "pobble" from sandro due to "flanian artifact missing"
+- await feedback for "thor" from sandro (20240919)
+- await feedback for "rob" from sandro (20240919)
## Installation
diff --git a/src/main/paisa-nonslim/foo.js b/src/main/paisa-nonslim/foo.js
index 2dd1847..8bc1ff3 100644
--- a/src/main/paisa-nonslim/foo.js
+++ b/src/main/paisa-nonslim/foo.js
@@ -265,6 +265,21 @@ Related:
function getJettyServiceNamesAsArray( app, onDone ){
setImmediate(onDone, null, [ /*TODO get via args/file */
+
+ /****** TryBuild early, because other depend on them ******/
+ //"platform",
+ //"slarti", "captain", "megacamel", "guide",
+ /****** "regular" builds ******/
+ //"allitnil", "babelfish", "barman", "benjy", "bentstick", "blart", "caveman", "colin",
+ //"deep", "drdan", "heimdall", "hooli", "jeltz", "kwaltz", "loon", "magician",
+ //"minetti", "mown", "nowwhat", "pobble", "poodoo", "prosser", "streetmentioner", "thor",
+ //"towel", "vannharl", "vogon", "vroom", "zaphake", "zem",
+ /****** Depends on 'slarti', 'captain' ******/
+ //"rob",
+ /****** Depends on 'slarti', 'megacamel' ******/
+ //"trillian",
+ /****** Depends on 'slarti', 'guide', 'trillian' ******/
+ //"deep",
]);
}
@@ -801,9 +816,7 @@ Related:
child.on("error", console.error.bind(console));
child.stderr.on("data", function( buf ){ log.write(buf); });
child.on("close", function( code, signal ){
- if( code === 1 && signal === null ){
- checkout(); /* try next remote/branch name */
- }else if( code !== 0 || signal !== null ){
+ if( code !== 0 || signal !== null ){
onDone(Error("code "+ code +", signal "+ signal));
}else{
onDone(null, null);
diff --git a/src/main/paisa-nonslim/patches/thor.patch b/src/main/paisa-nonslim/patches/thor.patch
new file mode 100644
index 0000000..4ad026d
--- /dev/null
+++ b/src/main/paisa-nonslim/patches/thor.patch
@@ -0,0 +1,22 @@
+
+--- a/pom.xml
++++ b/pom.xml
+@@ -7,7 +7,7 @@
+ <groupId>ch.post.it.paisa.service</groupId>
+ <!-- Caution: when changing the parent version number, also change the
+ platform.version below -->
+- <version>03.06.46.01-PR-388-SNAPSHOT</version>
++ <version>${j21.platform.version}</version>
+ </parent>
+
+
+--- a/pom.xml
++++ b/pom.xml
+@@ -17,7 +17,7 @@
+ <name>thor</name>
+ <properties>
+- <platform.version>03.06.46.01-PR-388-SNAPSHOT</platform.version>
++ <platform.version>${j21.platform.version}</platform.version>
+ <service.name>thor</service.name>
+ <service.port>9103</service.port>
+
diff --git a/src/main/paisa/JenkinsReBuild.c b/src/main/paisa/JenkinsReBuild.c
index af87f72..901b489 100644
--- a/src/main/paisa/JenkinsReBuild.c
+++ b/src/main/paisa/JenkinsReBuild.c
@@ -32,8 +32,10 @@
#define STR_QUOT(s) STR_QUOT_(s)
#define LOGDBG(...) fprintf(stderr, __VA_ARGS__)
#define LOGERR(...) fprintf(stderr, __VA_ARGS__)
+#define REGISTER /*no-op*/
#define FLG_isHelp (1<<0)
+#define FLG_printRspBodyAnyway (1<<1)
typedef struct App App;
@@ -44,7 +46,14 @@ struct App {
int mAGIC;
int flg;
int exitCode;
+ int httpRspCode;
+ char *serviceName;
+ char *branchName;
+ char *cookie;
+ char *rspBody;
+ int rspBody_cap, rspBody_end;
struct GarbageEnv **env;
+ struct Garbage_TlsClient **tlsClient;
void *envMem[SIZEOF_struct_GarbageEnv/sizeof(void*)];
};
@@ -68,23 +77,48 @@ static void printHelp( void ){
" \n"
" Fights annoying just-trigger-another-build workaround.\n"
" \n"
+ " Options:\n"
+ " \n"
+ " --service <str>\n"
+ " Service name in question (eg 'slarti').\n"
+ " \n"
+ " --branch <str>\n"
+ " Branch name in question (eg 'feature-SDCISA-42-foobar').\n"
+ " \n"
+ " --cookie <str>\n"
+ " This tool does not support any auth mechanism. A cookie header can\n"
+ " be provided here. For example one copied from an established\n"
+ " browser session or similar. This already works for some auth\n"
+ " mechanisms.\n"
+ " \n"
);
}
static int parseArgs( App*app, char**argv ){
+ assert(app->serviceName == NULL);
register int iA = 0;
nextArg:;
char *arg = argv[++iA];
if( arg == NULL ){ goto verify; }
if( !strcmp(arg, "--help") ){
app->flg |= FLG_isHelp; return 0;
+ }else if( !strcmp(arg, "--service") ){
+ app->serviceName = argv[++iA];
+ if( app->serviceName == NULL ){ LOGERR("EINVAL: %s needs value\n", arg); return-1; }
+ }else if( !strcmp(arg, "--branch") ){
+ app->branchName = argv[++iA];
+ if( app->branchName == NULL ){ LOGERR("EINVAL: %s needs value\n", arg); return-1; }
+ }else if( !strcmp(arg, "--cookie") ){
+ app->cookie = argv[++iA];
+ if( app->cookie == NULL ){ LOGERR("EINVAL: %s needs value\n", arg); return-1; }
}else{
LOGERR("EINVAL: %s\n", arg); return-1;
}
goto nextArg;
verify:
- //if( argc <= 1 ){ LOGERR("EINVAL: Zero-arg-nonsense. Tell me what you want please.\n"); return -1; }
+ if( app->serviceName == NULL ){ LOGERR("EINVAL: --service missing\n"); return -1; }
+ if( app->branchName == NULL ){ LOGERR("EINVAL: --branch missing\n"); return -1; }
return 0;
}
@@ -105,7 +139,8 @@ static void HttpReq_onRspHdr(
const struct Garbage_HttpMsg_Hdr*hdrs, int hdrs_cnt,
struct Garbage_HttpClientReq**req, void*app_
){
- //App*const app = assert_is_App(app_);
+ App*const app = assert_is_App(app_);
+ app->httpRspCode = rspCode;
if( rspCode != 200 ){
LOGDBG("%.*s %d %.*s\n", proto_len, proto, rspCode, phrase_len, phrase);
for( int i = 0 ; i < hdrs_cnt ; ++i ){
@@ -119,20 +154,61 @@ static void HttpReq_onRspHdr(
static void HttpReq_onRspBody(
const char*buf, int buf_len, struct Garbage_HttpClientReq**req, void*app_
){
- //App*const app = assert_is_App(app_);
- // TODO if( httpRspCode != 200 ){
+ App*const app = assert_is_App(app_);
+ if( app->httpRspCode != 200 ){
LOGDBG("%.*s", buf_len, buf);
- // TODO }
+ return;
+ }
+ if( app->flg & FLG_printRspBodyAnyway ){
+ LOGDBG("%.*s", buf_len, buf);
+ }
+ if( app->rspBody_cap - app->rspBody_end < buf_len ){
+ app->rspBody_cap += buf_len;
+ void *tmp = realloc(app->rspBody, app->rspBody_cap*sizeof*app->rspBody);
+ if( tmp == NULL ){ assert(!"TODO_0GgAAAF8AACMaAAA ENOMEM"); }
+ app->rspBody = tmp;
+ }
+ memcpy(app->rspBody + app->rspBody_end, buf, buf_len);
+ app->rspBody_end += buf_len;
}
static void HttpReq_onRspDone( struct Garbage_HttpClientReq**req, void*app_ ){
- LOGDBG("[DEBUG] TODO_FlsAAAwZAADIHgAA %s()\n", __func__);
+ App*const app = assert_is_App(app_);
+ if( app->flg & FLG_printRspBodyAnyway ){
+ LOGDBG("\n");/*fix broken server which deliver no LF at TEXT body end*/
+ }
+ assert(app->rspBody != NULL);
+ int const isFail = strstr(app->rspBody, "\"state\":\"failure\"") != NULL;
+ if( isFail ){
+ LOGDBG("[DEBUG] Build has FAILED\n");
+ }else{
+ LOGDBG("[DEBUG] Build has SUCCEEDED (likely)\n");
+ }
}
+static void TlsClientMentor_pushIoTask( void(*task)(void*arg), void*arg, void*app_ ){ assert(!"TODO_4WgAAI8UAACIdQAA"); }
+static void TlsClientMentor_onError( int eno, void*app_ ){ assert(!"TODO_gxsAAMspAABkYgAA"); }
+
+
static void run( void*app_ ){
+ REGISTER int err;
App*const app = assert_is_App(app_);
+ static char const*const peerHostname = "jenkinspaisa-temp.tools.pnet.ch";
+ assert(app->tlsClient == NULL);
+ static struct Garbage_TlsClient_Mentor tlsMentor = {
+ .pushIoTask = TlsClientMentor_pushIoTask,
+ .onError = TlsClientMentor_onError,
+ };
+ app->tlsClient = (*app->env)->newTlsClient(app->env,
+ &tlsMentor, app, &(struct Garbage_TlsClient_Opts){
+ .peerHostname = peerHostname,
+ //.mallocator = NULL,
+ //.socketMgr = NULL,
+ //.ioWorker = NULL,
+ }
+ );
struct Garbage_HttpClientReq **req = NULL;
static struct Garbage_HttpClientReq_Mentor httpMentor = {
.pushIoTask = HttpReq_pushIoTask,
@@ -142,16 +218,30 @@ static void run( void*app_ ){
.onRspDone = HttpReq_onRspDone,
};
assert(5*sizeof(void*) == sizeof httpMentor);
+ #define SPACE (url_cap - (it - url))
+ int const url_cap = 256;
+ char url[url_cap];
+ char *it = url;
+ err = snprintf(it, SPACE, "/job/"); it += err; assert(err == 5);
+ err = snprintf(it, SPACE, "%s", app->serviceName); it += err; assert(err == (signed)strlen(app->serviceName));
+ err = snprintf(it, SPACE, "/job/"); it += err; assert(err == 5);
+ err = snprintf(it, SPACE, "%s", app->branchName); it += err; assert(err == (signed)strlen(app->branchName));
+ err = snprintf(it, SPACE, "/lastBuild/pipeline-graph/tree"); it += err; assert(err == 30);
+ #undef SPACE
+ //LOGDBG("[DEBUG] GET %s\n", url);
req = (*app->env)->newHttpClientReq(app->env, &httpMentor, app,
&(struct Garbage_HttpClientReq_Opts){
//.mallocator = NULL,
- //.socketMgr = NULL,
+ .socketMgr = (*app->tlsClient)->asSocketMgr(app->tlsClient),
.mthd = "GET",
- .host = "127.0.0.1",
- .url = "/guguseli/gagageli",
- .port = 8081,
- //.hdrs = struct Garbage_HttpMsg_Hdr*,
- //.hdrs_cnt = int,
+ .host = peerHostname,
+ .url = url,
+ .port = 443,
+ .hdrs_cnt = (app->cookie == NULL) ? 0 : 1,
+ .hdrs = ((struct Garbage_HttpMsg_Hdr[]){{
+ .key = "Cookie", .key_len = 6,
+ .val = app->cookie, .val_len = (app->cookie == NULL ? 0 : strlen(app->cookie)),
+ }}),
});
(*req)->resume(req);
}
@@ -169,6 +259,7 @@ int main( int argc, char**argv ){
if( parseArgs(app, argv) ){ goto endFn; }
if( app->flg & FLG_isHelp ){ printHelp(); goto endFn; }
app->exitCode = 0;
+ //app->flg |= FLG_printRspBodyAnyway;
app->env = GarbageEnv_ctor(app->envMem, sizeof app->envMem);
(*app->env)->enqueBlocking(app->env, run, app);
(*app->env)->runUntilDone(app->env);