Пример #1
0
 def prepare_pacman_keychain(self):
     # removed / from etc to make path relative...
     dest_path = os.path.join(self.dest_dir, "etc/pacman.d/gnupg")
     # use copytree for cp -r
     try:
         misc.copytree('/etc/pacman.d/gnupg', dest_path)
     except (FileExistsError, shutil.Error) as e:
         # print error but continue anyway
         print(e)
Пример #2
0
 def prepare_pacman_keychain(self):
     # removed / from etc to make path relative...
     dest_path = os.path.join(self.dest_dir, "etc/pacman.d/gnupg")
     # use copytree for cp -r
     try:
         misc.copytree('/etc/pacman.d/gnupg', dest_path)
     except FileExistsError:
         # ignore if exists
         pass
Пример #3
0
  def install(self):
    # FIXME: DEPENDS!!!
  
    path = os.path.normpath(os.path.join(self.parent.config['path'], 'packages', self.get_atom(True, False)))
    download = DownloadLink(self.package_file['uri'], path)
    download.process()
    # TODO: user patches?
    
    tmp_path = os.path.normpath(os.path.join(self.parent.config['path'], 'temp', self.get_atom(True, False)))
    try:
      shutil.rmtree(tmp_path)
    except:
      pass
    os.makedirs(tmp_path)

    for root, dirs, files in os.walk(path, True):
      for ignored_path in ignored_paths:
        if ignored_path in dirs:
          dirs.remove(ignored_path)
      
      for file in files:
        rel_file = os.path.relpath(os.path.join(root, file), path).replace('\\', '/')
        if (rel_file in self.package_file['files']):
          shutil.copy(os.path.join(root, file), os.path.join(tmp_path, self.package_file['files'][rel_file]))
      
      rel_root = os.path.relpath(root, path).replace('\\', '/')
      if (rel_root in self.package_file['files']):
        copytree(root, os.path.join(tmp_path, self.package_file['files'][rel_root]), ignore=shutil.ignore_patterns('.git'))
    
    filelist = FileList(listdir(tmp_path))
    filelist.save(os.path.join(path, self['name'] + '.filelist'))
    
    success = False
    try:
      copytree(tmp_path, self.parent.config['simba_path'])
      success = True
      shutil.rmtree(tmp_path)
    except:
      pass
    return success
Пример #4
0
 def do_file(self, update = False):
   path = self.url[5:]
   copytree(path, self.path)
Пример #5
0
 def do_file(self, update=False):
     path = self.url[5:]
     copytree(path, self.path)
