Help me with ur distro on my project packaging Bookmark and Share

News and Discussion about GNU/Linux OS such as Fedora, Ubuntu, Debian, etc...

Help me with ur distro on my project packaging

Postby victor_lin21 » November 3rd, 2007, 2:14 pm

:D
Like this topic, before I were unable to notify, that bro tried with SuSE.
As you all know, how many of distro variants for GNU/Linux and even more if counting BSD in.. So, those, those users and need ur help on my project packaging. Help test, debug and commit me for the packaging code.
For now, i tried write shell script installer for Fedora and Ubuntu for UniBurma keyboard installation. Since my box is Fedora, so Fedora script is ok. But i think Ubuntu is broken.

The script shipped with UniBurma current latest release V 2.0.1 package. The doc links are at:
http://www.unimm.org/xkbinstall/
http://uniburma.blogspot.com/2007/10/un ... -only.html

installkb.ub6
Code: Select all
#!/bin/sh

#############################################################
#   This is a small piece of user interactive shell installer script for UniBurma Keyboard installation.
#     Original author: Victor San Kho Lin <victor.sankholin@mmlug.org or gmail.com> | sankholin.com | mmglug.org | unimm.org
#   Contributors:
#   Last Update: 8-Sept-2007
#   
#
#
#
##############################################################

if apt-cache policy dialog #dpkg -l | grep dialog #dialog
then
dialog --title "Alert : Using a right shell script installer?" --backtitle "UniBurma Shell Script \
Installer" --yesno "\nOne last question. You are running Ubuntu 6 or up? If so, select Yes and close all running applications now. Because installer \
need to restart your X window after installation completed. You have to type \"startx\" command while console prompting." 8 100
sel=$?
case $sel in
   0) cp -f /etc/X11/xkb/symbols/mm /etc/X11/xkb/symbols/mm.bak
   sleep 1
   echo "Backup Ok."
   sleep 1   
   rm -f /etc/X11/xkb/symbols/mm
   echo "Deleted Old Layout."
   sleep 1   
   cp -v mm /etc/X11/xkb/symbols/
   sleep 1
   echo "Installation completed!"
   sleep 1
   echo "Going to restart X for taking effect."
   sleep 2
   echo "Please re-login or startx, startxfce4 again."
   sleep 1 | echo .
   sleep 1 | echo ..
   sleep 1 | echo ....
   sleep 1 | echo ........
   sleep 1 | echo .............
   # different commands of restarting x, comment in/out to adjust your system
   sudo pkill X
   #init 3
   #/etc/init.d/xdm restart
   #/etc/init.d/gdm restart
   #/etc/init.d/kdm restart
   #exit
   ;;
   1) echo "Good. Choose your respective distro shell scipt, tail the name with extension.";;
   255) echo "Canceled by user by pressing [ESC] key";;
esac

else
   installdialog=0
   echo "You don't have dialog utility. Please install it by \"apt-get install dialog\" or I shall do this for you?";
   echo "1. Yah, Install it for me."
   echo "2. No. I will do myself."
   echo -n "Select your choice [1 or 2]? "
   read installdialog
   if [ $installdialog -eq 1 ] ; then
      echo "Ok. I will install dialog utility for you. Please re-run this installer script after dialog utility installed."
      sleep 1 | echo .
      sleep 1 | echo ...
      sleep 1 | echo ......
      sleep 1 | echo ...........
      echo "Going out from UniBurma installer script. Starting dialog utility apt-get installation...."
      sleep 1
      apt-get install dialog
      else #### nested if i.e. if within if ######
         if [ $installdialog -eq 2 ] ; then
            echo "Ok. Please install dialog utility and re-run the installer script again."
         else
            echo "What are you trying to say?? I ask you 1 or 2. Please re-run the installer script."
         fi
   fi
fi


I think the problem is at the fist line, checking dialog program if statement. I intend to check whether dialog program is available or not. Any idea? Or any other terminal message command?

The following is a working script for fedora, same logic. I wrote primary on Fedora, so ubuntu script is derived from the following fedora script.

installkb.fc6
Code: Select all
#!/bin/sh

#############################################################
#   This is a small piece of user interactive shell installer script for UniBurma Keyboard installation.
#     Original author: Victor San Kho Lin <victor.sankholin@mmlug.org or gmail.com> | sankholin.com | mmglug.org | unimm.org
#   Contributors:
#   Last Update: 8-Sept-2007
#   
#
#
#
##############################################################

