LUCK

Lean Undroidwish Construction Kit

A by-product of undroidwish, see it in action in http://www.ch-werner.de/LUCK.html , the available binary templates in http://www.ch-werner.de/LUCK , and the source code in https://www.androwish.org/home/dir?ci=tip&name=undroid/luck .

undroidwish_image

Web based (CGI) script to make a taylored undroidwish, vanillawish or vanillatclsh from binaries which are searched in the same directory as the tclsh or wish executing this script. Additionally, prefabricated configurations are presented. These are searched like the binaries and additionally relative to the parent directory of this script.

In the first step, the user selects a prefabricated or uploaded configuration or a binary. In the second step, a selection of packages derived from the binary's ZIP is presented plus some other options such as ZIP password and output filename. The package selection and other options can be primed by the info from a prefabricated or uploaded configuration. In the last step the user can generate a new binary and configuration with only the selected packages and other options, which is downloaded as a file.

Currently supported/available platforms

The following table is a snapshot from 2021-06-18.

PlatformMachineRemarks
FreeBSDx86
Haikux86, x86_64undroidwish only
Illumosx86
Linuxx86, x86_64, arm, aarch64glibc and musl, wayland
MacOSXx86_64no builds for Catalina and newer
OpenBSDx86_64
Windowsx86, x86_64

REST interface

The CGI script is RESTful and can be used as a service from other Tcl scripts utilizing tcllib's rest package, e.g. to easily mass produce Tcl apps for a variety of platforms. Here is an example on how to read out information and make a binary:

# Demonstrate usage of LUCK RESTfully, requires a locally running LUCK service on port 8015

package require rest

set luck(list) {
    url http://localhost:8015/cgi-bin/luck.tcl description {list of available templates}
    result raw
    method post static_args {api list} req_args {} opt_args {}
}

# req_args:
#   -template   name of binary template, e.g. vanillawish-linux32
# opt_args:
#   -withtips   when present send alternating lines of extension name and description

set luck(extlist) {
    url http://localhost:8015/cgi-bin/luck.tcl description {list of extensions of given template}
    result raw
    method post static_args {api extlist} req_args {template:} opt_args {withtips}
}

# req_args:
#   -template   name of binary template, e.g. vanillawish-linux32
#   -include    list of extensions to be embedded
# opt_args:
#   -appfile    *.tcl (for app/main.tcl) or *.zip (must have main.tcl),
#               content must be base64 encoded
#   -cmdline    (undroidwish) additional startup arguments
#   -appicon    (undroidwish) BMP (24 bit RGB) icon,
#               content must be base64 encoded
#   -winicon    (Windows binaries) icon (*.ico) for executable,
#               content must be base64 encoded
#   -passwd     ZIP password

set luck(generate) {
    url http://localhost:8015/cgi-bin/luck.tcl description {generate a binary}
    result raw
    method post static_args {api generate} req_args {template: include: appfile:} opt_args {cmdline: appicon: winicon: passwd:}
}

# create REST interface
rest::create_interface luck

# list templates
puts "==== Templates ===="
puts -nonewline [luck::list]

# list extensions of vanillawish-win32.exe
puts "==== Extensions of vanillawish-win32.exe ===="
puts -nonewline [luck::extlist -template vanillawish-win32.exe]

# make tkbugz for win32 from a ZIP which contains main.tcl
# with the single line "source [info nameofexecutable]/tkbugz/tk_bugz.tcl"
set main_tcl_zip {
    UEsDBBQAAAAIAJVmp1I2IJT8MAAAADIAAAAIABwAbWFpbi50Y2xVVAkAA/oblWAL
    HJVgdXgLAAEE6AMAAAToAwAAK84vLUpOVYjOzEvLV8hLzE3NT0utSE0uLUlMykmN
    1S/JTipNrwJS8SBaryQ5hwsAUEsBAh4DFAAAAAgAlWanUjYglPwwAAAAMgAAAAgA
    GAAAAAAAAQAAAKSBAAAAAG1haW4udGNsVVQFAAP6G5VgdXgLAAEE6AMAAAToAwAA
    UEsFBgAAAAABAAEATgAAAHIAAAAAAA==
}
set f [open tkbugz.exe wb]
puts -nonewline $f \
    [luck::generate -template vanillawish-win32.exe \
         -include tkbugz -appfile $main_tcl_zip]
close $f

Most vanillatclsh-en from the web site contain a REST based TUI frontend called lucktui which is available in the luck package, e.g. by running vanillatclsh... builtin:luck/lucktui.tcl or vanillatclsh... builtin:lucktui for short. Here's a sample session as an ASCII screencast .

How to roll your own build service

  • fetch the relevant (or all) binary templates from http://www.ch-werner.de/LUCK
  • store these in one directory
  • execute vanillawish... builtin:LUCK with a vanillawish runnable on your platform; this starts a local tclhttpd on port 8015 and tries to invoke a web browser on its LUCK page
  • or execute vanillatclsh... builtin:lucktui with a vanillatclsh runnable on your platform; this presents the TUI with a local tclhttpd on port 8015
  • begin mass production of single file self contained Tcl/Tk apps; the world is your oyster!

LUCK(y) success story: with light speed to slow trains

The LUCKy steps to a train application: Try it, it is fun!

  1. Open the trains3.tcl wiki page , section "Code"
  2. Copy the Code snipped in the "Code" box by pressing to the small right icon on the upper-right corner of the big grey code box.
  3. Go to the LUCK(y) page: http://www.ch-werner.de/LUCK.html
  4. Select a *vanillawish* suitable for your platform, for example "vanillawish-win32.exe".
  5. Scroll down to the entry box titled "Application app/main.tcl" and paste the code snipped (Press Ctrl/Apple+v)
  6. Press button "generate binary". The binary is downloaded. Start the binary and enjoy the movie.