Exemple #1
0
    def install_important_packages( self ):
        logme( 'ArchlinuxDistro - install_important_packages() - starting' )
        self.package_group_size = 2
        os.system( 'clear' )
        print( 'Chroot into the distro. Try running pacman -Syu. See if it works. Then, exit.' )
        os.system( 'bash' )
        chroot_this( self.mountpoint, 'yes "" 2> /dev/null | pacman -Syu', title_str = self.title_str, status_lst = self.status_lst )
        chroot_this( self.mountpoint, 'yes "" 2>/dev/null | pacman -S --needed --force fakeroot', title_str = self.title_str, status_lst = self.status_lst )
        system_or_die( 'rm -f %s/var/lib/pacman/db.lck; sync; sync; sync; sleep 2; sync; sync; sync; sleep 2' % ( self.mountpoint ) )
        packages_lst = [ r for r in self.important_packages.split( ' ' ) if r != '']
        list_of_groups = [ packages_lst[i:i + self.package_group_size] for i in range( 0, len( packages_lst ), self.package_group_size ) ]
        for lst in list_of_groups:
            s = ''.join( [r + ' ' for r in lst] )
            chroot_this( self.mountpoint, 'yes "" 2>/dev/null | pacman -Syu --needed ' + s, title_str = self.title_str, status_lst = self.status_lst,
                         on_fail = 'Failed to install %s' % ( ''.join( [' ' + r for r in lst] ) ) )
            logme( 'Installed%s OK' % ( ''.join( [' ' + r for r in lst] ) ) )
            self.update_status( '.' )
#                self.update_and_upgrade_all()
#        fix_perl_cpan( self.mountpoint )
#        abort_if_make_is_segfaulting( self.mountpoint )
        chroot_this( self.mountpoint, 'yes "" 2>/dev/null | pacman -Syu --needed --force fakeroot', title_str = self.title_str, status_lst = self.status_lst,
                         on_fail = 'Failed to install fakeroot' )
        for pkg in ( 'shiboken', 'python-pyside' ):
            abort_if_make_is_segfaulting( self.mountpoint )
            self.update_status( '.' )
            self.build_and_install_software_from_archlinux_source( pkg, quiet = False )
        self.update_status_with_newline( 'installed.' )
        chroot_this( self.mountpoint, 'yes "" 2>/dev/null | pacman -Syu --needed --force cgpt', title_str = self.title_str, status_lst = self.status_lst,
                         on_fail = 'Failed to install cgpt' )

        system_or_die( 'rm -Rf %s/var/cache/apt/archives/*' % ( self.mountpoint ) )
Exemple #2
0
def install_iceweasel_mozilla_settings( mountpoint, path ):
    logme( 'install_iceweasel_mozilla_settings(%s,%s) --- entering' % ( mountpoint, path ) )
    dirname = os.path.dirname( path )
    basename = os.path.basename( path )
    username = os.path.basename( path )
    if username[0] == '.':
        username = username[1:]  # just in case the path is '.guest' => user is 'guest'
    assert( path.count( '/' ) == 2 )

    assert( os.path.exists( '%s/home/guest' % ( mountpoint ) ) )
    system_or_die( 'tar -zxf /usr/local/bin/Chrubix/blobs/settings/iceweasel-moz.tgz -C %s%s' % ( mountpoint, path ) )
#    for stub in ( '.gtkrc-2.0', '.config/chromium/Default/Preferences', '.config/chromium/Local State' ):
#        do_a_sed( '%s/home/%s/%s' % ( mountpoint, user_name, stub ), GUEST_HOMEDIR, '/home/%s' % ( user_name ) )

    f = '%s%s/.mozilla/firefox/ygkwzm8s.default/secmod.db' % ( mountpoint, path )
    logme( 'f = %s' % ( f ) )
    assert( os.path.exists( f ) )
    s = r"cat %s | sed s/'\/home\/wharbargl\/'/'\/%s\/%s\/'/ > %s.new" % ( f, dirname.strip( '/' ), basename.strip( '/' ), f )
    logme( 'calling ==> %s' % ( s ) )
    if 0 != os.system( s ):  # do_a_sed() does not work. That's why we are using the sed binary instead.
        logme( 'WARNING - failed to install iceweasel settings for %s' % ( username ) )
        os.system( 'xmessage -buttons OK:0 -default Yes -nearmouse "install_iceweasel_mozilla_settings() is broken" -timeout 30' )
    else:
        system_or_die( 'mv %s.new %s' % ( f, f ) )
    chroot_this( mountpoint, 'chown -R %s %s' % ( username, path ) )
    assert( os.path.exists( f ) )
    logme( 'install_iceweasel_mozilla_settings() --- leaving' )
Exemple #3
0
    def download_package_source( self, package_name, filenames_lst = None ):
        logme( 'ArchlinuxDistro - download_package_source() - starting' )
#        self.update_status(( [ "Downloading %s package into %s OS" % ( package_name, self.name ) ] )
        system_or_die( 'mkdir -p %s/%s/%s' % ( self.mountpoint, self.sources_basedir, package_name ) )
        os.chdir( '%s/%s/%s' % ( self.mountpoint, self.sources_basedir, package_name ) )
        if os.path.isfile( '%s/%s/%s/PKGBUILD' % ( self.mountpoint, self.sources_basedir, package_name ) ):
            self.update_status( '' )  # += "."  # ..Still working"  # No need to download anything. We have PKGBUILD already.
        elif filenames_lst in ( None, [] ):
            url = 'aur.archlinux.org/packages/%s/%s/%s.tar.gz' % ( package_name[:2], package_name, package_name )
            wget( url = url, extract_to_path = '%s/%s' % ( self.mountpoint, self.sources_basedir ), quiet = True , title_str = self.title_str, status_lst = self.status_lst )
        else:
            for fname in filenames_lst:
                file_to_download = '%s/%s/%s/%s' % ( self.mountpoint, self.sources_basedir, package_name, fname )
                try:
                    os.unlink( file_to_download )
                except IOError:
                    pass
                wget( url = 'http://projects.archlinux.org/svntogit/packages.git/plain/trunk/%s?h=packages/%s' \
                                 % ( fname, package_name ), save_as_file = file_to_download, attempts = 20,
                                 quiet = True, title_str = self.title_str, status_lst = self.status_lst )
        system_or_die( 'mv PKGBUILD PKGBUILD.ori' )
        system_or_die( r"cat PKGBUILD.ori | sed s/march/phr34k/ | sed s/\'libutil-linux\'// | sed s/\'java-service-wrapper\'// | sed s/arch=\(.*/arch=\(\'%s\'\)/ | sed s/phr34k/march/ > PKGBUILD" % ( self.architecture ) )
        chroot_this( self.mountpoint, 'chown -R guest %s/%s' % ( self.sources_basedir, package_name ) )
        call_makepkg_or_die( mountpoint = self.mountpoint, \
                            package_path = '%s/%s' % ( self.sources_basedir, package_name ), \
                            cmd = 'cd %s/%s && makepkg --skipchecksums --nobuild -f' % ( self.sources_basedir, package_name ),
                            errtxt = 'Failed to download %s' % ( package_name ) )
        return 0
Exemple #4
0
    def configure_distrospecific_tweaks( self ):
        logme( 'ArchlinuxDistro - configure_distrospecific_tweaks() - starting' )
        self.update_status_with_newline( 'Installing distro-specific tweaks' )
        friendly_list_of_packages_to_exclude = ''.join( r + ' ' for r in self.list_of_mkfs_packages ) + os.path.basename( self.kernel_src_basedir )
        do_a_sed( '%s/etc/pacman.conf' % ( self.mountpoint ), '#.*IgnorePkg.*', 'IgnorePkg = %s' % ( friendly_list_of_packages_to_exclude ) )
        chroot_this( self.mountpoint, 'systemctl enable lxdm.service' )