if rpm -q dialog
then
dialog --title "Alert : Using a right shell script installer?" --backtitle "UniBurma Shell Script \
Installer" --yesno "\nOne last question. You are running Fedora Core 6 or up? If so, select Yes and close all running applications now. Because installer \
need to restart your X window after installation completed. You have to type \"startx\" command while console prompting." 8 100
sel=$?
case $sel in
   0) cp -f /usr/share/X11/xkb/symbols/mm /usr/share/X11/xkb/symbols/mm.bak
   sleep 1
   echo "Backup Ok."
   sleep 1   
   rm -f /usr/share/X11/xkb/symbols/mm
   echo "Deleted Old Layout."
   sleep 1   
   cp -v mm /usr/share/X11/xkb/symbols/
   sleep 1
   echo "Installation completed!"
   sleep 1
   echo "Going to restart X for taking effect."
   sleep 2
   echo "Please re-login or startx, startxfce4 again."
   sleep 1 | echo .
   sleep 1 | echo ..
   sleep 1 | echo ....
   sleep 1 | echo ........
   sleep 1 | echo .............
   # different commands of restarting x, comment in/out to adjust your system
   sudo pkill X
   #init 3
   #/etc/init.d/xdm restart
   #/etc/init.d/gdm restart
   #/etc/init.d/kdm restart
   #exit
   ;;
   1) echo "Good. Choose your respective distro shell scipt, tail the name with extension.";;
   255) echo "Canceled by user by pressing [ESC] key";;
esac

else
   installdialog=0
   echo "You don't have dialog utility. Please install it by \"yum install dialog\" or I shall do this for you?";
   echo "1. Yah, Install it for me."
   echo "2. No. I will do myself."
   echo -n "Select your choice [1 or 2]? "
   read installdialog
   if [ $installdialog -eq 1 ] ; then
      echo "Ok. I will install dialog utility for you. Please re-run this installer script after dialog utility installed."
      sleep 1 | echo .
      sleep 1 | echo ...
      sleep 1 | echo ......
      sleep 1 | echo ...........
      echo "Going out from UniBurma installer script. Starting dialog utility yum installation...."
      sleep 1
      yum install dialog
      else #### nested if i.e. if within if ######
         if [ $installdialog -eq 2 ] ; then
            echo "Ok. Please install dialog utility and re-run the installer script again."
         else
            echo "What are you trying to say?? I ask you 1 or 2. Please re-run the installer script."
         fi
   fi
fi


Pls also suggest/commit for better code and logic beautify also, such as sed, awk, etc... And port for other distro.

:)
~ penguins are psychiatric. and you keep a secret, we really not penguins at all
~ hacker-nin never play-a-cheap jutsu
~ exploring kernel, networking, security and java
Image
User avatar
victor_lin21
Global Moderator
 
Posts: 780
Joined: July 30th, 2007, 11:36 pm
Location: Singapore

Re: Help me with ur distro on my project packaging

Postby akhtet » November 10th, 2007, 9:34 pm

Tested Uniburma XKB on Ubuntu 7.10.
It worked fine so far.

1) Copy the font into /usr/share/fonts/truetype, set chmod 777
2) Run sudo installkb.ub6
3) Reboot X
4) Add keyboard indicator on Desktop panel
ေအာင္ေက်ာ္ထက္
User avatar
akhtet
Global Moderator
 
Posts: 639
Joined: July 30th, 2007, 8:52 am
Location: Sydney, Australia

Re: Help me with ur distro on my project packaging

Postby victor_lin21 » November 11th, 2007, 12:00 pm

akhtet wrote:Tested Uniburma XKB on Ubuntu 7.10.
It worked fine so far.

Yah, for ubuntu user who want to use installkb.ub6 installer script, please install dialog program first.
You can install through apt-get or repository.
Code: Select all
#apt-get install dialog
#sudo sh installkb.ub6

Current installkb.ub6 is trying to automagically install dialog for target machine, but I'm not sure checking shell command for dialog utility is either one of these or not.

Code: Select all
#apt-cache policy dialog
#dpkg -l | grep dialog
#dialog

I dont know the return value for those commands and so, not sure to check the true or false. Therefore, it wont do that automagically part. So, installing dialog first then run the installer script will fix for this release.
~ penguins are psychiatric. and you keep a secret, we really not penguins at all
~ hacker-nin never play-a-cheap jutsu
~ exploring kernel, networking, security and java
Image
User avatar
victor_lin21
Global Moderator
 
Posts: 780
Joined: July 30th, 2007, 11:36 pm
Location: Singapore

Re: Help me with ur distro on my project packaging (python)

Postby victor_lin21 » November 13th, 2007, 4:35 am

:D
Today, Mg AK47 contributed the python version for UniBurma XKB and Fonts installation. As for on going development and code reviewing against logic suggestion, current initial code summary as follow by quoted. We shall continuing discuss for more and reliable outcome. Once the logic and code reached to its final goal, I'll remove or replace the following code quotation and it will be in ship with next up UniBurma package releases.

Code: Select all
#!/usr/bin/env python
#############################################################
#
#   This is a python script for UniBurma Font and Keyboard installation.
#   Original author: Aung Kyaw Htet <akhtet@mmlt.org> | {yourname}
#   Contributors: Victor San Kho Lin <victor@mmlt.org> <sankholin.com> | {yourname}
#   Affiliations: mmglug.org | unimm.org | mmlt.org
#   Last Update: {set date for ship release}
#   Script Version: {not yet release, development}
#   
#   Goals: Instead of performing individual installation for fonts and xkb,
#          this script will do all necessary tasks. End-user(s) just have to
#          run this script in a few steps from terminal. As much as GNU/Linux(es) out there,
#          the path(es) are different on each system and design. This script intend to
#          support all possible GNU/Linux(es).
#
#   License: This script will ship with UniBurma Fonts and XKB, thus shall apply
#            the same license as Font and Keyboard wares. Read License.txt.
#
#   Howto: Run this script from terminal by one of the following methods. If root user, ommit
#          the sudo.
#               
#                username@localhost$sudo python installUniBurma.py
#                                  (OR)
#                username@localhost$chmod 755 installUniBurma.py
#                username@localhost$sudo ./installUniBurma.py
#
##############################################################


