Changeset 3357

Show
Ignore:
Timestamp:
01/11/10 21:12:57 (10 years ago)
Author:
imcheng
Message:

Rewrote some of the codes for Nokia N800 in seattle[un]installer.py

Location:
seattle/trunk/dist
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • seattle/trunk/dist/seattleinstaller.py

    r3347 r3357  
    12171217  """ 
    12181218   
     1219 
     1220  # Note to developers: If you need to change the path of the startup script or 
     1221  # the path of the symlink, make sure you keep it consistent with those in 
     1222  # seattleuninstaller.py. 
     1223 
    12191224  # The name of the startup script. 
    12201225  startup_script_name = "nokia_seattle_startup.sh" 
     
    12311236  symlink_path = symlink_dir + symlink_name 
    12321237 
    1233   # The username of the user. This is assumed to be 'user', since this is the 
    1234   # default name and it is highly unlikely that the name can be changed.  
     1238  # The username of the user. This is assumed to be 'user'. 
     1239  # However, if you do change your user name on the Nokia, 
     1240  # you will need to modify the following line to match your user name. 
    12351241  username = "user" 
    12361242   
     
    13081314    return False 
    13091315 
    1310   _output("Seattle has been configured to run on startup.") 
    13111316  servicelogger.log("Seattle has been configured to run on startup. Two " \ 
    13121317                      + "files were created: " + startup_script_path + " and " \ 
     
    20232028    # if the current user name is not 'root' 
    20242029    if pwd.getpwuid(os.getuid())[0] != 'root': 
    2025       _output('Please run the installer as root. This can be done in by ' \ 
     2030      _output('Please run the installer as root. This can be done by ' \ 
    20262031                + 'installing/using the rootsh or openssh package.') 
    20272032      return 
  • seattle/trunk/dist/seattleuninstaller.py

    r3347 r3357  
    3434# Derek Cheng: This is for detecting if the user is root (for Nokia tablets) 
    3535import pwd 
     36# Derek Cheng: This is for detecting error codes when removing the script or 
     37# the link is unsuccessful. 
     38import errno 
    3639 
    3740# Import seattle modules 
     
    342345    Remove the startup script and symlink to it in the /etc/init.d and  
    343346    /etc/rc2.d directories, and kill all seattle processes by using  
    344     impose_seattlestopper_lock. This requires the user to be currently on root 
    345     access. 
     347    stop_all_seattle_processes. This requires the user to be currently on root 
     348    access.  
    346349 
    347350  <Arguments> 
     
    360363  """ 
    361364   
    362   # Check to see if the current user is root. 
    363   if pwd.getpwuid(os.getuid())[0] != 'root': 
    364     _output('Please run the uninstaller as root. This can be done by ' \ 
    365               + 'installing/using the rootsh or openssh package.') 
    366     return False 
    367    
    368   # Stop all instances of seattle from running. 
    369   impose_seattlestopper_lock.killall() 
    370  
    371   # The name of the startup script. 
     365 
     366  # Note to developers: If you need to change the path of the startup script or 
     367  # the path of the symlink, make sure you keep it consistent with those in 
     368  # seattleinstaller.py. 
     369 
    372370  startup_script_name = "nokia_seattle_startup.sh" 
    373371  # The directory where the startup script resides. 
     
    392390  try: 
    393391    os.remove(startup_script_path) 
    394   except: 
    395     # The script does not exist for some reason (but the symlink exists) 
    396     pass 
    397    
     392  # Cannot remove the startup script due to some reason. 
     393  except OSError as (error_number, error_desc): 
     394    # The startup script does not exist - that is fine, we will continue  
     395    # and try to remove the symlink. 
     396    if error_number == errno.ENOENT: 
     397      pass 
     398    else: 
     399      # The startup script cannot be removed. 
     400      _output("The startup script cannot be removed. Make sure you have the " \ 
     401                + "permission to do so.") 
     402      servicelogger.log("Seattle cannot be uninstalled because " \ 
     403                          + startup_script_path + " cannot be removed.") 
     404      return False 
     405 
    398406  # Remove the symlink. 
    399407  try: 
    400408    os.remove(symlink_path) 
    401   except: 
    402     # The symlink does not exist for some reason (but the script existed) 
    403     pass 
     409  # Cannot remove the symlink due to some reason. 
     410  except OSError as (error_number, error_desc): 
     411    # The symlink does not exist - that is fine. 
     412    if error_number == errno.ENOENT: 
     413      pass 
     414    else: 
     415      # The symlink cannot be removed. 
     416      _output("The symlink cannot be removed. Make sure you have the " \ 
     417                + "permission to do so.") 
     418      servicelogger.log("Seattle cannot be uninstalled because " \ 
     419                          + symlink_path + " cannot be removed.") 
     420      return False 
     421 
     422  # Stop all instances of seattle from running. 
     423  stop_all_seattle_processes.main() 
    404424 
    405425  return True 
     
    585605    return 
    586606 
    587  
    588  
     607  # Derek Cheng: If the user is running the uninstaller on the Nokia N800, we  
     608  # require them to be on root to remove some files in /etc/init.d and  
     609  # /etc/rc2.d directories. 
     610  if platform.node().startswith('Nokia-N'): 
     611    # Check to see if the current user is root. 
     612    if pwd.getpwuid(os.getuid())[0] != 'root': 
     613      _output('Please run the uninstaller as root. This can be done by ' \ 
     614                + 'installing/using the rootsh or openssh package.') 
     615      return 
    589616 
    590617  # Begin uninstall process.