Author Topic: Scriptbasic Build Linux  (Read 995 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #30 on: November 29, 2018, 12:18:22 AM »
There seems to be a problem with curl::option using the AppImage version.

Code: Script BASIC
  1. ' Firefox Download Challenge (Script BASIC Version) by JRS.
  2.  
  3. INCLUDE curl.bas
  4.  
  5. FUNCTION EXTRACT(base, mask)
  6.   UNDEF MATCH
  7.   start = 1
  8.   match_idx = 2
  9.   SPLITA mask BY "*" TO patterns
  10.   FOR idx = 0 TO UBOUND(patterns) STEP 2
  11.     MATCH[match_idx, 1] = INSTR(base, patterns[idx], start)
  12.     start = MATCH[match_idx, 1]
  13.     MATCH[match_idx, 2] = INSTR(base, patterns[idx + 1], start)
  14.     start = MATCH[match_idx, 2]
  15.     MATCH[match_idx, 1] = MATCH[match_idx, 1] + LEN(patterns[idx])
  16.     MATCH[match_idx, 2] = MATCH[match_idx, 2] - MATCH[match_idx, 1]
  17.     MATCH[match_idx, 0] = MID(base, MATCH[match_idx, 1], MATCH[match_idx, 2])
  18.     match_idx += 2
  19.   NEXT
  20.   EXTRACT = UBOUND(patterns) + 1 / 2
  21. END FUNCTION
  22.  
  23.  
  24. ch = curl::init()
  25. curl::option(ch,"URL","https://www.mozilla.org/en-US/firefox/new/")
  26. wp = curl::perform(ch)
  27.  
  28. IF EXTRACT(wp, """*data-latest-firefox="*" data-esr-versions*<div id="other-platforms">*<li class="os_win64">*<a href="*"
  29.            class*""") THEN
  30.   PRINT "Downloading Latest 64Bit Firefox (",MATCH[2, 0],") for Windows.\n"
  31.   curl::option(ch,"FOLLOWLOCATION", 1)
  32.   curl::option(ch,"NOPROGRESS",0)
  33.   curl::option(ch,"FILE","Firefox_Setup-" & MATCH[2, 0] & ".exe")
  34.   curl::option(ch,"URL", MATCH[6, 0])
  35.   curl::perform(ch)
  36.   PRINTNL
  37.   PRINT "Firefox_Setup-" & MATCH[2, 0] & ".exe Downloaded ",FORMAT("%~##,###,###~ Bytes",curl::info(ch,"SIZE_DOWNLOAD")), _
  38.   " at ",FORMAT("%~##,###,###~ Bytes/Second",curl::info(ch,"SPEED_DOWNLOAD")),".\n"
  39. ELSE
  40.   PRINT "<< ERROR >>\n"
  41. END IF
  42.  
  43. curl::finish(ch)
  44.  


jrs@jrs-laptop:~/sb/abcc/LIKE$ sb ff_extract.sb
ff_extract.sb(25): error &H77:syntax error during checking the line and also noting that the syntax error so serious that none of the other syntax defintions can match the current line
ff_extract.sb(31): error &H77:syntax error during checking the line and also noting that the syntax error so serious that none of the other syntax defintions can match the current line
ff_extract.sb(32): error &H77:syntax error during checking the line and also noting that the syntax error so serious that none of the other syntax defintions can match the current line
ff_extract.sb(33): error &H77:syntax error during checking the line and also noting that the syntax error so serious that none of the other syntax defintions can match the current line
ff_extract.sb(34): error &H77:syntax error during checking the line and also noting that the syntax error so serious that none of the other syntax defintions can match the current line
ff_extract.sb(43): error &H77:syntax error during checking the line and also noting that the syntax error so serious that none of the other syntax defintions can match the current line
jrs@jrs-laptop:~/sb/abcc/LIKE$ scriba.JRS ff_extract.sb
Downloading Latest 64Bit Firefox (63.0.3) for Windows.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   134  100   134    0     0    592      0 --:--:-- --:--:-- --:--:--   592
100 42.3M  100 42.3M    0     0  21.5M      0  0:00:01  0:00:01 --:--:-- 27.2M

Firefox_Setup-63.0.3.exe Downloaded 44,396,080 Bytes at 22,547,526 Bytes/Second.
jrs@jrs-laptop:~/sb/abcc/LIKE$



Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #31 on: November 29, 2018, 02:41:22 AM »
I was able to get around the syntax errors by adding curl_ as a prefix to my commands.

Code: Script BASIC
  1. ' Firefox Download Challenge (Script BASIC Version) by JRS.
  2.  
  3. INCLUDE curl.bas
  4.  
  5. FUNCTION EXTRACT(base, mask)
  6.   UNDEF MATCH
  7.   start = 1
  8.   match_idx = 2
  9.   SPLITA mask BY "*" TO patterns
  10.   FOR idx = 0 TO UBOUND(patterns) STEP 2
  11.     MATCH[match_idx, 1] = INSTR(base, patterns[idx], start)
  12.     start = MATCH[match_idx, 1]
  13.     MATCH[match_idx, 2] = INSTR(base, patterns[idx + 1], start)
  14.     start = MATCH[match_idx, 2]
  15.     MATCH[match_idx, 1] = MATCH[match_idx, 1] + LEN(patterns[idx])
  16.     MATCH[match_idx, 2] = MATCH[match_idx, 2] - MATCH[match_idx, 1]
  17.     MATCH[match_idx, 0] = MID(base, MATCH[match_idx, 1], MATCH[match_idx, 2])
  18.     match_idx += 2
  19.   NEXT
  20.   EXTRACT = UBOUND(patterns) + 1 / 2
  21. END FUNCTION
  22.  
  23.  
  24. ch = curl::curl_init()
  25. curl::curl_option(ch,"URL","https://www.mozilla.org/en-US/firefox/new/")
  26. wp = curl::curl_perform(ch)
  27.  
  28. IF EXTRACT(wp, """*data-latest-firefox="*" data-esr-versions*<div id="other-platforms">*<li class="os_win64">*<a href="*"
  29.            class*""") THEN
  30.   PRINT "Downloading Latest 64Bit Firefox (",MATCH[2, 0],") for Windows.\n"
  31.   curl::curl_option(ch,"FOLLOWLOCATION", 1)
  32.   curl::curl_option(ch,"NOPROGRESS",0)
  33.   curl::curl_option(ch,"FILE","Firefox_Setup-" & MATCH[2, 0] & ".exe")
  34.   curl::curl_option(ch,"URL", MATCH[6, 0])
  35.   curl::curl_perform(ch)
  36.   PRINTNL
  37.   PRINT "Firefox_Setup-" & MATCH[2, 0] & ".exe Downloaded ",FORMAT("%~##,###,###~ Bytes",curl::curl_info(ch,"SIZE_DOWNLOAD")), _
  38.   " at ",FORMAT("%~##,###,###~ Bytes/Second",curl::curl_info(ch,"SPEED_DOWNLOAD")),".\n"
  39. ELSE
  40.   PRINT "<< ERROR >>\n"
  41. END IF
  42.  
  43. curl::curl_finish(ch)
  44.  

A problem still exists with the cURL module as it won't load due to a OpenSSL version conflict.


jrs@jrs-laptop:~/sb/abcc/LIKE$ sb -d ff_extract_ai.sb
Searching installed module header file 'curl.bas' ...
Checking installed module header file location '/tmp/.mount_sbsXS8pg/include/curl.bas' Result=OK
Including file '/tmp/.mount_sbsXS8pg/include/curl.bas'
dlopen failed.
dlerror message=/usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by /tmp/.mount_sbsXS8pg/module/curl.so)
(0): error &H10:The requested module can not be loaded.
jrs@jrs-laptop:~/sb/abcc/LIKE$ sudo apt-get install openssl
[sudo] password for jrs:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
openssl is already the newest version (1.1.1-1ubuntu2).
openssl set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
jrs@jrs-laptop:~/sb/abcc/LIKE$


Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #32 on: November 29, 2018, 07:55:40 AM »
I was able to get around the syntax errors by adding curl_ as a prefix to my commands.



