rluck.tcl at tip
Not logged in

File undroid/luck/rluck.tcl from the latest check-in


# 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}
    method      post
    static_args {api list}
    req_args    {}
    opt_args    {}
    result      raw
}

# 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}
    method      post
    static_args {api extlist}
    req_args    {template:}
    opt_args    {withtips}
    result      raw
}

# 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}
    method      post
    static_args {api generate}
    req_args    {template: include:}
    opt_args    {appfile: cmdline: appicon: winicon: passwd:}
    result      raw
}

set luck(resolve) {
    copy        generate
    description {resolve dependencies}
    static_args {api resolve}
}

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