Пример #6
0
    def configure_system(self):
        # final install steps
        # set clock, language, timezone
        # run mkinitcpio
        # populate pacman keyring
        # setup systemd services
        # ... check configure_system from arch-setup

        # Generate the fstab file        
        self.auto_fstab()
        #Copy configured networks in Live medium to target system
        self.copy_network_config()

        # copy cinnarch menu icon
        cinnarch_path = os.path.join(self.dest_dir, "usr/share/cinnarch")
        if not os.path.exists(cinnarch_path):
            os.makedirs(cinnarch_path)
        shutil.copy2('/usr/share/cinnarch/cinnarch_menu.png', \
                    os.path.join(cinnarch_path, 'cinnarch_menu.png'))

        # copy mirror list
        shutil.copy2('/etc/pacman.d/mirrorlist', \
                    os.path.join(self.dest_dir, 'etc/pacman.d/mirrorlist'))       

        self.queue_event("action", _("Configuring your new system"))

        # Copy important config files to target system
        files = [ "/etc/pacman.conf", "/etc/yaourtrc" ]        
        
        for path in files:
            shutil.copy2(path, os.path.join(self.dest_dir, 'etc/'))

        # enable services      
        self.enable_services([ "mdm", "NetworkManager" ])

        # TODO: we never ask the user about this...
        if self.settings.get("use_ntp"):
            self.enable_services([ "ntpd" ])

        # Wait FOREVER until the user sets the timezone
        while self.settings.get('timezone_done') is False:
            # wait five seconds and try again
            time.sleep(5)

        # set timezone
        zoneinfo_path = os.path.join("/usr/share/zoneinfo", \
                                     self.settings.get("timezone_zone"))
        self.chroot(['ln', '-s', zoneinfo_path, "/etc/localtime"])
        
        # Wait FOREVER until the user sets his params
        while self.settings.get('user_info_done') is False:
            # wait five seconds and try again
            time.sleep(5)         

        # Set user parameters
        username = self.settings.get('username')
        fullname = self.settings.get('fullname')
        password = self.settings.get('password')
        hostname = self.settings.get('hostname')
        
        sudoers_path = os.path.join(self.dest_dir, "etc/sudoers")
        with open(sudoers_path, "wt") as sudoers:
            sudoers.write('# Sudoers file\n')
            sudoers.write('root ALL=(ALL) ALL\n')
            sudoers.write('%s ALL=(ALL) ALL\n' % username)
        
        subprocess.check_call(["chmod", "440", sudoers_path])
        
        try:
            misc.copytree('/etc/skel', os.path.join(self.dest_dir, "etc/skel"))
        except FileExistsError:
            # ignore if exists
            pass

        process = subprocess.check_call(["rm", "-rf", "%s/etc/skel/Desktop" % self.dest_dir])
        
        self.chroot(['useradd', '-m', '-s', '/bin/bash', \
                  '-g', 'users', '-G', 'lp,video,network,storage,wheel,audio', \
                  username])

        self.change_user_password(username, password)

        self.chroot(['chfn', '-f', fullname, username])
        
        try:
            misc.copytree('/etc/skel', os.path.join(self.dest_dir, "home/%s" % username))
        except FileExistsError:
            # ignore if exists
            pass

        self.chroot(['chown', '-R', '%s:users' % username, "/home/%s" % username])
        
        hostname_path = os.path.join(self.dest_dir, "etc/hostname")
        if not os.path.exists(hostname_path):
            with open(hostname_path, "wt") as f:
                f.write(hostname)
        
        # User password is the root password  
        self.change_user_password('root', password)

        ## Generate locales
        lang_code = self.settings.get("language_code")
        locale = self.settings.get("locale")
        self.queue_event('info', _("Generating locales"))
        
        self.chroot(['sed', '-i', '-r', '"s/#(.*%s)/\1/g"' % locale, "/etc/locale.gen"])
        
        self.chroot(['locale-gen'])
        locale_conf_path = os.path.join(self.dest_dir, "etc/locale.conf")
        with open(locale_conf_path, "wt") as locale_conf:
            locale_conf.write('LANG=%s \n' % locale)
            locale_conf.write('LC_COLLATE=C \n')
            
        # Set /etc/vconsole.conf
        vconsole_conf_path = os.path.join(self.dest_dir, "etc/vconsole.conf")
        with open(vconsole_conf_path, "wt") as vconsole_conf:
            vconsole_conf.write('KEYMAP=%s \n' % lang_code)

        self.auto_timesetting()

        # Let's start without using hwdetect for mkinitcpio.conf.
        # I think it should work out of the box most of the time.
        # This way we don't have to fix deprecated hooks.    
        self.queue_event('info', _("Running mkinitcpio"))
        self.run_mkinitcpio()
        
        # TODO: Mirrorlist has to be generated using our rank-mirrorlist script
        # located in /arch and then copy that generated file to the target system.
        # In the CLI installer I'm running this script when the user opens the installer,
        # because it has to search for the 5 fastest mirrors, which takes time.
        
        # Ok, we already did this before, in another thread
        
        # Call post-install script
        script_path_postinstall = os.path.join(self.settings.get("CNCHI_DIR"), \
            "scripts", _postinstall_script)
        subprocess.check_call(["/bin/bash", script_path_postinstall, username, self.dest_dir])