#        logme( 'FYI, ArchLinux has no distro-specific post-install tweaks at present' )
        self.update_status_with_newline( '...tweaked.' )
Exemple #5
0
    def install_important_packages(self):
        logme('ArchlinuxDistro - install_important_packages() - starting')
        self.package_group_size = 2
        os.system('clear')
        print(
            'Chroot into the distro. Try running pacman -Syu. See if it works. Then, exit.'
        )
        os.system('bash')
        chroot_this(self.mountpoint,
                    'yes "" 2> /dev/null | pacman -Syu',
                    title_str=self.title_str,
                    status_lst=self.status_lst)
        chroot_this(self.mountpoint,
                    'yes "" 2>/dev/null | pacman -S --needed --force fakeroot',
                    title_str=self.title_str,
                    status_lst=self.status_lst)
        system_or_die(
            'rm -f %s/var/lib/pacman/db.lck; sync; sync; sync; sleep 2; sync; sync; sync; sleep 2'
            % (self.mountpoint))
        packages_lst = [
            r for r in self.important_packages.split(' ') if r != ''
        ]
        list_of_groups = [
            packages_lst[i:i + self.package_group_size]
            for i in range(0, len(packages_lst), self.package_group_size)
        ]
        for lst in list_of_groups:
            s = ''.join([r + ' ' for r in lst])
            chroot_this(self.mountpoint,
                        'yes "" 2>/dev/null | pacman -Syu --needed ' + s,
                        title_str=self.title_str,
                        status_lst=self.status_lst,
                        on_fail='Failed to install %s' %
                        (''.join([' ' + r for r in lst])))
            logme('Installed%s OK' % (''.join([' ' + r for r in lst])))
            self.update_status('.')
#                self.update_and_upgrade_all()
#        fix_perl_cpan( self.mountpoint )
#        abort_if_make_is_segfaulting( self.mountpoint )
        chroot_this(
            self.mountpoint,
            'yes "" 2>/dev/null | pacman -Syu --needed --force fakeroot',
            title_str=self.title_str,
            status_lst=self.status_lst,
            on_fail='Failed to install fakeroot')
        for pkg in ('shiboken', 'python-pyside'):
            abort_if_make_is_segfaulting(self.mountpoint)
            self.update_status('.')
            self.build_and_install_software_from_archlinux_source(pkg,
                                                                  quiet=False)
        self.update_status_with_newline('installed.')
        chroot_this(self.mountpoint,
                    'yes "" 2>/dev/null | pacman -Syu --needed --force cgpt',
                    title_str=self.title_str,
                    status_lst=self.status_lst,
                    on_fail='Failed to install cgpt')

        system_or_die('rm -Rf %s/var/cache/apt/archives/*' % (self.mountpoint))
Exemple #6
0
    def install_kernel_and_mkfs ( self ):
        # Technically, this won't install Linux-latest, which wasn't built with makepkg's help anyway. However, it WILL install
        # 3.4.0-ARCH (built w/ makepkg). Two kernels wait in PKGBUILDs/ore: one in linux-latest, the other in linux-chromebook.
        logme( 'ArchlinuxDistro - install_kernel_and_mkfs() - starting' )
        chroot_this( self.mountpoint, r'yes "" 2>/dev/null | pacman -U `find %s | grep -x ".*\.tar\.xz"`' % ( self.sources_basedir ), title_str = self.title_str, status_lst = self.status_lst )
#         if self.use_latest_kernel:
#             chroot_this( self.mountpoint, 'cd %s/linux-latest && make install && make modules_install' % ( self.sources_basedir ),
#                          title_str = self.title_str, status_lst = self.status_lst,
#                          on_fail = "Failed to install the standard ChromeOS kernel and/or modules" )
        self.update_status_with_newline( '...kernel installed.' )
Exemple #7
0
def add_user_to_the_relevant_groups(username, distro_name, mountpoint):
    for group_to_add_me_to in (
            '%s' % ('debian-tor' if distro_name == 'debian' else 'tor'),
            'freenet', 'audio', 'pulse-access', 'pulse', 'users'):
        logme('Adding %s to %s' % (username, group_to_add_me_to))
        #        if group_to_add_me_to != 'pulse-access' and 0 !=
        chroot_this(mountpoint,
                    'usermod -a -G %s %s 2> /dev/null' %
                    (group_to_add_me_to, username),
                    attempts=1)
Exemple #8
0
 def configure_distrospecific_tweaks(self):
     logme('ArchlinuxDistro - configure_distrospecific_tweaks() - starting')
     self.update_status_with_newline('Installing distro-specific tweaks')
     friendly_list_of_packages_to_exclude = ''.join(
         r + ' ' for r in self.list_of_mkfs_packages) + os.path.basename(
             self.kernel_src_basedir)
     do_a_sed('%s/etc/pacman.conf' % (self.mountpoint), '#.*IgnorePkg.*',
              'IgnorePkg = %s' % (friendly_list_of_packages_to_exclude))
     chroot_this(self.mountpoint, 'systemctl enable lxdm.service')
     #        logme( 'FYI, ArchLinux has no distro-specific post-install tweaks at present' )
     self.update_status_with_newline('...tweaked.')
Exemple #9
0
    def install_final_push_of_packages(self):
        logme('ArchlinuxDistro - install_final_push_of_packages() - starting')
        self.update_status('Installed')
        for my_fname in ('ssss-0.5-3-armv7h.pkg.tar.xz',
                         'florence-0.6.2-1-armv7h.pkg.tar.xz'):
            try:
                system_or_die(
                    'cp /usr/local/bin/Chrubix/blobs/apps/%s /%s/tmp/' %
                    (my_fname, self.mountpoint))
            except RuntimeError:
                wget( url = 'https://dl.dropboxusercontent.com/u/59916027/chrubix/%s' % ( my_fname ), \
                save_as_file = '%s/tmp/%s' % ( self.mountpoint, my_fname ), \
                status_lst = self.status_lst, \
                title_str = self.title_str )
            if 0 == chroot_this(self.mountpoint,
                                'yes "" | pacman -U /tmp/%s' % (my_fname)):
                self.update_status(' ' + my_fname.split('-')[0])
#            else:
#                failed( 'Failed to install ' + my_fname.split( '-' )[0])
#        perl-cpan-meta-check perl-class-load-xs perl-eval-closure perl-mro-compat perl-package-depreciationmanager perl-sub-name perl-task-weaken \
# perl-test-checkdeps perl-test-without-module perl-moose
        failed_pkgs = self.install_from_AUR
        attempts = 0
        while failed_pkgs != '' and attempts < 5:
            self.update_and_upgrade_all()
            attempts += 1
            packages_to_install = failed_pkgs
            failed_pkgs = ''
            for pkg_name in packages_to_install.split(' '):
                if pkg_name in (None, '', ' '):
                    continue
                try:
                    self.build_and_install_software_from_archlinux_source(
                        pkg_name, quiet=True)
                    self.update_status(' %s' % (pkg_name))
                except RuntimeError:
                    failed_pkgs += ' %s' % (pkg_name)
        self.update_status('...OK.')
        if failed_pkgs != '':
            self.update_status(
                ['Warning - failed to install%s' % (failed_pkgs)])
#        self.update_status(' etc. ')
#        self.update_status(( ['Installing %s' % ( self.final_push_packages.replace( '  ', ' ' ).replace( ' ', ', ' ) )] )
        chroot_this(self.mountpoint,
                    'yes "" 2>/dev/null | pacman -S --needed %s' %
                    (self.final_push_packages),
                    title_str=self.title_str,
                    status_lst=self.status_lst,
                    on_fail='Failed to install final push of packages',
                    attempts=20)
        self.update_and_upgrade_all()
        self.update_status_with_newline('...complete.')