Yeah, that's because the curl module interface file names the exported functions like that.  It was using a _custom_ bas file.  Another example of a module not set up to export a bas file. 

As far as the libcurl error, the appimage currently uses what is on the system as opposed to including the lib.

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #33 on: November 29, 2018, 08:28:45 AM »
Creating a PROPER AppImage requires patching and/or compiling custom libraries, like libcurl.  Not going down that path, so AppImages are off the table unless SOMEONE ELSE wants to tackle this...

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #34 on: November 29, 2018, 08:55:21 AM »
It was nice concept but not worth investing anymore time into.

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #35 on: November 29, 2018, 09:39:35 AM »
I'm using your FF curl code to test, and MATCH[6, 0] is returning the entire page instead of the download link.

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #36 on: November 29, 2018, 10:16:13 AM »
I've just started replacing my old SB Linux install with the new build. I will be testing each extension module with my test code. I will be back to you with my results.


Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #37 on: November 29, 2018, 11:10:22 AM »
What version of Ubuntu are you running?

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #38 on: November 29, 2018, 11:14:04 AM »
Ubuntu 16.04.5 LTS

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #39 on: November 29, 2018, 11:33:57 AM »
My build or your cURL extension source works fine on Ubuntu 18.10.


jrs@jrs-laptop:~/sb/abcc/LIKE$ scriba ff_extract_ai.sb
Downloading Latest 64Bit Firefox (63.0.3) for Windows.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   134  100   134    0     0    507      0 --:--:-- --:--:-- --:--:--   507
100 42.3M  100 42.3M    0     0  22.0M      0  0:00:01  0:00:01 --:--:-- 34.0M

Firefox_Setup-63.0.3.exe Downloaded 44,396,080 Bytes at 23,086,885 Bytes/Second.
jrs@jrs-laptop:~/sb/abcc/LIKE$