import os

author_email = 'victor@mmlt.org'

def install_fonts():
   print 'Installing UniBurma Fonts'
   known_font_paths = ['/usr/share/fonts/truetype', '/usr/share/fonts']
   for sys_font_path in known_font_paths:
      if os.path.exists(sys_font_path):
         print 'System font path found:', sys_font_path
         break
   else:
      print 'Error: Cannot find system font directory.'
      return
   mm_font_path = './UniBurma_Font-2.0/'
   if os.path.exists(mm_font_path):
      for filename in os.listdir(mm_font_path):
         if filename.endswith('ttf'):
            filepath = os.path.join(mm_font_path, filename)
            print 'Copying %s to %s' % (filepath, sys_font_path)
            os.system('cp %s %s' % (filepath, sys_font_path))
            os.system('chmod 755 ' + os.path.join(sys_font_path, filename))
   else:
      print 'Error: Cannot find UniBurma font directory under current directory.'
      

def install_xkb():
   print 'Installing UniBurma XKB'
   known_xkb_paths = ['/etc/X11/xkb/symbols', '/usr/share/X11/xkb/symbols']
   for xkb_path in known_xkb_paths:
      if os.path.exists(xkb_path):
         print 'XKB path found:', xkb_path
         break
   else:
      print """XKB path NOT found. Please specify your XKB path below.
   If you dont know your XKB path, press 'CTRL-C' to terminate this program
   and plese notify the author at %s.""" % author_email
      return
   mm_xkb_path = os.path.join(xkb_path, 'mm')

   # Backup current mm file if it is not UniBurma.
   if os.path.exists(mm_xkb_path):
      mm = open(mm_xkb_path).read()
      if mm.find('UniBurma') == -1:
         os.rename(mm_xkb_path, mm_xkb_path + '.bak')
      else:
         print 'Previous UniBurma xkb found. Overwritting'

   # Copy the UniBurma mm file to xkb directory.
   if os.path.exists('./mm'):
      os.system('cp ./mm %s' % mm_xkb_path)
      if os.path.exists(mm_xkb_path):
         print 'Installation complete'
      else:
         print 'ERROR: cannot create file %s' % mm_xkb_path
         return
   else:
      print 'ERROR: Cannot find the file "mm".'
      return
      
   print "You will nedd to restart your system to use UniBurma."
   reboot = raw_input('Do you want to reboot now? (Y/N) :')
   if reboot.upper() == 'Y':
      os.system('reboot')
   

if __name__ == '__main__':
   install_fonts()
   install_xkb()


======================
Now let's discuss about features.

1) Paths
- expect the known path(s) for system font and xkb folder
- if script known the paths, use the known path
- if script dont know the path, option user to supply path for it
- if not, print user to call error report (see 6)

2) Definitions
- mm xkb file must only the first and one time back up
- if user somehow re-run (double/second time) the script, must protect original "mm" as in form of "mm.bak"

3) Need uninstall phase.
- So, it will be somthing like
Code: Select all
./UniBurma.py install
./UniBurma.py uninstall

- the tasks for uninstall phase will perform, deleting installed fonts and reverting back "mm.bak" into "mm".
- while uninstallation call, check mm.bak is original or not (optional but may require if more than one vendors)

4) Delay
- "you see, nowaday machine are faster and faster like quad core Xeon, if you never put delay or sleep, i dont know wut is going on"
- :roll:
- effect, timing and prompts

5) fontconv
- As this will be intended for complete package release, shall include burglish.com's fontconv product.
- It will be like ./fontconv into local directory, thus need to discuss which directory should be
- May be in future if we happen to do Prince Ka Naung...

6) Object for error report
- As every states, if fails, call global object, author lists for email
- quote which step it fails about if possible

7) more??
~ penguins are psychiatric. and you keep a secret, we really not penguins at all
~ hacker-nin never play-a-cheap jutsu
~ exploring kernel, networking, security and java
Image
User avatar
victor_lin21
Global Moderator
 
Posts: 780
Joined: July 30th, 2007, 11:36 pm
Location: Singapore

Re: Help me with ur distro on my project packaging

Postby victor_lin21 » November 27th, 2007, 6:25 pm

I found out the follow tool, not sure can be used in something related.

http://sourceforge.net/projects/fontypython/
~ penguins are psychiatric. and you keep a secret, we really not penguins at all
~ hacker-nin never play-a-cheap jutsu
~ exploring kernel, networking, security and java
Image
User avatar
victor_lin21
Global Moderator
 
Posts: 780
Joined: July 30th, 2007, 11:36 pm
Location: Singapore

Bookmark and Share

Return to GNU/Linux

Who is online

Users browsing this forum: No registered users and 1 guest