Exemple #10
0
    def install_debianspecific_package_manager_tweaks(self):
        #        f = open('%s/etc/apt/sources.list' % ( self.mountpoint ), 'a')
        #        f.write(''' ''')
        #        f.close()
        chroot_this(self.mountpoint, '')
        if g_proxy is not None:
            f = open('%s/etc/apt/apt.conf' % (self.mountpoint), 'a')
            f.write('''
Acquire::http::Proxy "http://%s/";
Acquire::ftp::Proxy  "ftp://%s/";
Acquire::https::Proxy "https://%s/";
''' % (g_proxy, g_proxy, g_proxy))
            f.close()
Exemple #11
0
    def install_debianspecific_package_manager_tweaks( self ):
#        f = open('%s/etc/apt/sources.list' % ( self.mountpoint ), 'a')
#        f.write(''' ''')
#        f.close()
        chroot_this( self.mountpoint, '' )
        if g_proxy is not None:
            f = open( '%s/etc/apt/apt.conf' % ( self.mountpoint ), 'a' )
            f.write( '''
Acquire::http::Proxy "http://%s/";
Acquire::ftp::Proxy  "ftp://%s/";
Acquire::https::Proxy "https://%s/";
''' % ( g_proxy, g_proxy, g_proxy ) )
            f.close()
Exemple #12
0
 def update_and_upgrade_all(self):
     logme('ArchlinuxDistro - update_and_upgrade_all() - starting')
     #        system_or_die( 'sync; sync; sync; sleep 1' )
     system_or_die(
         'rm -f %s/var/lib/pacman/db.lck; sync; sync; sync; sleep 2; sync; sync; sync; sleep 2'
         % (self.mountpoint))
     chroot_this(self.mountpoint,
                 r'yes "" 2>/dev/null | pacman -Syu',
                 "Failed to upgrade OS",
                 attempts=5,
                 title_str=self.title_str,
                 status_lst=self.status_lst)
     system_or_die('sync; sync; sync; sleep 1; sync; sync; sync; sleep 1')
Exemple #13
0
def configure_lxdm_service(mountpoint):
    #    if 0 != chroot_this( mountpoint, 'systemctl enable lxdm', attempts = 1 ):
    if os.path.exists( '%s/etc/systemd/system/display-manager.service' % ( mountpoint ) ) \
    and not os.path.exists( '%s/etc/systemd/system/multi-user.target.wants/display-manager.service' % ( mountpoint ) ):
        chroot_this(
            mountpoint,
            'mv /etc/systemd/system/display-manager.service /etc/systemd/system/multi-user.target.wants/'
        )
    if 0 != chroot_this(
            mountpoint,
            'ln -sf /usr/lib/systemd/system/lxdm.service /etc/systemd/system/multi-user.target.wants/display-manager.service'
    ):
        failed('Failed to enable lxdm')
    for f in ('lxdm', 'display-manager'):
        if os.path.exists('%s/usr/lib/systemd/system/%s.service' %
                          (mountpoint, f)):
            system_or_die('cp %s/usr/lib/systemd/system/%s.service /tmp/' %
                          (mountpoint, f))


#    if os.path.exists( '%s/usr/lib/systemd/system/lxdm.service' % ( mountpoint ) ):
    write_lxdm_service_file('%s/usr/lib/systemd/system/lxdm.service' %
                            (mountpoint))
    chroot_this(mountpoint,
                'which lxdm &> /dev/null',
                on_fail='I cannot find lxdm. This is not good.')
    if chroot_this(mountpoint, 'which kdm &> /dev/null', attempts=1) == 0:
        chroot_this(mountpoint, 'systemctl disable kdm', attempts=1)
Exemple #14
0
 def install_kernel_and_mkfs(self):
     # Technically, this won't install Linux-latest, which wasn't built with makepkg's help anyway. However, it WILL install
     # 3.4.0-ARCH (built w/ makepkg). Two kernels wait in PKGBUILDs/ore: one in linux-latest, the other in linux-chromebook.
     logme('ArchlinuxDistro - install_kernel_and_mkfs() - starting')
     chroot_this(
         self.mountpoint,
         r'yes "" 2>/dev/null | pacman -U `find %s | grep -x ".*\.tar\.xz"`'
         % (self.sources_basedir),
         title_str=self.title_str,
         status_lst=self.status_lst)
     #         if self.use_latest_kernel:
     #             chroot_this( self.mountpoint, 'cd %s/linux-latest && make install && make modules_install' % ( self.sources_basedir ),
     #                          title_str = self.title_str, status_lst = self.status_lst,
     #                          on_fail = "Failed to install the standard ChromeOS kernel and/or modules" )
     self.update_status_with_newline('...kernel installed.')
Exemple #15
0
    def install_important_packages( self ):
        # https://wiki.ubuntu.com/DebootstrapChroot
        for cmd in ( 
                    'apt-get update',
                    'apt-get --no-install-recommends install wget debconf devscripts gnupg nano',
                    'apt-get update',
                    'apt-get install locales dialog',
                    'locale-gen en_US.UTF-8',
                    'add-apt-repository ppa:ubuntuhandbook1/apps',
                    'apt-get update',
                    'apt-get install liferea' ):
            chroot_this( self.mountpoint, 'yes "" | ' + cmd, title_str = self.title_str, status_lst = self.status_lst )
#        failed( 'Aborting for test porpoises' )
#        'tzselect; TZ='Continent/Country'; export TZ
        super( VividUbuntuDistro, self ).install_important_packages()
        self.install_aircrack_ng()
Exemple #16
0
    def install_debianspecific_package_manager_tweaks( self, yes_add_ffmpeg_repo = False ):
        assert( not yes_add_ffmpeg_repo )
        logme( 'UbuntuDistro - install_package_manager_tweaks() - starting' )
#        f = open('%s/etc/apt/sources.list' % ( self.mountpoint ), 'a')
#        f.write(''' ''')
#        f.close()
        chroot_this( self.mountpoint, '' )
        if g_proxy is not None:
            f = open( '%s/etc/apt/apt.conf' % ( self.mountpoint ), 'a' )
            f.write( '''
Acquire::http::Proxy "http://%s/";
Acquire::ftp::Proxy  "ftp://%s/";
Acquire::https::Proxy "https://%s/";
''' % ( g_proxy, g_proxy, g_proxy ) )
            f.close()
        logme( 'UbuntuDistro - install_package_manager_tweaks() - leaving' )
Exemple #17
0
def install_panicbutton_scripting(mountpoint, boomfname):
    #        print( "Configuring acpi" )
    system_or_die('mkdir -p %s/etc/tmpfiles.d' % (mountpoint))
    write_oneliner_file( '%s/etc/tmpfiles.d/brightness.conf' % ( mountpoint ), \
'''f /sys/class/backlight/pwm-backlight.0/brightness 0666 - - - 800
''' )
    powerbuttonpushed_fname = '/usr/local/bin/power_button_pushed.sh'
    write_oneliner_file(
        '%s%s' % (mountpoint, powerbuttonpushed_fname), '''#!/bin/bash
ctrfile=/etc/.pwrcounter
[ -e "$ctrfile" ] || echo 0 > $ctrfile
counter=`cat $ctrfile`
time_since_last_pushed=$((`date +%%s`-`stat -c %%Y $ctrfile`))
[ "$time_since_last_pushed" -le "1" ] || counter=0
counter=$(($counter+1))
echo $counter > $ctrfile
if [ "$counter" -ge "10" ]; then
echo "Power button was pushed 10 times in rapid succession" > %s
exec /usr/local/bin/boom.sh
fi
exit 0
''' % (boomfname))
    system_or_die('chmod +x %s%s' % (mountpoint, powerbuttonpushed_fname))
    # Setup power button (10x => boom)
    handler_sh_file = '%s/etc/acpi/handler.sh' % (mountpoint)
    if os.path.isfile(handler_sh_file):
        # ARCHLINUX
        do_a_sed(handler_sh_file, "logger 'LID closed'",
                 "logger 'LID closed'; systemctl suspend")
        do_a_sed(
            handler_sh_file, "logger 'PowerButton pressed'",
            "logger 'PowerButton pressed'; /usr/local/bin/power_button_pushed.sh"
        )
        system_or_die('chmod +x %s' % (handler_sh_file))
    elif os.path.isdir('%s/etc/acpi/events' % (mountpoint)) and 0 == os.system(
            'cat %s/etc/acpi/powerbtn-acpi-support.sh | fgrep /etc/acpi/powerbtn.sh >/dev/null'
            % (mountpoint)):
        # DEBIAN
        system_or_die('ln -sf %s %s/etc/acpi/powerbtn.sh' %
                      (powerbuttonpushed_fname, mountpoint))
    else:
        failed('How do I hook power button into this distro?')


