Δημοσιεύτηκε: 09 Ιουν 2012, 21:17
- Κώδικας: Επιλογή όλων
-- *************/******************************************************************************
-- Lexmark Research & Development
-- 4900 Series Linux Installer Script Powered by Nixstaller
--
--
-- *******************************************************************************************
--
-- Think of localization!!!
-- How to sense-survive-recover low disk space ?
-- trap wm delete_event
function Init()
print("TRACKING IDENT = 170209")
g_product_code = '0000000'
g_usetar = false
if is_process_running('synaptic') then
gui.warnbox('Please close the currently running synaptics package manager program, then run again this installer.')
os.exit(1)
end
if is_process_running('apt-get') then
gui.warnbox('Please close the currently running apt-get program, then run again this installer.')
os.exit(1)
end
g_IsNcursesBased = is_ncurses_based()
g_processsor_speed,g_ram_size,g_bfused,g_hd_avail,g_tmp_avail,g_usrlocal_avail = get_systems_asset()
if check_lexmark_requirement(g_processsor_speed,g_ram_size,g_bfused,g_hd_avail,g_tmp_avail,g_usrlocal_avail) == false then
gui.warnbox('Your system does not meet at least one these mininum requirements:\n\n 500MHz CPU\n 256MB RAM\n 300MB harddisk space.')
-- os.exit(1)
end
--g_jre_ident = 'jre1.6.0_07.bin'
--g_jre_folder = 'jre1.6.0_07'
g_yarlog_ident = 'lexmark_08z_series_driver'
g_yarlog_ident_orig = 'lexmark-08z-series-driver'
--g_jre_path_list = {'/usr/local/jre1.6.0_07'} -- add more jre versions here
g_mult_dev_list = {}
g_PrinterModel = 'Lexmark Printer'
g_mysecurepath = get_uniq_dirname( os.getenv("HOME") )
-- os.mkdir(g_mysecurepath)
-- gui.msgbox(g_mysecurepath)
-- install.destdir = get_uniq_dirname(os.getenv("HOME"))
-- we have more chances of space in HOME ?!
install.destdir = install.getpkgdir()
the_install_dir = install.destdir
g_lpadmin_path_list = {'/usr/sbin/lpadmin','usr/bin/lpadmin'} -- add more candidates here
g_lpadmin_exe = ''
-- |========================================================================|
-- | Creating our custom screens |
-- |========================================================================|
MyWelcomeScreen = install.newscreen('')
MyReadMeScreen = install.newscreen('Read me')
--[[ Use the prebuilt LicenseScreen ]]
MyLicenseScreen = install.newscreen('License agreement') -- Always roll your own!!
MyInstallScreen = install.newscreen('Files are being installed')
MyConnectUsbCableScreen = install.newscreen('Connect USB Cable')
MySelectPrinterScreen = install.newscreen('Select Printer')
MyCreateQueueScreen = install.newscreen('Create Queue')
MyCongratulationsScreen = install.newscreen('Congratulations!')
MyRegisterScreen = install.newscreen('Product Registration')
MyRegisterScreen2 = install.newscreen('Product Registration')
MyCongratulationsScreen2 = install.newscreen('Congratulations!')
-- =========================================================================|
-- |=====================================================================|
-- |putting widgets to our custom screens |
-- |=====================================================================|
-- *******************
-- MyWelcomeScreen
-- *******************
MyWelcomeScreen_group = MyWelcomeScreen:addgroup()
MyWelcomeScreen_group:addimage( install.extrafilespath('printer.png') )
MyWelcomeScreen_group:addlabel('This will install the Lexmark Z2400/3600-4600/7600/5600-6600/4900/5000 Series Linux drivers in your computer. \n\nAfter installation, you will be guided in configuring your printer for use in your computer. \n\nDo not connect the printer to your computer yet! The setup utility will prompt you to connect your printer at the appropriate time.')
-- *******************
-- MyReadMeScreen
-- *******************
MyReadMeScreen_ReadMeTextField = MyReadMeScreen:addtextfield("",true)
MyReadMeScreen_ReadMeTextField:load( install.extrafilespath('readme') )
-- ****************************
-- MyLicenseScreen
-- ****************************
MyLicenseScreen_screen = MyLicenseScreen:addtextfield("",true)
MyLicenseScreen_screen:load(install.extrafilespath('license'))
MyLicenseScreen_check = MyLicenseScreen:addcheckbox("",{ "I agree to this license agreement" })
-- ****************************
-- MyInstallScreen
-- ****************************
MyInstallScreen_progressbar = MyInstallScreen:addprogressbar("Progress")
MyInstallScreen_statlabel = MyInstallScreen:addlabel("")
MyInstallScreen_output = MyInstallScreen:addtextfield("", true)
MyInstallScreen_output:follow(true)
-- ******************************
-- MyConnectUsbCableScreen
-- ******************************
MyConnectUsbCableScreen:addlabel('Connect the USB cable from your printer to any available USB port on your computer')
MyConnectUsbCableScreen_group = MyConnectUsbCableScreen:addgroup()
MyConnectUsbCableScreen_detector = MyConnectUsbCableScreen_group:addlabel('')
MyConnectUsbCableScreen_group:addimage('files_extra/usbconnect.png')
MyConnectUsbCableScreen_group:addlabel('')
-- ************************
-- MySelectPrinterScreen
-- ************************
MySelectPrinterScreen:addlabel('Select the printer you want to use.\n')
-- MySelectPrinterScreen_USBAttachedPrinters = MySelectPrinterScreen:addmenu("Detected Prenters:",{} ) -- cannot be!!
-- *********************
-- MyCreateQueueScreen
-- *********************
MyCreateQueueScreen_MkQueueScreenInfo = MyCreateQueueScreen:addlabel("We will now create a print queue for your printer. Enter the appropriate information in the fields below and press \"Next\" to continue.")
MyCreateQueueScreen_MkQueueScreenLabel1 = MyCreateQueueScreen:addlabel("Printer Name:")
MyCreateQueueScreen_MkQueuePrinterName = MyCreateQueueScreen:addinput("","",34)
MyCreateQueueScreen_MkQueueScreenLabel2 = MyCreateQueueScreen:addlabel("Description (optional):")
MyCreateQueueScreen_MkQueuePrinterDesc = MyCreateQueueScreen:addinput("","",95)
-- *******************
-- MyRegisterScreen
-- *******************
MyRegisterScreen:addlabel(' Product Registration')
-- MyRegisterScreen_screen = MyRegisterScreen:addtextfield("",true)
-- MyRegisterScreen_screen:load(install.extrafilespath('register'))
MyRegisterScreen_label = MyRegisterScreen:addlabel('')
MyRegisterScreen_check = MyRegisterScreen:addcheckbox("",{ "Register now" })
-- ********************
-- MyRegisterScreen2
-- *******************
-- MyRegisterScreen2_screen = MyRegisterScreen2:addtextfield("",true)
-- MyRegisterScreen2_screen:load(install.extrafilespath('register'))
MyRegisterScreen2_label = MyRegisterScreen2:addlabel('')
-- MyRegisterScreen2:addlabel('Registration URL:\nhttps://www.lexmarkregister.com/registration/ProductSelector.aspx')
-- ==============================|
-- MyCongratulationsScreen |
-- ==============================|
MyCongratulationsScreen:addlabel(' Congratulations!')
MyCongratulationsScreen_lbl = MyCongratulationsScreen:addlabel('')
MyCongratulationsScreen2_lbl = MyCongratulationsScreen2:addlabel('')
MyCongratulationsScreen_cb = MyCongratulationsScreen:addlabel('')
-- =====================================================|
-- Event handlers for our custom screen's widgets |
-- =====================================================|
function MyConnectUsbCableScreen_detector:verify()
--
-- g_mult_dev_list is a list of hash of this form
-- table['Lexmark xxx Series'] = 'usb://Lexmark/xxxx'
--
g_mult_dev_list = enum_attached_printers()
local dev_list = {} -- this one is a plain list of Friendly Names
for key,val in pairs(g_mult_dev_list) do
table.insert(dev_list,key)
end
local dev_list_count = table.getn(dev_list)
if dev_list_count == 0 then
gui.msgbox('Connect the printer to the PC with the USB cable.')
return false
else
MySelectPrinterScreen_USBAttachedPrinters = MySelectPrinterScreen:addmenu("Detected Printers:",dev_list )
return true
end
end
function MyCreateQueueScreen_MkQueuePrinterName:verify()
local szQueueName = MyCreateQueueScreen_MkQueuePrinterName:get()
if ValidateQueueName(szQueueName) == false then
if #szQueueName ~= 0 then
local szValidatedQueueName = ValidateString(szQueueName)
MyCreateQueueScreen_MkQueuePrinterName:set(szValidatedQueueName)
end
return false
else
-- must transform queue name by replacing ' ' with '_'
-- must switch between yaris or logan ppd
local x_ppdfile = 'undefined.ppd'
local selected_friendly_name = MySelectPrinterScreen_USBAttachedPrinters:get()
local uri = g_mult_dev_list[selected_friendly_name]
if string.find(uri,'usb://Lexmark/4900') then
x_ppdfile = '/usr/lexinkjet/08zero/etc/lx4900.ppd'
g_PrinterModel = 'Lexmark 4900 Series'
-- elseif string.find(uri,'usb://Lexmark/Z2300') then
-- x_ppdfile = '/usr/lexinkjet/lxk08/etc/lxZ2300.ppd'
-- g_PrinterModel = 'Lexmark Z2300 Series'
elseif string.find(uri, 'usb://Lexmark/Z2400') then
x_ppdfile = '/usr/lexinkjet/08zero/etc/lxZ2400.ppd'
g_PrinterModel = 'Lexmark Z2400 Series'
elseif string.find(uri, 'usb://Lexmark/3600') then
x_ppdfile = '/usr/lexinkjet/08zero/etc/lx36-46.ppd'
g_PrinterModel = 'Lexmark 3600-4600 Series'
elseif string.find(uri, 'usb://Lexmark/7600') then
x_ppdfile = '/usr/lexinkjet/08zero/etc/lx7600.ppd'
g_PrinterModel = 'Lexmark 7600 Series'
elseif string.find(uri, 'usb://Lexmark/5600') then
x_ppdfile = '/usr/lexinkjet/08zero/etc/lx56-66.ppd'
g_PrinterModel = 'Lexmark 5600-6600 Series'
elseif string.find(uri, 'usb://Lexmark/5000') then
x_ppdfile = '/usr/lexinkjet/08zero/etc/lx5000.ppd'
g_PrinterModel = 'Lexmark 5000 Series'
else
x_ppdfile = ''
g_PrinterModel = ''
end
if os.fileexists(x_ppdfile) then
local queuename = MyCreateQueueScreen_MkQueuePrinterName:get()
DoPostInstall(uri,queuename,x_ppdfile)
else
-- something went wrong during the installation !!!
gui.warnbox('Installation error. ' .. x_ppdfile .. ' is not found.')
do_clean_up()
os.exit(1)
end
return true
end
end
function MyCreateQueueScreen_MkQueuePrinterName:datachanged()
local content = MyCreateQueueScreen_MkQueuePrinterName:get()
local content2 = space_remove(content)
if content2~=nil and #content2 == 0 then -- programming is like condom
install.lockscreen(false,false,true)
else
install.lockscreen(false, false, false)
end
end
function MyCongratulationsScreen_cb:verify()
cmdstring = ""
--[[if MyCongratulationsScreen_cb:get('Launch printer maintenance utility') == true then
print('launching the launcher')
if g_IsNcursesBased == true then
-- os.execute('/usr/bin/lexijtools')
-- os.execute(install.destdir .. '/launcher')
-- os.execute(install.destdir .. '/launcher noshow')
-- os.execute('echo "launch lexijtools in the command line"')
else
os.execute(install.destdir .. '/launcher --maintgui')
cmdstring = " --maintgui";
end
-- utils.opendoc('/usr/bin/lexijtools')
-- wait_until_maintgui_is_up()
end]]--
if MyRegisterScreen_check:get('Register now') == true then
--browsers = shell_execute('/tmp/lsbrowser -l')
--browser = null
if g_PrinterModel == 'Lexmark 4900 Series' then
g_product_code = '4441W21' -- this is sequoia product code for web register
-- elseif g_PrinterModel == 'Lexmark Z2300 Series' then
-- g_product_code = '4119001'
elseif g_PrinterModel == 'Lexmark Z2400 Series' then
g_product_code = '4116W01'
elseif g_PrinterModel == 'Lexmark 3600-4600 Series' then
g_product_code = '4438001'
elseif g_PrinterModel == 'Lexmark 7600 Series' then
g_product_code = '4440W21'
elseif g_PrinterModel == 'Lexmark 5600-6600 Series' then
g_product_code = '4437W02'
elseif g_PrinterModel == 'Lexmark 5000 Series' then
g_product_code = '4432001'
else
g_product_code = ''
end
--[[if #browsers > 0 then
for key,val in pairs(browsers) do
browser = val
if string.find(val,'firefox') then
break
end
end
end]]--
if os.fileexists('/usr/dt/bin/netscape') then
browser = '/usr/dt/bin/netscape'
elseif os.fileexists('/opt/NSCPcom/netscape') then
browser = '/opt/NSCPcom/netscape'
elseif os.fileexists('/usr/bin/netscape') then
browser = '/usr/bin/netscape'
elseif os.fileexists('/usr/X11R6/bin/netscape') then
browser = '/usr/X11R6/bin/netscape'
elseif os.fileexists('/usr/X11R6/bin/netscape6') then
browser = '/usr/X11R6/bin/netscape6'
elseif os.fileexists('/usr/bin/konqueror') then
browser = '/usr/bin/konqueror'
elseif os.fileexists('/opt/kde3/bin/konqueror') then
browser = '/opt/kde3/bin/konqueror'
elseif os.fileexists('/usr/bin/mozilla') then
browser = '/usr/bin/mozilla'
elseif os.fileexists('/usr/sfw/bin/mozilla') then
browser = '/usr/sfw/bin/mozilla'
elseif os.fileexists('/usr/X11R6/bin/mozilla') then
browser = '/usr/X11R6/bin/mozilla'
elseif os.fileexists('/usr/bin/galeon') then
browser = '/usr/bin/galeon'
elseif os.fileexists('/usr/bin/firefox') then
browser = '/usr/bin/firefox'
elseif os.fileexists('/opt/gnome/bin/galeon') then
browser = '/opt/gnome/bin/galeon'
else
browser = ''
end
if browser~=null then
os.chdir('/') --the holy grail we've been looking for
os.execute(browser .. ' "http://www.lexmark.com/MD/?func=newreg&lang=0&ctry=00000409&os=7&src=2&prtr="' .. g_product_code .. ' &')
--os.execute('/tmp/launcher --register ' .. browser .. " " .. g_product_code)
--cmdstring = cmdstring .. " --register"
end
return true
end
-- os.execute(install.destdir .. '/launcher' .. cmdstring)
end
function MyLicenseScreen_check:datachanged()
install.lockscreen(false,false, not MyLicenseScreen_check:get('I agree to this license agreement'))
end
-- =======================================================|
-- Instantiation event handlers for screens |
-- =======================================================|
function MyWelcomeScreen:activate()
install.lockscreen(false,true,false)
end
function MyReadMeScreen:activate()
install.lockscreen(false,false,false)
end
function MyInstallScreen:activate()
-- Disable Back and Next buttons
install.lockscreen(false, true, true)
install.startinstall(
function (s) MyInstallScreen_statlabel:set(s) end,
function (s) MyInstallScreen_progressbar:set(s) end,
function (s) MyInstallScreen_output:add(s) end,
true
)
-- Re-enable Next button, lock Back and Cancel buttons
install.lockscreen(true, true, false)
end
function MyCongratulationsScreen2:activate()
install.lockscreen(true,true,false) -- make same with gtk version
MyCongratulationsScreen2_lbl:set("You are now ready to start using your " .. g_PrinterModel .. " printer.\n\n\n\nUse the printer maintenance utility to clean and align your cartridges to get quality prints.\n\nYou can launch any time the printer maintenance utility in a terminal.")
end
function MyCongratulationsScreen:activate()
-- DoPostInstall() here?!
MyCongratulationsScreen_lbl:set('You are now ready to start using your ' .. g_PrinterModel .. ' printer.')
install.lockscreen(true,true,false) -- jeremy request to disable Back,Pie requested to disable Cancel
do_clean_up()
--[[if os.fileexists('/usr/bin/lex4900ijtools') then
if os.chdir('/usr/bin')==true then
print('success chdir /usr/bin')
else
print('cannot chdir /usr/bin')
end
else
print('missing lex4900ijtools')
end]]--
end
function MySelectPrinterScreen:activate()
install.lockscreen(true, true, false) -- Re-enable Next button, lock Back and Cancel buttons
end
function MyConnectUsbCableScreen:activate()
-- can no longer do this here...
-- USBAttachedPrinters = MySelectPrinterScreen:addmenu("Detected Printers",{'Lexmark Printer 1','Lexmark Printer 2'} )
end
function MyCreateQueueScreen:canactivate()
for _,vv in pairs(g_lpadmin_path_list) do
if os.fileexists(vv) then
g_lpadmin_exe = vv;
break
end
end
if os.fileexists(g_lpadmin_exe) then
return true
else
return false
end
end
function MyCreateQueueScreen:activate()
--- 000
local selected_friendly_name = MySelectPrinterScreen_USBAttachedPrinters:get()
local uri = g_mult_dev_list[selected_friendly_name]
if string.find(uri,'usb://Lexmark/4900') then
g_PrinterModel = 'Lexmark 4900 Series'
elseif string.find(uri,'usb://Lexmark/Z2400') then
g_PrinterModel = 'Lexmark Z2400 Series'
elseif string.find(uri,'usb://Lexmark/3600') then
g_PrinterModel = 'Lexmark 3600-4600 Series'
elseif string.find(uri,'usb://Lexmark/7600') then
g_PrinterModel = 'Lexmark 7600 Series'
elseif string.find(uri,'usb://Lexmark/5600') then
g_PrinterModel = 'Lexmark 5600-6600 Series'
elseif string.find(uri,'usb://Lexmark 5000') then
g_PrinterModel = 'Lexmark 5000 Series'
end
--- 000
print('SELECTION ==> ' .. g_PrinterModel)
-- Disable Next button
install.lockscreen(false, false, true)
-- check if a queue has been auto-created for the selected uri
-- and auto put this queue name into the box
local selected_friendly_name = MySelectPrinterScreen_USBAttachedPrinters:get()
local selected_uri = g_mult_dev_list[selected_friendly_name]
install.executeasroot('/usr/local/lexmark/08zero/bin/.scripts/lsusbdevice -u ' .. '"' .. selected_uri .. '"' .. ' -o ' .. '"%q" > ' .. the_install_dir .. '/auto_queue' )
local Qtemp = shell_invoke("cat " .. the_install_dir .. "/auto_queue" )
local Q = ''
if Qtemp ~= nil then
if Qtemp[1] ~= nil then -- wowwwww.....
Q = Qtemp[1].out
end
end
if Q~=nil and #Q > 0 then
print('auto Q in ' .. kernel_release[1].out .. ' = ' .. Q)
-- Put the auto queue name in the box but user can still edit it
local qq = space_replace(Q)
if #qq > 0 then
MyCreateQueueScreen_MkQueuePrinterName:set(qq)
install.lockscreen(false,false,false)
else
install.lockscreen(false,false,true)
end
else
local qval = 'My' .. '_' .. space_replace(g_PrinterModel)
if #qval > 0 then
MyCreateQueueScreen_MkQueuePrinterName:set(qval)
install.lockscreen(false,false,false)
else
install.lockscreen(false,false,true)
end
end
end
function MyLicenseScreen:activate()
if MyLicenseScreen_check:get('I agree to this license agreement') == true then
install.lockscreen(false,false,false)
else
install.lockscreen(false,false,true)
end
end
function MyRegisterScreen:activate()
MyRegisterScreen_label:set('Benefits may include: *\n - Exclusive discounts on ink\n - More efficient warranty support\n - Critical software update notification\n\nThank you for purchasing your ' .. g_PrinterModel .. ' printer. Click the "Register now" checkbox if you want to register your new product. This requires that you are connected to the Internet.\n\n* Benefits may vary and will not be available in all countries.')
end
function MyRegisterScreen2:activate()
MyRegisterScreen2_label:set('Benefits may include: *\n - Exclusive discounts on ink\n - More efficient warranty support\n - Critical software update notification\n\nThank you for purchasing your ' .. g_PrinterModel .. ' printer. To register your new product, run the printer maintenance utility and click the "Register Product" link. This requires that you are connected to the Internet.\n\n* Benefits may vary and will not be available in all countries.')
end
-- **************************************************
-- The Post Installation creates print queue
--
-- **************************************************
function DoPostInstall(uri,queuename,ppdfile)
-- gui.msgbox(queuename)
-- gui.msgbox(ppdfile)
-- gui.msgbox(uri) -- special chars probs with display
for _,vv in pairs(g_lpadmin_path_list) do
if os.fileexists(vv) then
g_lpadmin_exe = vv;
break
end
end
local the_queuename = ValidateString(queuename)
local the_queuedesc = ValidateString(MyCreateQueueScreen_MkQueuePrinterDesc:get())
if os.fileexists(g_lpadmin_exe) then
install.executeasroot(g_lpadmin_exe .. ' -p ' .. '"' .. the_queuename .. '"' .. ' -v ' .. uri .. ' -P ' .. ppdfile .. ' -E' .. ' -D ' .. '"' .. the_queuedesc .. '"')
end
end
-- ======================================|
-- Checking for system compatibility |
-- ======================================|
kernel_release = shell_invoke("uname -r") -- 2.6.24-gentoo-r8
kernel_name = shell_invoke("uname -s") -- Linux
kernel_name[1].out = string.lower(kernel_name[1].out)
if kernel_name[1].out ~= 'linux' then
gui.warnbox(kernel_name[1].out .. " is not officially supported.")
end
rpm_status = os.execute("(rpm --version) < /dev/null > /dev/null 2>&1")
dpkg_status = os.execute("(dpkg --version) < /dev/null > /dev/null 2>&1")
if rpm_status ~= 0 and dpkg_status ~= 0 then
-- if true then
-- gui.warnbox("This particular Linux distribution does not have a compatible package manager (dpkg or rpm) that is needed for this installer. This installation will exit.")
-- do_clean_up()
-- os.exit(1)
g_usetar = true
end
-- Installation screens to show (in given order). Custom screens should be placed here.
--
if g_IsNcursesBased == true then
install.screenlist =
{
MyWelcomeScreen,
MyReadMeScreen,
MyLicenseScreen, -- always roll your own
MyInstallScreen,
MyConnectUsbCableScreen,
MySelectPrinterScreen,
MyCreateQueueScreen,
MyRegisterScreen2,
MyCongratulationsScreen2
}
else
install.screenlist =
{
MyWelcomeScreen,
MyReadMeScreen,
MyLicenseScreen, -- always roll your own
MyInstallScreen,
MyConnectUsbCableScreen,
MySelectPrinterScreen,
MyCreateQueueScreen,
MyRegisterScreen,
MyCongratulationsScreen
}
end
end
function Install()
-- This function is called as soon as the 'InstallScreen' is shown.
-- How many 'steps' the installation has (used to divide the progressbar). Since both
-- install.extractfiles and install.generatepkg count as one step, we start with 2.
-- install.setstepcount(2)
install.askrootpw()
-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
-- get ready to check the extracted files after this call..
--
--
--
-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
-- This function extracts the files to 'install.destdir'.
install.extractfiles() -- we need to extract files first to determine what the installer has
--install.executeasroot('cp ' .. install.destdir .. '/launcher /tmp/')
--install.executeasroot('cp ' .. install.destdir .. '/lsbrowser /tmp/')
--local user = shell_execute('whoami')
--install.executeasroot('chown ' .. user[1] .. ':' .. user[1] .. ' /tmp/launcher')
--install.executeasroot('chown ' .. user[1] .. ':' .. user[1] .. ' /tmp/lsbrowser')
install_status = 0
install_type = "undefined"
if g_usetar == true then
print('go tar!')
MyInstallScreen_output:add("Using tar installation")
install_type = "tar"
install_status = do_tar_install()
else
rpm_list_count = 0
deb_list_count = 0
-- look for .deb and .rpm packages
-- the noise in ncurses, eliminated by a touched of zen..but other solutions
-- are possible...
if os.execute("ls " .. install.destdir .. " | grep '\.rpm' > " .. the_install_dir .. "/dx_RPM_list") == 0 then
-- becuase we background
while os.fileexists(the_install_dir .. '/dx_RPM_list') == false do
-- wait until the file exists...
end
rpm_list = shell_invoke("cat " .. the_install_dir .. "/dx_RPM_list")
rpm_list_count = table.getn(rpm_list)
end
if os.execute("ls " .. install.destdir .. " | grep '\.deb' > " .. the_install_dir .. "/dx_DEB_list") == 0 then
-- becuase we background
while os.fileexists(the_install_dir .. '/dx_DEB_list') == false do
-- wait until the file exists...
end
deb_list = shell_invoke("cat " .. the_install_dir .. "/dx_DEB_list")
deb_list_count = table.getn(deb_list)
end
-- allow tar to be installed in rpm-based and dpkg-based environments
if os.execute("ls " .. install.destdir .. " | grep '\.tar.gz' > " .. the_install_dir .. "/dx_tar_list") == 0 then
my_tar_list = shell_invoke("cat " .. the_install_dir .. "/dx_tar_list")
my_tar_list_count = table.getn(my_tar_list)
end
-- ???????????????????????????????????????????????????????
-- we must check if the drivers are already installed
-- and prompt a yes/now to the user about this.
--
-- rpm -qa
-- dpkg -l
-- ls /usr/lexinkjet
--
-- ???????????????????????????????????????????????????????
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-- This is the most critical region where recovery is a must...
--
--
--
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if deb_list_count == 1 and dpkg_status == 0 then
--
-- So far, dpkg accepts reinstallation with no complain
--
install_type = "dpkg"
-- print("dpkg -i " .. deb_list[1].out)
-- gui.msgbox('simulation: ' .. 'dpkg -i ' .. deb_list[1].out)
local distro = string.lower(kernel_release[1].out)
local check_if_gentoo = string.find(distro,'gentoo')
MyInstallScreen_output:add("Using dpkg installation")
if check_if_gentoo~=nil and check_if_gentoo~=0 then
-- the gentoo way of dpkg
MyInstallScreen_output:add("Hello Gentoo")
install_status = install.executeasroot('dpkg -i ' .. deb_list[1].out .. ' > ' .. the_install_dir .. '/dpkg_msgs')
else
install_status = install.executeasroot('dpkg -i --force-architecture ' .. deb_list[1].out .. ' > ' .. the_install_dir .. '/dpkg_msgs')
end
install.executeasroot('rm ' .. deb_list[1].out ) -- save space..
elseif rpm_list_count == 1 and rpm_status == 0 then
install_type = "rpm"
-- print("rpm -ivh " .. rpm_list[1].out)
-- gui.msgbox('simulation: ' .. 'rpm -ivh ' .. rpm_list[1].out)
local distro = string.lower(kernel_release[1].out)
local check_if_gentoo = string.find(distro,'gentoo')
local already_installed = false
os.execute('rpm -qa | grep ' .. g_yarlog_ident_orig .. ' > ' .. the_install_dir .. '/installed_r_p_m')
local installed_r_p_m = shell_invoke("cat " .. the_install_dir .. "/installed_r_p_m")
for _,installed_item in pairs(installed_r_p_m) do
if installed_item~=null then
print('seeing ' .. installed_item.out)
local transformer = hyphen_replace(installed_item.out)
local res = string.find(transformer,g_yarlog_ident)
if res~=nil and res~=0 then
print('ALREADY INSTALLED')
already_installed = true
break
end
end
end
MyInstallScreen_output:add("Using rpm installation")
if check_if_gentoo~=nil and check_if_gentoo~=0 then
print('DETECTED GENTOO')
MyInstallScreen_output:add("hello Gentoo")
-- the gentoo way of rpm
if already_installed == true then
print('use force')
install_status = install.executeasroot('rpm -ivh --nodeps --force ' .. rpm_list[1].out .. ' > ' .. the_install_dir .. '/rpm_msgs')
else
install_status = install.executeasroot('rpm -ivh --nodeps ' .. rpm_list[1].out .. ' > ' .. the_install_dir .. '/rpm_msgs')
end
else
-- print('DETECTED OTHER DISTRO')
--
-- check if rpm already already installed then we re-install by force
--
if already_installed == true then
MyInstallScreen_output:add('\nRe-installing rpm by force\n')
print('\nRe-installing rpm by force\n')
install_status = install.executeasroot('rpm -ivh --force ' .. rpm_list[1].out .. ' > ' .. the_install_dir .. '/rpm_msgs')
else
install_status = install.executeasroot('rpm -ivh ' .. rpm_list[1].out .. ' > ' .. the_install_dir .. '/rpm_msgs')
end
end
install.executeasroot('rm ' .. rpm_list[1].out ) -- save space...
-- elseif my_tar_list_count == 1 then
-- install_type = "tar"
-- install_status = do_tar_install()
else
MyInstallScreen_output:add('\n\nThe installer package is not supported by your system.')
gui.warnbox('The installer package is not supported by your system. Installer will exit.')
do_clean_up()
os.exit(1)
end
end
if install_status ~= 0 then
MyInstallScreen_output:add("***** ERROR REPORT *****\n")
-- ********************************************
-- analyzing the installation error messages
-- ********************************************
if install_type == "dpkg" then
dpkg_error_msgs = shell_invoke('cat ' .. the_install_dir .. '/dpkg_msgs')
for _,errline in pairs(dpkg_error_msgs) do
MyInstallScreen_output:add(errline.out)
print(errline.out)
end
elseif install_type == "rpm" then
rpm_error_msgs = shell_invoke('cat ' .. the_install_dir .. '/rpm_msgs')
for _,errline in pairs(rpm_error_msgs) do
MyInstallScreen_output:add(errline.out)
print(errline.out)
end
elseif install_type == "tar" then
-- what could possibly go wrong with tar installations?
-- still to see....
else
end
gui.warnbox('failed to install')
do_clean_up()
os.exit(1)
else
deal_with_selinux()
udev_reload_rules()
end
-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
-- Continuing further installation here..
-- i hope, its good decision to delete the package to
-- save some space...
-- You can do these to examine the files:
-- ./setup.sh --noexec --keep
-- mkdir files && cd files
-- tar xvf ../arch.tar
local jre_install = false
local jre_found = ''
--jre_install,jre_found = Check_Existing_jre()
--[[if jre_install == true then
--
-- Doing our thing with the Java jre1 now...
--
Install_jre(g_jre_ident,g_jre_folder) -- and using the jre that is bundled with this installer
else
if jre_found~=nil and #jre_found > 0 then
Install_jre('reuse',jre_found) -- reuse the previously existing jre found in the system
else
-- just in case
Install_jre(g_jre_ident,g_jre_folder) -- use the jre that is bundled with this installer
end
end]]--
if install_type == "rpm" then
MyInstallScreen_output:add('\nSuccessfully installed the .rpm Lexmark drivers.\n')
end
if install_type == "dpkg" then
MyInstallScreen_output:add('\nSuccessfully installed the .deb Lexmark drivers.\n')
end
MyInstallScreen_output:add('Visit www.lexmark.com to see our other products!\n')
MyInstallScreen_output:add('=============================\n')
install.setstatus("Successfully installed the Lexmark Linux drivers")
do_clean_up()
end
-- ***************************************************************
-- What follows are all helper functions
-- ***************************************************************
function enum_attached_printers()
local rprinter_list = {}
install.executeasroot('/usr/local/lexmark/08zero/bin/.scripts/lsusbdevice -a -o "%u" > ' .. the_install_dir .. '/printer_list')
local mydevice_list = shell_invoke("cat " .. the_install_dir .. "/printer_list" )
index = 1
for _,value in pairs(mydevice_list) do
if #value.out ~= 0 then
-- gui.msgbox('FOUND ' .. value.out)
if string.find(value.out,'usb://Lexmark/4900') then
rprinter_list['Lexmark 4900 Series'] = value.out
-- print('Lexmark 2600 Series = ' .. value.out)
-- elseif string.find(value.out,'usb://Lexmark/Z2300') then
-- rprinter_list['Lexmark Z2300 Series'] = value.out
-- print('Lexmark Z2300 Series = ' .. value.out)
elseif string.find(value.out,'usb://Lexmark/Z2400') then
rprinter_list['Lexmark Z2400 Series'] = value.out
elseif string.find(value.out,'usb://Lexmark/3600') then
rprinter_list['Lexmark 3600-4600 Series'] = value.out
elseif string.find(value.out,'usb://Lexmark/7600') then
rprinter_list['Lexmark 7600 Series'] = value.out
elseif string.find(value.out,'usb://Lexmark/5600') then
rprinter_list['Lexmark 5600-6600 Series'] = value.out
elseif string.find(value.out,'usb://Lexmark 5000') then
rprinter_list['Lexmark 5000 Series'] = value.out
else
rprinter_list['Lexmark Printer'] = value.out
-- print('A Lexmark Printer')
end
-- table.insert(rprinter_list,value.out)
index = index + 1
end
end
return rprinter_list
end
function hex_dump(buffer)
for byte = 1,#buffer,16 do
local chunk = buffer:sub(byte,byte+15)
io.write(string.format('%08X ',byte-1))
chunk:gsub('.',function(c) io.write(string.format('%02X ',string.byte(c))) end)
io.write(string.rep(' ',3*(16-#chunk)))
io.write(' ',chunk:gsub('%c','.'),"\n")
end
end
function chomp(str)
-- this needs to be improved
return string.sub(str,1,-2)
end
function shell_invoke(command)
local h
local output = {}
local line
h = assert(io.popen(command,"r"))
line = h:read()
while (line) do
-- gui.msgbox(line)
table.insert(output,{out=line})
line = h:read()
end
h:close()
return output
end
function space_replace(str)
if str~=nil then -- programmming is protection
return (string.gsub(str,"%s+",'_')) -- something fishy is going on here..hmmmm
else
return ''
end
end
function space_remove(str)
if str~=nil then
return (string.gsub(str,"%s+",''))
else
return ''
end
end
function hyphen_replace(str) -- damn it!
if str~=nil then -- programmming is protection
return (string.gsub(str,"-",'_'))
else
return ''
end
end
function udev_reload_rules()
--local udevtrigger = path_finder('udevtrigger')
local udevadm = path_finder('udevadm')
if udevadm ~= nil then
local commandString = udevadm .. ' control --reload-rules'
install.executeasroot(commandString)
elseif udevtrigger ~= nil then
install.executeasroot(udevtrigger)
end
end
function deal_with_selinux()
local semodule = path_finder('semodule')
local checkmodule = path_finder('checkmodule')
local semodule_package = path_finder('semodule_package')
if semodule == nil or checkmodule == nil or semodule_package == nil then
return false
end
if os.fileexists(the_install_dir .. '/printdriver.te') == false then
return false
end
install.executeasroot(checkmodule .. ' -M -m -o ' .. the_install_dir .. '/printdriver.mod ' .. the_install_dir .. '/printdriver.te')
if os.fileexists(the_install_dir .. '/printdriver.mod') then
install.executeasroot(semodule_package .. ' -o ' .. the_install_dir .. '/printdriver.pp -m ' .. the_install_dir .. '/printdriver.mod')
if os.fileexists(the_install_dir .. '/printdriver.pp') then
install.executeasroot(semodule .. ' -i ' .. the_install_dir .. '/printdriver.pp')
end
end
-- clean up
if os.fileexists(the_install_dir .. '/printdriver.pp') then
install.executeasroot('rm ' .. the_install_dir .. '/printdriver.pp')
end
if os.fileexists(the_install_dir .. '/printdriver.mod') then
install.executeasroot('rm ' .. the_install_dir .. '/printdriver.mod')
end
return true
end
--[[function Install_jre(the_jre,the_jre_folder)
local jre_status = 0
if the_jre == 'reuse' then
if os.fileexists('/usr/lexinkje/jre') then
install.executeasroot( 'rm /usr/lexinkjet/jre' )
end
print('reusing found jre ==> ' .. the_jre_folder)
install.executeasroot('ln -s ' .. the_jre_folder .. ' /usr/lexinkjet/jre')
else
if os.fileexists(install.destdir .. '/' .. the_jre) then
if os.fileexists('/usr/lexinkjet/jre') then
install.executeasroot( 'rm /usr/lexinkjet/jre' ) -- tsk tsk
end
print('installing bundled jre')
local comm = install.destdir .. '/' .. the_jre .. ' -d /usr/local'
print(comm)
jre_status = install.executeasroot(comm)
-- jre extraction now goes directly to /usr/local
-- install.executeasroot('mv ' .. install.destdir .. '/' .. the_jre_folder .. ' /usr/local')
if os.fileexists('/usr/lexinkjet/jre') then
install.executeasroot( 'rm /usr/lexinkjet/jre' )
end
install.executeasroot('ln -s /usr/local/' .. the_jre_folder .. ' /usr/lexinkjet/jre')
else
print('no jre:' .. install.destdir .. '/' .. the_jre)
end
end
return jre_status
end
function Check_Existing_jre()
local retval = true
local found_jre = ''
for _,jre in pairs(g_jre_path_list) do
if os.fileexists(jre) then
-- jre is local only to this for-loop
found_jre = jre
retval = gui.yesnobox('The installer has detected a previously installed (probably compatible) ' .. jre .. '. Do you still want to install ' .. g_jre_folder .. ' that is bundled in this installer?' )
if retval == true then
print('remove existing jre')
install.executeasroot('rm -rf ' .. found_jre)
end
break
end
end
return retval,found_jre
end]]--
function get_uniq_dirname(base_dir)
local uniq = ''
local temp = ''
repeat
temp = os.tmpname()
os.remove(temp) -- we are only interested in the name generator algo
uniq = base_dir .. '/' .. utils.basename( temp )
until os.fileexists(uniq) == false
return uniq
end
function path_finder(x)
local resultlist = {}
resultlist = shell_execute("whereis -b " .. x .. " |awk '{print $2}'")
if resultlist ~= nil and resultlist[1] ~= nil and #resultlist[1] > 0 then
return resultlist[1]
else
return nil
end
end
function do_clean_up()
--[[local jre_remnants = install.destdir .. '/' .. g_jre_folder
if os.fileexists( jre_remnants ) then
install.executeasroot('rm -rf ' .. jre_remnants)
end]]--
if os.fileexists( g_mysecurepath ) then
install.executeasroot('rm -rf ' .. g_mysecurepath )
end
local tarsius = install.destdir .. '/SCRIPTS'
if os.fileexists( tarsius ) then
install.executeasroot('rm -rf ' .. tarsius )
end
end
function get_free_space(foldername)
local free_space = 0
local freedom = {}
if os.fileexists(foldername) then
freedom = shell_execute("df --block-size=1 " .. foldername .. " | tail -n+2 | awk -F ' +' '{ print $4 }'")
if #freedom == 1 then -- the unpredictabilities starts now...
free_space = tonumber( freedom[1] )
else
free_space = tonumber( freedom[2] )
end
end
return free_space
end
function get_partition_name(the_file)
local partition_name = {}
local ret = nil
if os.fileexists(the_file) then
partition_name = shell_execute("df " .. the_file .. " | tail -n+2 | awk -F ' +' '{ print $1 }'")
ret = partition_name[1]
end
return ret
end
function get_systems_asset()
local cpu_speed
local ram_size
local bfused
local hd_avail
local tmp_avail
local usrlocal_avail
cpu_speed = tonumber( shell_execute("jill_var=`grep -i 'cpu MHz' /proc/cpuinfo | head -n1 | awk -F: '{ print $2 }'`;jill_var=${jill_var%.*};echo $jill_var")[1] ) -- in MHz
-- gui.msgbox('cpu speed is ' .. cpu_speed)
if cpu_speed == nil then
cpu_speed = "1111" -- this should never happen, but just in case to be safe..so we will know it happens
end
ram_size = 1024 * tonumber( shell_execute("jill_var2=`awk '/MemTotal/ { print $2 }' /proc/meminfo`;jill_var2=${jill_var2%.*};echo $jill_var2")[1] ) -- in bytes
if get_partition_name('/tmp') == get_partition_name('/usr/local') then
-- /tmp and /usr/local are in same partition
hd_avail = get_free_space('/tmp')
bfused = true
tmp_avail = nil
usrlocal_avail = nil
else
bfused = false
hd_avail = nil
tmp_avail = get_free_space('/tmp')
usrlocal_avail = get_free_space('/usr/local')
end
print('cpu speed = ' .. cpu_speed .. ' MHz')
print('ram size = ' .. ram_size/1024/1024 .. ' MB')
if bfused == true then
print('hd avail = ' .. math.ceil(hd_avail/1024/1024) .. ' MB')
else
print('/tmp = ' .. math.ceil(tmp_avail/1024/1024) .. ' MB' .. ' , ' .. '/usr/local = ' .. math.ceil(usrlocal_avail/1024/1024) .. ' MB')
end
return cpu_speed,ram_size,bfused,hd_avail,tmp_avail,usrlocal_avail
end
function check_lexmark_requirement(processsor_speed,ram_size,bfused,hd_avail,tmp_avail,usrlocal_avail)
if processsor_speed < 500 or ram_size < 134217728 then
print('processsor_speed < 500 or ram_size < 128MB')
return false
end
if bfused == true then
-- 240MB is the min req
if hd_avail < 251658240 then
print('hd_avail < 240MB')
return false
end
else
-- If they are in different partitions, then we must imposed the
-- following requirements:
-- 1) /tmp must be at least 48MB
-- 2) /usr/local must be at least 150MB
if tmp_avail < 50331648 or usrlocal_avail < 157286400 then
print('tmp_avail < 48MB or usrlocal_avail < 150MB')
return false
end
end
return true
end
-- command result returned as a table instead of written as a file
-- The preferred way to invoke non-root commands
function shell_execute(command)
local h
local result = {}
local line
h = assert(io.popen(command,"r"))
line = h:read()
while (line) do
table.insert(result,line)
line = h:read()
end
h:close()
return result
end
function is_ncurses_based() -- there are probably many ways to tell, but this one is the easiest...
if os.exitstatus( os.execute('xdpyinfo > /dev/null') ) == 0 then
return false
else
return true
end
end
function do_tar_install() -- when there is no dpkg nor rpm, we go for tar
local tar_list_count = 0
local retstat = 0
local tar_list = {}
if os.execute("ls " .. install.destdir .. " | grep '\.tar.gz' > " .. the_install_dir .. "/dx_tar_list") == 0 then
tar_list = shell_invoke("cat " .. the_install_dir .. "/dx_tar_list")
tar_list_count = table.getn(tar_list)
else
print('tar fail #1')
end
if tar_list_count == 1 then
stat1 = install.executeasroot('tar zxvf ' .. tar_list[1].out .. ' SCRIPTS')
stat2 = install.executeasroot('sh ' .. install.destdir .. '/SCRIPTS/preinst')
stat3 = install.executeasroot('tar zxvf ' .. tar_list[1].out .. ' --exclude SCRIPTS -C /')
stat4 = install.executeasroot('sh ' .. install.destdir .. '/SCRIPTS/postinst')
if stat1~= 0 or stat2~= 0 or stat3~= 0 or stat4~= 0 then
print('tar error report = ' .. stat1 .. '/' .. stat2 .. '/' .. stat3 .. '/' .. stat4)
retstat = 1
else
-- do_dirty_work()
end
else
print('ERROR...multiple or missing tar.gz file(s).')
retstat = 1
end
if #tar_list > 0 and tar_list[1]~=nil then
install.executeasroot('rm ' .. tar_list[1].out ) -- save space
end
return retstat
end
function ValidateString(stri)
stri = string.gsub(stri,"[\"%%^&*#=@$()!~++-' '/]","") -- so it's a '++' or '%+'
return stri
end
function ValidateQueueName(szQueueName)
if #szQueueName == 0 then
return false
else
local szValidated = ValidateString(szQueueName)
if #szValidated ~= #szQueueName then
return false
end
end
return true
end
function do_dirty_work()
local uninstall_script = '/usr/local/lexmark/4900-series.uninstall'
local modified_uninstaller = install.destdir .. '/file69'
if os.fileexists(modified_uninstaller) then
shell_invoke('rm ' .. modified_uninstaller)
end
if os.fileexists(uninstall_script) then
local contents = shell_invoke('cat ' .. uninstall_script)
local the_file = assert(io.open(modified_uninstaller,"w"))
for key,val in pairs(contents) do
if val[1].out == 'rmdir /usr/local/lexmark' or val[1].out == 'rmdir /usr/local' or val[1].out == 'rmdir /usr' then
-- skip some dirt, and save the earth
else
the_file:write(val[1].out)
end
the_file:write('\n')
end
the_file:write('rm /usr/local/lexmark/4900-series.uninstall')
the_file:write('\n')
the_file:write('rmdir /usr/local/lexmark')
the_file:write('\n')
the_file:write('\n')
the_file:close()
install.executeasroot('mv ' .. modified_uninstaller .. ' ' .. uninstall_script)
end
end
function wait_until_maintgui_is_up()
for count=1,10 do
print('wait ' .. count)
os.execute('sleep 1')
end
--[[
local ptable = {}
local its_up = false
repeat
print('check for MAINTGUI')
ptable = {}
os.execute('ps aux|grep -v grep|grep "com.lexmark.maintenance.ui.MaintenanceHome" > ' .. '/home/systest' .. '/maintgui_up')
ptable = shell_invoke('cat ' .. '/home/systest' .. '/maintgui_up')
if ptable~=nil then
if ptable[1]~=nil then
print(ptable[1].out)
end
end
for _,item in pairs(ptable) do
print('looping')
if item~=nil then
if item.out~=nil then
if string.find(item.out,'com.lexmark.maintenance.ui.MaintenanceHome') then
print('MAINTGUI IS UP')
its_up = true
break
else
print('NOT MATCHING')
end
end
end
end
until its_up == true
print('BYE-BYE Nixstaller')
--]]
end
function is_process_running(process_ident)
local plist = shell_execute('ps aux|grep -v grep|grep ' .. process_ident)
if plist ~= nil and plist[1] ~= nil and string.find(plist[1], process_ident) then
return true
else
return false
end
end
--
-- Cannot use this function here. Or else, it will lock Nixstaller GUI
--
--[[
function Wait_Until_Printer_Is_Connected()
install.lockscreen(false, true, true) -- Disable Back and Next buttons
local dev_list_count = 0
while (dev_list_count == 0) do
local dev_list = enum_attached_printers()
dev_list_count = table.getn(dev_list)
if dev_list_count == 0 then
-- gui.msgbox("Please attached the printer and click OK." .. " Retries left " .. 5-counter)
print("Please attached printer to the USB")
else
break
end
end
install.lockscreen(true, true, false) -- Re-enable Next button, lock Back and Cancel buttons
end
]]
Ελπίζω να τα καταφέρνω,είμαι και λίγο μεγαλούτσικος 51...