I'm renaming my copy of scriba to sb. The AppImage thing spoiled me.  :D
« Last Edit: November 29, 2018, 11:55:59 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #40 on: November 29, 2018, 12:14:16 PM »
The next module I will be pushing to the SB-DEV sandbox that meets the non-GUI requirement will be the SBT extension module. This allows you to run SB threads independently or as a RUN / EVAL process. I need to bring it to SB build engine standards before the push.

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #41 on: November 29, 2018, 12:23:00 PM »
My build or your cURL extension source works fine on Ubuntu 18.10.

It's not the Curl module, it's the EXTRACT function returning more than it should with MATCH[6, 0].  I'm using the example you posted in this thread.

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #42 on: November 29, 2018, 12:35:26 PM »
If I use your version that uses LIKE instead of your EXTRACT function, it works fine....

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #43 on: November 29, 2018, 12:54:06 PM »
This code works fine on my box using your source to build scriba, curl.so and curl.bas.

Code: Script BASIC
  1. ' Firefox Download Challenge (Script BASIC Version) by JRS.
  2.  
  3. INCLUDE curl.bas
  4.  
  5. FUNCTION EXTRACT(base, mask)
  6.   UNDEF MATCH
  7.   start = 1
  8.   match_idx = 2
  9.   SPLITA mask BY "*" TO patterns
  10.   FOR idx = 0 TO UBOUND(patterns) STEP 2
  11.     MATCH[match_idx, 1] = INSTR(base, patterns[idx], start)
  12.     start = MATCH[match_idx, 1]
  13.     MATCH[match_idx, 2] = INSTR(base, patterns[idx + 1], start)
  14.     start = MATCH[match_idx, 2]
  15.     MATCH[match_idx, 1] = MATCH[match_idx, 1] + LEN(patterns[idx])
  16.     MATCH[match_idx, 2] = MATCH[match_idx, 2] - MATCH[match_idx, 1]
  17.     MATCH[match_idx, 0] = MID(base, MATCH[match_idx, 1], MATCH[match_idx, 2])
  18.     match_idx += 2
  19.   NEXT
  20.   EXTRACT = UBOUND(patterns) + 1 / 2
  21. END FUNCTION
  22.  
  23.  
  24. ch = curl::curl_init()
  25. curl::curl_option(ch,"URL","https://www.mozilla.org/en-US/firefox/new/")
  26. wp = curl::curl_perform(ch)
  27.  
  28. IF EXTRACT(wp, """*data-latest-firefox="*" data-esr-versions*<div id="other-platforms">*<li class="os_win64">*<a href="*"
  29.            class*""") THEN
  30.   PRINT "Downloading Latest 64Bit Firefox (",MATCH[2, 0],") for Windows.\n"
  31.   curl::curl_option(ch,"FOLLOWLOCATION", 1)
  32.   curl::curl_option(ch,"NOPROGRESS",0)
  33.   curl::curl_option(ch,"FILE","Firefox_Setup-" & MATCH[2, 0] & ".exe")
  34.   curl::curl_option(ch,"URL", MATCH[6, 0])
  35.   curl::curl_perform(ch)
  36.   PRINTNL
  37.   PRINT "Firefox_Setup-" & MATCH[2, 0] & ".exe Downloaded ",FORMAT("%~##,###,###~ Bytes",curl::curl_info(ch,"SIZE_DOWNLOAD")), _
  38.   " at ",FORMAT("%~##,###,###~ Bytes/Second",curl::curl_info(ch,"SPEED_DOWNLOAD")),".\n"
  39. ELSE
  40.   PRINT "<< ERROR >>\n"
  41. END IF
  42.  
  43. curl::curl_finish(ch)
  44.  


jrs@jrs-laptop:~/sb/abcc/LIKE$ scriba -v
ScriptBasic v2.1
Variation >>STANDARD<< build 1
Magic value 859037496
Node size is 24
Extension interface version is 11
Compilation: Nov 28 2018 15:18:40
jrs@jrs-laptop:~/sb/abcc/LIKE$ scriba ff_extract_ai.sb
Downloading Latest 64Bit Firefox (63.0.3) for Windows.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   134  100   134    0     0    606      0 --:--:-- --:--:-- --:--:--  1595
100 42.3M  100 42.3M    0     0  19.3M      0  0:00:02  0:00:02 --:--:-- 24.0M

Firefox_Setup-63.0.3.exe Downloaded 44,396,080 Bytes at 20,272,182 Bytes/Second.
jrs@jrs-laptop:~/sb/abcc/LIKE$


If you're still having problems with MATCH[6,0], copy the code from a quote of the post or let me know and I'll attach the script. Note the match pattern has an embedded line feed and specific space characters following it.
« Last Edit: November 29, 2018, 03:09:16 PM by John »

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #44 on: November 29, 2018, 03:33:35 PM »
I think it was a cache issue, because it's working now.....go figure....

Back to AppImage, now that this is working:  Instead of an AppImage, have you considered a Docker vm?  This way all the libraries would be consistent without the craziness that accomplishing the same with an AppImage would entail....just a thought.

Learn Docker in 12 Minutes.  YouTube video....