# activate acpi (sort of)
    chroot_this(mountpoint, 'systemctl enable acpid')
Exemple #18
0
 def download_package_source(self, package_name, filenames_lst=None):
     logme('ArchlinuxDistro - download_package_source() - starting')
     #        self.update_status(( [ "Downloading %s package into %s OS" % ( package_name, self.name ) ] )
     system_or_die('mkdir -p %s/%s/%s' %
                   (self.mountpoint, self.sources_basedir, package_name))
     os.chdir('%s/%s/%s' %
              (self.mountpoint, self.sources_basedir, package_name))
     if os.path.isfile(
             '%s/%s/%s/PKGBUILD' %
         (self.mountpoint, self.sources_basedir, package_name)):
         self.update_status(
             ''
         )  # += "."  # ..Still working"  # No need to download anything. We have PKGBUILD already.
     elif filenames_lst in (None, []):
         url = 'aur.archlinux.org/packages/%s/%s/%s.tar.gz' % (
             package_name[:2], package_name, package_name)
         wget(url=url,
              extract_to_path='%s/%s' %
              (self.mountpoint, self.sources_basedir),
              quiet=True,
              title_str=self.title_str,
              status_lst=self.status_lst)
     else:
         for fname in filenames_lst:
             file_to_download = '%s/%s/%s/%s' % (
                 self.mountpoint, self.sources_basedir, package_name, fname)
             try:
                 os.unlink(file_to_download)
             except IOError:
                 pass
             wget( url = 'http://projects.archlinux.org/svntogit/packages.git/plain/trunk/%s?h=packages/%s' \
                              % ( fname, package_name ), save_as_file = file_to_download, attempts = 20,
                              quiet = True, title_str = self.title_str, status_lst = self.status_lst )
     system_or_die('mv PKGBUILD PKGBUILD.ori')
     system_or_die(
         r"cat PKGBUILD.ori | sed s/march/phr34k/ | sed s/\'libutil-linux\'// | sed s/\'java-service-wrapper\'// | sed s/arch=\(.*/arch=\(\'%s\'\)/ | sed s/phr34k/march/ > PKGBUILD"
         % (self.architecture))
     chroot_this(
         self.mountpoint,
         'chown -R guest %s/%s' % (self.sources_basedir, package_name))
     call_makepkg_or_die( mountpoint = self.mountpoint, \
                         package_path = '%s/%s' % ( self.sources_basedir, package_name ), \
                         cmd = 'cd %s/%s && makepkg --skipchecksums --nobuild -f' % ( self.sources_basedir, package_name ),
                         errtxt = 'Failed to download %s' % ( package_name ) )
     return 0
Exemple #19
0
    def install_i2p( self ):
        failed( 'https://launchpad.net/~i2p-maintainers/+archive/ubuntu/i2p' )
#        chroot_this( self.mountpoint, 'wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2014.2_all.deb -O - > /tmp/debmult.deb', attempts = 1, title_str = self.title_str, status_lst = self.status_lst )
#        chroot_this( self.mountpoint, 'dpkg -i /tmp/debmult.deb', attempts = 1, title_str = self.title_str, status_lst = self.status_lst )
        assert( self.branch in ( 'wheezy', 'jessie' ) )
        write_oneliner_file( '%s/etc/apt/sources.list.d/i2p.list' % ( self.mountpoint ), '''
deb http://deb.i2p2.no/ %s main
deb-src http://deb.i2p2.no/ %s main
''' % ( self.branch, self.branch ) )
        for cmd in ( 
                        'yes 2>/dev/null | add-apt-repository "deb http://deb.i2p2.no/ %s main"' % ( self.branch ),
                        'yes "" 2>/dev/null | curl https://geti2p.net/_static/i2p-debian-repo.key.asc | apt-key add -',
                        'yes 2>/dev/null | apt-get update'
                   ):
            chroot_this( self.mountpoint, cmd, title_str = self.title_str, status_lst = self.status_lst,
                             on_fail = "Failed to run %s successfully" % ( cmd ) )
        chroot_this( self.mountpoint, 'yes | apt-get install i2p i2p-keyring', on_fail = 'Failed to install i2p' )
        logme( 'tweaking i2p ID...' )
        do_a_sed( '%s/etc/passwd' % ( self.mountpoint ), 'i2p:/bin/false', 'i2p:/bin/bash' )
Exemple #20
0
    def install_final_push_of_packages( self ):
        logme( 'ArchlinuxDistro - install_final_push_of_packages() - starting' )
        self.update_status( 'Installed' )
        for my_fname in ( 'ssss-0.5-3-armv7h.pkg.tar.xz', 'florence-0.6.2-1-armv7h.pkg.tar.xz' ):
            try:
                system_or_die( 'cp /usr/local/bin/Chrubix/blobs/apps/%s /%s/tmp/' % ( my_fname, self.mountpoint ) )
            except RuntimeError:
                wget( url = 'https://dl.dropboxusercontent.com/u/59916027/chrubix/%s' % ( my_fname ), \
                save_as_file = '%s/tmp/%s' % ( self.mountpoint, my_fname ), \
                status_lst = self.status_lst, \
                title_str = self.title_str )
            if 0 == chroot_this( self.mountpoint, 'yes "" | pacman -U /tmp/%s' % ( my_fname ) ):
                self.update_status( ' ' + my_fname.split( '-' )[0] )
#            else:
#                failed( 'Failed to install ' + my_fname.split( '-' )[0])
#        perl-cpan-meta-check perl-class-load-xs perl-eval-closure perl-mro-compat perl-package-depreciationmanager perl-sub-name perl-task-weaken \
# perl-test-checkdeps perl-test-without-module perl-moose
        failed_pkgs = self.install_from_AUR
        attempts = 0
        while failed_pkgs != '' and attempts < 5:
            self.update_and_upgrade_all()
            attempts += 1
            packages_to_install = failed_pkgs
            failed_pkgs = ''
            for pkg_name in packages_to_install.split( ' ' ):
                if pkg_name in ( None, '', ' ' ):
                    continue
                try:
                    self.build_and_install_software_from_archlinux_source( pkg_name, quiet = True )
                    self.update_status( ' %s' % ( pkg_name ) )
                except RuntimeError:
                    failed_pkgs += ' %s' % ( pkg_name )
        self.update_status( '...OK.' )
        if failed_pkgs != '':
            self.update_status( ['Warning - failed to install%s' % ( failed_pkgs )] )
#        self.update_status(' etc. ')
#        self.update_status(( ['Installing %s' % ( self.final_push_packages.replace( '  ', ' ' ).replace( ' ', ', ' ) )] )
        chroot_this( self.mountpoint, 'yes "" 2>/dev/null | pacman -S --needed %s' % ( self.final_push_packages ), title_str = self.title_str, status_lst = self.status_lst,
                     on_fail = 'Failed to install final push of packages', attempts = 20 )
        self.update_and_upgrade_all()
        self.update_status_with_newline( '...complete.' )
Exemple #21
0
    def install_final_push_of_packages( self ):
        logme( 'Fedora - install_final_push_of_packages() - starting' )
#        self.build_and_install_software_from_archlinux_source( 'wmsystemtray' )
        self.update_status_with_newline( 'Installing %s' % ( self.final_push_packages.replace( '  ', ' ' ).replace( ' ', ', ' ) ) )
        res = 999
        attempts = 5
        while res != 0 and attempts > 0:
            attempts -= 1
            res = chroot_this( self.mountpoint, 'yes 2>/dev/null | yum install %s' % ( self.final_push_packages ), title_str = self.title_str, status_lst = self.status_lst )
            if res != 0:
                system_or_die( 'rm -f %s/var/lib/pacman/db.lck; sync; sync; sync; sleep 3' % ( self.mountpoint ) )
        assert( attempts > 0 )
Exemple #22
0
    def install_final_push_of_packages( self ):  # See https://twiki.grid.iu.edu/bin/view/Documentation/Release3/YumRpmBasics
        logme( 'Fedora - install_final_push_of_packages() - starting' )
#        self.build_and_install_software_from_archlinux_source( 'wmsystemtray' )
        self.update_status_with_newline( 'Installing %s' % ( self.final_push_packages.replace( '  ', ' ' ).replace( ' ', ', ' ) ) )
        res = 999
        attempts = 5
        while res != 0 and attempts > 0:
            attempts -= 1
            res = chroot_this( self.mountpoint, 'yes 2>/dev/null | yum install %s' % ( self.final_push_packages ), title_str = self.title_str, status_lst = self.status_lst )
            if res != 0:
                system_or_die( 'rm -f %s/var/lib/pacman/db.lck; sync; sync; sync; sleep 3' % ( self.mountpoint ) )
        assert( attempts > 0 )
Exemple #23
0
def configure_lxdm_service( mountpoint ):
#    if 0 != chroot_this( mountpoint, 'systemctl enable lxdm', attempts = 1 ):
    if os.path.exists( '%s/etc/systemd/system/display-manager.service' % ( mountpoint ) ) \
    and not os.path.exists( '%s/etc/systemd/system/multi-user.target.wants/display-manager.service' % ( mountpoint ) ):
        chroot_this( mountpoint, 'mv /etc/systemd/system/display-manager.service /etc/systemd/system/multi-user.target.wants/' )
    if 0 != chroot_this( mountpoint, 'ln -sf /usr/lib/systemd/system/lxdm.service /etc/systemd/system/multi-user.target.wants/display-manager.service' ):
        failed( 'Failed to enable lxdm' )
    for f in ( 'lxdm', 'display-manager' ):
        if os.path.exists( '%s/usr/lib/systemd/system/%s.service' % ( mountpoint, f ) ):
            system_or_die( 'cp %s/usr/lib/systemd/system/%s.service /tmp/' % ( mountpoint, f ) )
#    if os.path.exists( '%s/usr/lib/systemd/system/lxdm.service' % ( mountpoint ) ):
    write_lxdm_service_file( '%s/usr/lib/systemd/system/lxdm.service' % ( mountpoint ) )
    chroot_this( mountpoint, 'which lxdm &> /dev/null', on_fail = 'I cannot find lxdm. This is not good.' )
    if chroot_this( mountpoint, 'which kdm &> /dev/null' , attempts = 1 ) == 0:
        chroot_this( mountpoint, 'systemctl disable kdm', attempts = 1 )
Exemple #24
0
def configure_lxdm_onetime_changes(mountpoint):
    if os.path.exists('%s/etc/.first_time_ever' % (mountpoint)):
        logme('configure_lxdm_onetime_changes() has already run.')
        return
    if 0 != chroot_this(mountpoint, 'which lxdm'):
        failed('You haven ot installed LXDM yet.')
    f = '%s/etc/WindowMaker/WindowMaker' % (mountpoint)
    if os.path.isfile(f):
        do_a_sed(f, 'MouseLeftButton', 'flibbertygibbet')
        do_a_sed(f, 'MouseRightButton', 'MouseLeftButton')
        do_a_sed(f, 'flibbertygibbet', 'MouseRightButton')


#    system_or_die( 'echo "ps wax | fgrep mate-session | fgrep -v grep && mpg123 /etc/.mp3/xpshutdown.mp3" >> %s/etc/lxdm/PreLogout' % ( mountpoint ) )
    append_startx_addendum('%s/etc/lxdm/Xsession' %
                           (mountpoint))  # Append. Don't replace.
    append_startx_addendum('%s/etc/X11/xinit/xinitrc' %
                           (mountpoint))  # Append. Don't replace.
    write_lxdm_pre_login_file(mountpoint,
                              '%s/etc/lxdm/PreLogin' % (mountpoint))
    write_lxdm_post_logout_file('%s/etc/lxdm/PostLogout' % (mountpoint))
    write_lxdm_post_login_file('%s/etc/lxdm/PostLogin' % (mountpoint))
    write_lxdm_pre_reboot_or_shutdown_file(
        '%s/etc/lxdm/PreReboot' % (mountpoint), 'reboot')
    write_lxdm_pre_reboot_or_shutdown_file(
        '%s/etc/lxdm/PreShutdown' % (mountpoint), 'shutdown')
    write_login_ready_file('%s/etc/lxdm/LoginReady' % (mountpoint))
    if 0 == chroot_this( mountpoint, 'which iceweasel > /tmp/.where_is_it.txt' ) \
    or 0 == chroot_this( mountpoint, 'which chromium  > /tmp/.where_is_it.txt' ):
        webbrowser = read_oneliner_file('%s/tmp/.where_is_it.txt' %
                                        (mountpoint)).strip()
        logme('webbrowser = %s' % (webbrowser))
    else:
        failed(
            'Which web browser should I use? I cannot find iceweasel. I cannot find chrome. I cannot find firefox...'
        )
    append_lxdm_xresources_addendum('%s/root/.Xresources' % (mountpoint),
                                    webbrowser)
    system_or_die('echo ". /etc/X11/xinitrc/xinitrc" >> %s/etc/lxdm/Xsession' %
                  (mountpoint))
    do_a_sed('%s/etc/X11/xinit/xinitrc' % (mountpoint), '.*xterm.*', '')
    do_a_sed('%s/etc/X11/xinit/xinitrc' % (mountpoint), 'exec .*',
             '')  # exec /usr/local/bin/ersatz_lxdm.sh' )
    #    system_or_die( 'echo "exec /usr/local/bin/ersatz_lxdm.sh" >> %s/etc/xinitrc/xinitrc' % ( mountpoint ) ) # start (Python) greeter at end of
    write_oneliner_file('%s/etc/.first_time_ever' % (mountpoint), 'yep')
    assert (os.path.exists('%s/etc/lxdm/lxdm.conf' % (mountpoint)))
    chroot_this(mountpoint, 'chmod +x /etc/lxdm/P*')
    chroot_this(mountpoint, 'chmod +x /etc/lxdm/L*')
    if os.path.exists('%s/etc/init/lxdm.conf' % (mountpoint)):
        do_a_sed('%s/etc/init/lxdm.conf' % (mountpoint), 'exec lxdm-binary.*',
                 'exec ersatz_lxdm.sh')
        do_a_sed('%s/etc/init/lxdm.conf' % (mountpoint), '/usr/sbin/lxdm',
                 '/usr/local/bin/ersatz_lxdm.sh')
Exemple #25
0
def install_iceweasel_mozilla_settings(mountpoint, path):
    logme('install_iceweasel_mozilla_settings(%s,%s) --- entering' %
          (mountpoint, path))
    dirname = os.path.dirname(path)
    basename = os.path.basename(path)
    username = os.path.basename(path)
    if username[0] == '.':
        username = username[
            1:]  # just in case the path is '.guest' => user is 'guest'
    assert (path.count('/') == 2)

    assert (os.path.exists('%s/home/guest' % (mountpoint)))
    system_or_die(
        'tar -zxf /usr/local/bin/Chrubix/blobs/settings/iceweasel-moz.tgz -C %s%s'
        % (mountpoint, path))
    #    for stub in ( '.gtkrc-2.0', '.config/chromium/Default/Preferences', '.config/chromium/Local State' ):
    #        do_a_sed( '%s/home/%s/%s' % ( mountpoint, user_name, stub ), GUEST_HOMEDIR, '/home/%s' % ( user_name ) )

    f = '%s%s/.mozilla/firefox/ygkwzm8s.default/secmod.db' % (mountpoint, path)
    logme('f = %s' % (f))
    assert (os.path.exists(f))
    s = r"cat %s | sed s/'\/home\/wharbargl\/'/'\/%s\/%s\/'/ > %s.new" % (
        f, dirname.strip('/'), basename.strip('/'), f)
    logme('calling ==> %s' % (s))
    if 0 != os.system(
            s
    ):  # do_a_sed() does not work. That's why we are using the sed binary instead.
        logme('WARNING - failed to install iceweasel settings for %s' %
              (username))
        os.system(
            'xmessage -buttons OK:0 -default Yes -nearmouse "install_iceweasel_mozilla_settings() is broken" -timeout 30'
        )
    else:
        system_or_die('mv %s.new %s' % (f, f))
    chroot_this(mountpoint, 'chown -R %s %s' % (username, path))
    assert (os.path.exists(f))
    logme('install_iceweasel_mozilla_settings() --- leaving')
Exemple #26
0
def install_panicbutton_scripting( mountpoint, boomfname ):
#        print( "Configuring acpi" )
    system_or_die( 'mkdir -p %s/etc/tmpfiles.d' % ( mountpoint ) )
    write_oneliner_file( '%s/etc/tmpfiles.d/brightness.conf' % ( mountpoint ), \
'''f /sys/class/backlight/pwm-backlight.0/brightness 0666 - - - 800
''' )
    powerbuttonpushed_fname = '/usr/local/bin/power_button_pushed.sh'
    write_oneliner_file( '%s%s' % ( mountpoint, powerbuttonpushed_fname ), '''#!/bin/bash
ctrfile=/etc/.pwrcounter
[ -e "$ctrfile" ] || echo 0 > $ctrfile
counter=`cat $ctrfile`
time_since_last_pushed=$((`date +%%s`-`stat -c %%Y $ctrfile`))
[ "$time_since_last_pushed" -le "1" ] || counter=0
counter=$(($counter+1))
echo $counter > $ctrfile
if [ "$counter" -ge "10" ]; then
echo "Power button was pushed 10 times in rapid succession" > %s
exec /usr/local/bin/boom.sh
fi
exit 0
''' % ( boomfname ) )
    system_or_die( 'chmod +x %s%s' % ( mountpoint, powerbuttonpushed_fname ) )
# Setup power button (10x => boom)
    handler_sh_file = '%s/etc/acpi/handler.sh' % ( mountpoint )
    if os.path.isfile( handler_sh_file ):
        # ARCHLINUX
        do_a_sed( handler_sh_file, "logger 'LID closed'", "logger 'LID closed'; systemctl suspend" )
        do_a_sed( handler_sh_file, "logger 'PowerButton pressed'", "logger 'PowerButton pressed'; /usr/local/bin/power_button_pushed.sh" )
        system_or_die( 'chmod +x %s' % ( handler_sh_file ) )
    elif os.path.isdir( '%s/etc/acpi/events' % ( mountpoint ) )  and 0 == os.system( 'cat %s/etc/acpi/powerbtn-acpi-support.sh | fgrep /etc/acpi/powerbtn.sh >/dev/null' % ( mountpoint ) ):
        # DEBIAN
        system_or_die( 'ln -sf %s %s/etc/acpi/powerbtn.sh' % ( powerbuttonpushed_fname, mountpoint ) )
    else:
        failed( 'How do I hook power button into this distro?' )
# activate acpi (sort of)
    chroot_this( mountpoint, 'systemctl enable acpid' )
Exemple #27
0
 def build_package( self, source_pathname ):
     logme( 'ArchlinuxDistro - build_package() - starting' )
     package_name = os.path.basename( source_pathname )
     package_path = os.path.dirname( source_pathname )
     str_to_add = "Kernel & rootfs" if package_name == 'linux-chromebook' else "%s" % ( package_name )
     self.update_status( '...' + str_to_add )
     chroot_this( self.mountpoint, 'chown -R guest %s/%s' % ( self.sources_basedir, package_name ) )
     chroot_this( self.mountpoint, 'cd %s && makepkg --skipchecksums --noextract -f ' % ( source_pathname ), \
                             "Failed to chroot make %s within %s" % ( package_name, package_path ),
                             title_str = self.title_str, status_lst = self.status_lst ,
                             user = '******' )
     chroot_this( self.mountpoint, 'chown -R root %s/%s' % ( self.sources_basedir, package_name ) )
     self.update_status_with_newline( '...Built.' )
Exemple #28
0
def set_up_guest_homedir( mountpoint = '/', homedir = GUEST_HOMEDIR ):
    logme( 'ersatz_lxdm.py --- set_up_guest_homedir() --- entering' )
    for cmd in ( 
                'mkdir -p %s' % ( homedir ),
                'chmod 700 %s' % ( homedir ),
                'tar -Jxf /usr/local/bin/Chrubix/blobs/settings/default_guest_settings.tar.xz -C %s' % ( homedir ),
                'chown -R guest.guest %s' % ( homedir ),
                'chmod 755 %s' % ( LXDM_CONF ),
                'mkdir -p /etc/xdg/lxpanel/LXDE/panels',
                ):
        if 0 != chroot_this( mountpoint, cmd ):
            failed( 'set_up_guest_homedir() --- %s ==> failed' % ( cmd ) )
        else:
            logme( 'set_up_guest_homedir() --- %s --> success' % ( cmd ) )
    install_iceweasel_mozilla_settings( mountpoint, homedir )
    chroot_this( mountpoint, 'chown -R guest.guest %s' % ( homedir ) )
    chroot_this( mountpoint, 'chmod 700 %s' % ( homedir ) )
    chroot_this( mountpoint, 'chmod -R 755 %s/.[A-Z,a-z]*' % ( homedir ) )
    logme( 'ersatz_lxdm.py --- set_up_guest_homedir() --- leaving' )
Exemple #29
0
def set_up_guest_homedir(mountpoint='/', homedir=GUEST_HOMEDIR):
    logme('ersatz_lxdm.py --- set_up_guest_homedir() --- entering')
    for cmd in (
            'mkdir -p %s' % (homedir),
            'chmod 700 %s' % (homedir),
            'tar -Jxf /usr/local/bin/Chrubix/blobs/settings/default_guest_settings.tar.xz -C %s'
            % (homedir),
            'chown -R guest.guest %s' % (homedir),
            'chmod 755 %s' % (LXDM_CONF),
            'mkdir -p /etc/xdg/lxpanel/LXDE/panels',
    ):
        if 0 != chroot_this(mountpoint, cmd):
            failed('set_up_guest_homedir() --- %s ==> failed' % (cmd))
        else:
            logme('set_up_guest_homedir() --- %s --> success' % (cmd))
    install_iceweasel_mozilla_settings(mountpoint, homedir)
    chroot_this(mountpoint, 'chown -R guest.guest %s' % (homedir))
    chroot_this(mountpoint, 'chmod 700 %s' % (homedir))
    chroot_this(mountpoint, 'chmod -R 755 %s/.[A-Z,a-z]*' % (homedir))
    logme('ersatz_lxdm.py --- set_up_guest_homedir() --- leaving')
Exemple #30
0
 def build_package(self, source_pathname):
     logme('ArchlinuxDistro - build_package() - starting')
     package_name = os.path.basename(source_pathname)
     package_path = os.path.dirname(source_pathname)
     str_to_add = "Kernel & rootfs" if package_name == 'linux-chromebook' else "%s" % (
         package_name)
     self.update_status('...' + str_to_add)
     chroot_this(
         self.mountpoint,
         'chown -R guest %s/%s' % (self.sources_basedir, package_name))
     chroot_this( self.mountpoint, 'cd %s && makepkg --skipchecksums --noextract -f ' % ( source_pathname ), \
                             "Failed to chroot make %s within %s" % ( package_name, package_path ),
                             title_str = self.title_str, status_lst = self.status_lst ,
                             user = '******' )
     chroot_this(
         self.mountpoint,
         'chown -R root %s/%s' % (self.sources_basedir, package_name))
     self.update_status_with_newline('...Built.')
Exemple #31
0
def configure_lxdm_onetime_changes( mountpoint ):
    if os.path.exists( '%s/etc/.first_time_ever' % ( mountpoint ) ):
        logme( 'configure_lxdm_onetime_changes() has already run.' )
        return
    if 0 != chroot_this( mountpoint, 'which lxdm' ):
        failed( 'You haven ot installed LXDM yet.' )
    f = '%s/etc/WindowMaker/WindowMaker' % ( mountpoint )
    if os.path.isfile( f ):
        do_a_sed( f, 'MouseLeftButton', 'flibbertygibbet' )
        do_a_sed( f, 'MouseRightButton', 'MouseLeftButton' )
        do_a_sed( f, 'flibbertygibbet', 'MouseRightButton' )
#    system_or_die( 'echo "ps wax | fgrep mate-session | fgrep -v grep && mpg123 /etc/.mp3/xpshutdown.mp3" >> %s/etc/lxdm/PreLogout' % ( mountpoint ) )
    append_startx_addendum( '%s/etc/lxdm/Xsession' % ( mountpoint ) )  # Append. Don't replace.
    append_startx_addendum( '%s/etc/X11/xinit/xinitrc' % ( mountpoint ) )  # Append. Don't replace.
    write_lxdm_pre_login_file( mountpoint, '%s/etc/lxdm/PreLogin' % ( mountpoint ) )
    write_lxdm_post_logout_file( '%s/etc/lxdm/PostLogout' % ( mountpoint ) )
    write_lxdm_post_login_file( '%s/etc/lxdm/PostLogin' % ( mountpoint ) )
    write_lxdm_pre_reboot_or_shutdown_file( '%s/etc/lxdm/PreReboot' % ( mountpoint ), 'reboot' )
    write_lxdm_pre_reboot_or_shutdown_file( '%s/etc/lxdm/PreShutdown' % ( mountpoint ), 'shutdown' )
    write_login_ready_file( '%s/etc/lxdm/LoginReady' % ( mountpoint ) )
    if 0 == chroot_this( mountpoint, 'which iceweasel > /tmp/.where_is_it.txt' ) \
    or 0 == chroot_this( mountpoint, 'which chromium  > /tmp/.where_is_it.txt' ):
        webbrowser = read_oneliner_file( '%s/tmp/.where_is_it.txt' % ( mountpoint ) ).strip()
        logme( 'webbrowser = %s' % ( webbrowser ) )
    else:
        failed( 'Which web browser should I use? I cannot find iceweasel. I cannot find chrome. I cannot find firefox...' )
    append_lxdm_xresources_addendum( '%s/root/.Xresources' % ( mountpoint ), webbrowser )
    system_or_die( 'echo ". /etc/X11/xinitrc/xinitrc" >> %s/etc/lxdm/Xsession' % ( mountpoint ) )
    do_a_sed( '%s/etc/X11/xinit/xinitrc' % ( mountpoint ), '.*xterm.*', '' )
    do_a_sed( '%s/etc/X11/xinit/xinitrc' % ( mountpoint ), 'exec .*', '' )  # exec /usr/local/bin/ersatz_lxdm.sh' )
#    system_or_die( 'echo "exec /usr/local/bin/ersatz_lxdm.sh" >> %s/etc/xinitrc/xinitrc' % ( mountpoint ) ) # start (Python) greeter at end of
    write_oneliner_file( '%s/etc/.first_time_ever' % ( mountpoint ), 'yep' )
    assert( os.path.exists( '%s/etc/lxdm/lxdm.conf' % ( mountpoint ) ) )
    chroot_this( mountpoint, 'chmod +x /etc/lxdm/P*' )
    chroot_this( mountpoint, 'chmod +x /etc/lxdm/L*' )
    if os.path.exists( '%s/etc/init/lxdm.conf' % ( mountpoint ) ):
        do_a_sed( '%s/etc/init/lxdm.conf' % ( mountpoint ), 'exec lxdm-binary.*', 'exec ersatz_lxdm.sh' )
        do_a_sed( '%s/etc/init/lxdm.conf' % ( mountpoint ), '/usr/sbin/lxdm', '/usr/local/bin/ersatz_lxdm.sh' )
Exemple #32
0
    os.system( 'python3 /usr/local/bin/Chrubix/src/poweroff_if_disk_removed.py' )
elif argv[2] == 'tweak-lxdm-source':
    distro = generate_distro_record_from_name( argv[3] )
    distro.mountpoint = MYDISK_MTPT
    distro.device = '/dev/mmcblk1'
    distro.root_dev = '/dev/mmcblk1p3'
    distro.spare_dev = '/dev/mmcblk1p2'
    p = '%s/%s' % ( distro.sources_basedir, 'lxdm' )
    generate_mickeymouse_lxdm_patch( distro.mountpoint, p, '%s/debian/patches/99_mickeymouse.patch' % ( p ) )
elif argv[2] == 'chromium':
    distro = generate_distro_record_from_name( argv[3] )
    distro.mountpoint = MYDISK_MTPT
    distro.device = '/dev/mmcblk1'
    distro.root_dev = '/dev/mmcblk1p3'
    distro.spare_dev = '/dev/mmcblk1p2'
    chroot_this( distro.mountpoint, 'yes "" 2>/dev/null | apt-get build-dep chromium' )
    distro.build_and_install_package_from_deb_or_ubu_source( 'chromium-browser', 'https://packages.debian.org/' + argv[3] )
elif argv[2] == 'install-bitmask':
    distro = generate_distro_record_from_name( argv[3] )
    distro.mountpoint = MYDISK_MTPT
    distro.device = '/dev/mmcblk1'
    distro.root_dev = '/dev/mmcblk1p3'
    distro.spare_dev = '/dev/mmcblk1p2'
    distro.install_leap_bitmask()
# elif argv[2] == 'download-kernel-source':
#     distro = generate_distro_record_from_name( argv[3] )
#     distro.mountpoint = '/' if os.system( 'cat /proc/cmdline 2>/dev/null | fgrep root=/dev/dm-0 > /dev/null' ) != 0 else MYDISK_MTPT
#     distro.device = '/dev/mmcblk1'
#     distro.root_dev = '/dev/mmcblk1p3'
#     distro.spare_dev = '/dev/mmcblk1p2'
#     distro.kernel_rebuild_required = True  # ...because the initramfs needs our boom pw, which means we'll have to rebuild initramfs.... which means rebuilding kernel!
Exemple #33
0
elif argv[2] == 'tweak-lxdm-source':
    distro = generate_distro_record_from_name(argv[3])
    distro.mountpoint = MYDISK_MTPT
    distro.device = '/dev/mmcblk1'
    distro.root_dev = '/dev/mmcblk1p3'
    distro.spare_dev = '/dev/mmcblk1p2'
    p = '%s/%s' % (distro.sources_basedir, 'lxdm')
    generate_mickeymouse_lxdm_patch(
        distro.mountpoint, p, '%s/debian/patches/99_mickeymouse.patch' % (p))
elif argv[2] == 'chromium':
    distro = generate_distro_record_from_name(argv[3])
    distro.mountpoint = MYDISK_MTPT
    distro.device = '/dev/mmcblk1'
    distro.root_dev = '/dev/mmcblk1p3'
    distro.spare_dev = '/dev/mmcblk1p2'
    chroot_this(distro.mountpoint,
                'yes "" 2>/dev/null | apt-get build-dep chromium')
    distro.build_and_install_package_from_deb_or_ubu_source(
        'chromium-browser', 'https://packages.debian.org/' + argv[3])
elif argv[2] == 'install-bitmask':
    distro = generate_distro_record_from_name(argv[3])
    distro.mountpoint = MYDISK_MTPT
    distro.device = '/dev/mmcblk1'
    distro.root_dev = '/dev/mmcblk1p3'
    distro.spare_dev = '/dev/mmcblk1p2'
    distro.install_leap_bitmask()
# elif argv[2] == 'download-kernel-source':
#     distro = generate_distro_record_from_name( argv[3] )
#     distro.mountpoint = '/' if os.system( 'cat /proc/cmdline 2>/dev/null | fgrep root=/dev/dm-0 > /dev/null' ) != 0 else MYDISK_MTPT
#     distro.device = '/dev/mmcblk1'
#     distro.root_dev = '/dev/mmcblk1p3'
#     distro.spare_dev = '/dev/mmcblk1p2'
Exemple #34
0
def remove_junk(mountpoint, kernel_src_basedir):
    #    system_or_die( 'rm -Rf %s%s/*/.git' % ( mountpoint, os.path.dirname( kernel_src_basedir ) ) )
    #    chroot_this( mountpoint, 'cd /usr/include && mv linux ../_linux_ && rm -Rf * && mv ../_linux_ linux' )
    for path in (
            '/var/cache/pacman/pkg',
            '/var/cache/apt/archives/',
            '/usr/share/gtk-doc',
            '/usr/share/doc',
            #                    '/usr/share/man',
            #                    kernel_src_basedir + '/src/chromeos-3.4/Documentation',    <-- needed for recompiling kernel (don't ask me why)
            '/usr/src/linux-3.4.0-ARCH',
            kernel_src_basedir + '/*.tar.gz',
            #                    os.path.dirname( kernel_src_basedir ) + '/linux-[a-b,d-z]*' # THIS DOESN'T DO ANYTHING.
    ):
        chroot_this(mountpoint, 'rm -Rf %s' % (path))


#        if not os.path.exists( '%s%s' % ( mountpoint, kernel_src_basedir ) ):
#            failed( 'rm -Rf %s ==> deletes the linux-chromebook folder from the bootstrap OS. That is suboptimal' % ( path ) )
    chroot_this(
        mountpoint, 'ln -sf %s/src/chromeos-3.4 /usr/src/linux-3.4.0-ARCH' %
        (kernel_src_basedir))
    chroot_this(mountpoint, 'set -e; cd /usr/share/locale; mv locale.alias ..')
    chroot_this(
        mountpoint,
        'set -e; cd /usr/share/locale; mkdir -p _; mv [a-d,f-z]* _ 2> /dev/null; mv e[a-m,o-z]* _ 2> /dev/null; rm -Rf _; mv ../locale.alias .'
    )
    chroot_this(mountpoint,
                'set -e; cd /usr/share/locale; mv ../locale.alias .',
                attempts=1)
    chroot_this(
        mountpoint,
        'cd /usr/lib/firmware 2>/dev/null && cp s5p-mfc/s5p-mfc-v6.fw ../mfc_fw.bin 2> /dev/null && cp mrvl/sd8797_uapsta.bin .. 2> /dev/null && rm -Rf * && mkdir -p mrvl && mv ../sd8797_uapsta.bin mrvl/ && mv ../mfc_fw.bin .'
    )
Exemple #35
0
def add_user_to_the_relevant_groups( username, distro_name, mountpoint ):
    for group_to_add_me_to in ( '%s' % ( 'debian-tor' if distro_name == 'debian' else 'tor' ), 'freenet', 'audio', 'pulse-access', 'pulse', 'users' ):
        logme( 'Adding %s to %s' % ( username, group_to_add_me_to ) )
#        if group_to_add_me_to != 'pulse-access' and 0 !=
        chroot_this( mountpoint, 'usermod -a -G %s %s 2> /dev/null' % ( group_to_add_me_to, username ), attempts = 1 )
Exemple #36
0
    def update_and_upgrade_all( self ):
        logme( 'ArchlinuxDistro - update_and_upgrade_all() - starting' )
#        system_or_die( 'sync; sync; sync; sleep 1' )
        system_or_die( 'rm -f %s/var/lib/pacman/db.lck; sync; sync; sync; sleep 2; sync; sync; sync; sleep 2' % ( self.mountpoint ) )
        chroot_this( self.mountpoint, r'yes "" 2>/dev/null | pacman -Syu', "Failed to upgrade OS", attempts = 5, title_str = self.title_str, status_lst = self.status_lst )
        system_or_die( 'sync; sync; sync; sleep 1; sync; sync; sync; sleep 1' )
Exemple #37
0
def remove_junk( mountpoint, kernel_src_basedir ):
#    system_or_die( 'rm -Rf %s%s/*/.git' % ( mountpoint, os.path.dirname( kernel_src_basedir ) ) )
#    chroot_this( mountpoint, 'cd /usr/include && mv linux ../_linux_ && rm -Rf * && mv ../_linux_ linux' )
    for path in ( 
                    '/var/cache/pacman/pkg',
                    '/var/cache/apt/archives/',
                    '/usr/share/gtk-doc',
                    '/usr/share/doc',
#                    '/usr/share/man',
#                    kernel_src_basedir + '/src/chromeos-3.4/Documentation',    <-- needed for recompiling kernel (don't ask me why)
                    '/usr/src/linux-3.4.0-ARCH',
                    kernel_src_basedir + '/*.tar.gz',
#                    os.path.dirname( kernel_src_basedir ) + '/linux-[a-b,d-z]*' # THIS DOESN'T DO ANYTHING.
                ):
        chroot_this( mountpoint, 'rm -Rf %s' % ( path ) )
#        if not os.path.exists( '%s%s' % ( mountpoint, kernel_src_basedir ) ):
#            failed( 'rm -Rf %s ==> deletes the linux-chromebook folder from the bootstrap OS. That is suboptimal' % ( path ) )
    chroot_this( mountpoint, 'ln -sf %s/src/chromeos-3.4 /usr/src/linux-3.4.0-ARCH' % ( kernel_src_basedir ) )
    chroot_this( mountpoint, 'set -e; cd /usr/share/locale; mv locale.alias ..' )
    chroot_this( mountpoint, 'set -e; cd /usr/share/locale; mkdir -p _; mv [a-d,f-z]* _ 2> /dev/null; mv e[a-m,o-z]* _ 2> /dev/null; rm -Rf _; mv ../locale.alias .' )
    chroot_this( mountpoint, 'set -e; cd /usr/share/locale; mv ../locale.alias .', attempts = 1 )
    chroot_this( mountpoint, 'cd /usr/lib/firmware 2>/dev/null && cp s5p-mfc/s5p-mfc-v6.fw ../mfc_fw.bin 2> /dev/null && cp mrvl/sd8797_uapsta.bin .. 2> /dev/null && rm -Rf * && mkdir -p mrvl && mv ../sd8797_uapsta.bin mrvl/ && mv ../mfc_fw.bin .' )