Ejemplo n.º 1
0
 def make_local_repo(self, path, package_list, index_name="pisi"):
     index = 0
     for name in package_list:
         package = self.packages[name]
         xterm_title("Fetching : %s - %s of %s" %
                     (name, index, len(package_list)))
         console = Console()
         cached = fetch_uri(self.base_uri, self.cache_dir, package.uri,
                            console)
         if not os.path.exists(os.path.join(path,
                                            os.path.basename(cached))):
             os.symlink(cached, os.path.join(path,
                                             os.path.basename(cached)))
         index += 1
     index = self.make_index(package_list)
     import bz2
     data = bz2.compress(index)
     import hashlib
     f = file(os.path.join(path, "%s-index.xml.bz2") % index_name, "w")
     f.write(data)
     f.close()
     f = file(
         os.path.join(path, "%s-index.xml.bz2.sha1sum") % index_name, "w")
     s = hashlib.sha1()
     s.update(data)
     f.write(s.hexdigest())
     f.close()
Ejemplo n.º 2
0
def make(project):
    make_image(project)
    if project.type == "install":
        make_install_repo(project)
    make_iso(project)
    print "ISO is ready!"
    xterm_title("ISO is ready")
Ejemplo n.º 3
0
 def make_local_repo(self, path, package_list, index_name="pisi"):
     index = 0
     for name in package_list:
         package = self.packages[name]
         xterm_title("Fetching : %s - %s of %s" % (name, index, len(package_list)))
         console = Console()
         cached = fetch_uri(self.base_uri, self.cache_dir, package.uri, console)
         subpath = os.path.dirname(package.uri)
         if not os.path.exists(os.path.join(path, subpath, os.path.basename(cached))):
             if not os.path.exists(os.path.join(path, subpath)):
                 os.makedirs(os.path.join(path, subpath))
             os.symlink(cached, os.path.join(path, subpath, os.path.basename(cached)))
         index += 1
     index = self.make_index(package_list)
     import bz2
     data = bz2.compress(index)
     import hashlib
     f = file(os.path.join(path, "%s-index.xml.bz2") % index_name, "w")
     f.write(data)
     f.close()
     f = file(os.path.join(path, "%s-index.xml.bz2.sha1sum") % index_name, "w")
     s = hashlib.sha1()
     s.update(data)
     f.write(s.hexdigest())
     f.close()
Ejemplo n.º 4
0
def make_iso(project):
    print "Preparing ISO..."
    xterm_title("Preparing ISO")
    
    try:
        iso_dir = project.iso_dir(clean=True)
        iso_file = project.iso_file(clean=True)
        image_dir = project.image_dir()
        image_file = project.image_file()
        
        os.link(image_file, os.path.join(iso_dir, "pardus.img"))
        
        def copy(src, dest):
            run('cp -PR "%s" "%s"' % (src, os.path.join(iso_dir, dest)))
        
        if project.release_files:
            path = project.release_files
            for name in os.listdir(path):
                if name != ".svn":
                    copy(os.path.join(path, name), name)
        
        setup_grub(project)
        
        if project.type == "install":
            run('ln -s "%s" "%s"' % (project.install_repo_dir(), os.path.join(iso_dir, "repo")))
        
        run('mkisofs -f -J -joliet-long -R -l -V "Pardus" -o "%s" -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table "%s"' % (
            iso_file,
            iso_dir,
        ))
    except KeyboardInterrupt:
        print "Keyboard Interrupt: make_iso() cancelled."
        sys.exit(1)
Ejemplo n.º 5
0
def check_repo_files(project):
    print "Checking image repo..."
    xterm_title("Checking image repo")

    try:
        repo = project.get_repo()
        repo_dir = project.image_repo_dir()
        if project.type == "install":
            imagedeps = repo.full_deps("yali")
        else:
            imagedeps = project.all_packages
        i = 0
        for name in imagedeps:
            i += 1
            sys.stdout.write("\r%-70.70s" % "Checking %d of %s packages" % (i, len(imagedeps)))
            sys.stdout.flush()
            pak = repo.packages[name]
            check_file(repo_dir, pak.uri, pak.sha1sum)
        sys.stdout.write("\n")
        
        if project.type == "install":
            repo_dir = project.install_repo_dir()
            i = 0
            for name in project.all_packages:
                i += 1
                sys.stdout.write("\r%-70.70s" % "Checking %d of %s packages" % (i, len(project.all_packages)))
                sys.stdout.flush()
                pak = repo.packages[name]
                check_file(repo_dir, pak.uri, pak.sha1sum)
        sys.stdout.write("\n")
    except KeyboardInterrupt:
        print "Keyboard Interrupt: check_repo() cancelled."
        sys.exit(1)
Ejemplo n.º 6
0
def generate_grub_conf(project, kernel, initramfs):
    print "Generating grub.conf files..."
    xterm_title("Generating grub.conf files")
    
    image_dir = project.image_dir()
    iso_dir = project.iso_dir()
    
    dict = {}
    dict["kernel"] = kernel
    dict["initramfs"] = initramfs
    dict["title"] = project.title
    dict["exparams"] = project.exparams

    path = os.path.join(image_dir, "usr/share/grub/templates")
    dest = os.path.join(iso_dir, "boot/grub")
    for name in os.listdir(path):
        if name.startswith("menu"):
            data = file(os.path.join(path, name)).read()
            f = file(os.path.join(dest, name), "w")
            f.write(data % dict)
            f.close()
Ejemplo n.º 7
0
 def make_local_repo(self, path, package_list):
     index = 0
     for name in package_list:
         p = self.packages[name]
         xterm_title("Fetching: %s - %s of %s" % (name, index, len(package_list)))
         con = Console()
         cached = fetch_uri(self.base_uri, self.cache_dir, p.uri, con)
         os.symlink(cached, os.path.join(path, os.path.basename(cached)))
         index += 1
     index = self.make_index(package_list)
     import bz2
     data = bz2.compress(index)
     import sha
     f = file(os.path.join(path, "pisi-index.xml.bz2"), "w")
     f.write(data)
     f.close()
     f = file(os.path.join(path, "pisi-index.xml.bz2.sha1sum"), "w")
     s = sha.new()
     s.update(data)
     f.write(s.hexdigest())
     f.close()
Ejemplo n.º 8
0
def make_repos(project):
    print "Preparing image repo..."
    xterm_title("Preparing image repo")
    
    try:
        repo = project.get_repo()
        repo_dir = project.image_repo_dir(clean=True)
        if project.type == "install":
            imagedeps = repo.full_deps("yali")
        else:
            imagedeps = project.all_packages
        repo.make_local_repo(repo_dir, imagedeps)
        
        if project.type == "install":
            xterm_title("Preparing installination repo")
            print "Preparing installation repository..."
            
            repo_dir = project.install_repo_dir(clean=True)
            repo.make_local_repo(repo_dir, project.all_packages)
    except KeyboardInterrupt:
        print "Keyboard Interrupt: make_repo() cancelled."
        sys.exit(1)
Ejemplo n.º 9
0
def setup_isolinux(project):
    print "Generating isolinux files..."
    xterm_title("Generating isolinux files")

    image_dir = project.image_dir()
    iso_dir = project.iso_dir()
    kernel = ""
    initramfs = ""

    # Setup dir
    path = os.path.join(iso_dir, "boot/isolinux")
    if not os.path.exists(path):
        os.makedirs(path)

    def copy(src, dest):
        run('cp -P "%s" "%s"' % (src, os.path.join(iso_dir, dest)))

    # Copy the kernel and initramfs
    path = os.path.join(image_dir, "boot")
    for name in os.listdir(path):
        if name.startswith("kernel") or name.startswith("initramfs") or name.endswith(".bin"):
            if name.startswith("kernel"):
                copy(os.path.join(path, name), "boot/kernel")
            elif name.startswith("initramfs"):
                copy(os.path.join(path, name), "boot/initrd")

    tmplpath = os.path.join(image_dir, "usr/share/gfxtheme/pardus/install")
    dest = os.path.join(iso_dir, "boot/isolinux")
    for name in os.listdir(tmplpath):
        if name != "gfxboot.cfg":
            copy(os.path.join(tmplpath, name), dest)

    # copy config and gfxboot stuff
    generate_isolinux_conf(project)

    copy(os.path.join(image_dir, "usr/lib/syslinux/isolinux-debug.bin"), "%s/isolinux.bin" % dest)
    copy(os.path.join(image_dir, "boot/memtest"), os.path.join(iso_dir, "boot"))
Ejemplo n.º 10
0
def make_image(project):
    print "Preparing install image..."
    xterm_title("Preparing install image")
   
    try:
        repo = project.get_repo()
        repo_dir = project.image_repo_dir()
        image_file = project.image_file()
        
        image_dir = project.image_dir()
        run('umount %s/proc' % image_dir, ignore_error=True)
        run('umount %s/sys' % image_dir, ignore_error=True)
        image_dir = project.image_dir(clean=True)
        
        run('pisi --yes-all -D"%s" ar pardus-install %s' % (image_dir, repo_dir + "/pisi-index.xml.bz2"))
        if project.type == "install":
            run('pisi --yes-all --ignore-comar -D"%s" it yali' % image_dir)
        else:
            install_packages(project)
        
        def chrun(cmd):
            run('chroot "%s" %s' % (image_dir, cmd))
        
        os.mknod("%s/dev/null" % image_dir, 0666 | stat.S_IFCHR, os.makedev(1, 3))
        os.mknod("%s/dev/console" % image_dir, 0666 | stat.S_IFCHR, os.makedev(5, 1))
        
        path = "%s/usr/share/baselayout/" % image_dir
        path2 = "%s/etc" % image_dir
        for name in os.listdir(path):
            run('cp -p "%s" "%s"' % (os.path.join(path, name), os.path.join(path2, name)))
        run('/bin/mount --bind /proc %s/proc' % image_dir)
        run('/bin/mount --bind /sys %s/sys' % image_dir)
        
        chrun("/sbin/ldconfig")
        chrun("/sbin/update-environment")
        chroot_comar(image_dir)
        chrun("/usr/bin/hav call-package System.Package.postInstall baselayout")
        chrun("/usr/bin/pisi configure-pending")
        
        chrun("hav call User.Manager.setUser uid 0 password pardus")
        if project.type != "install":
            chrun("hav call User.Manager.addUser uid 1000 name pars realname Pardus groups users,wheel,disk,removable,power,pnp,pnpadmin,video,audio password pardus")
        chrun("/usr/bin/comar --stop")
        
        chrun("/sbin/update-modules")
        chrun("/sbin/depmod -a %s-%s" % (repo.packages["kernel"].version, repo.packages["kernel"].release))
        
        path1 = os.path.join(image_dir, "usr/share/baselayout/inittab.live")
        path2 = os.path.join(image_dir, "etc/inittab")
        os.unlink(path2)
        run('mv "%s" "%s"' % (path1, path2))
        
        file(os.path.join(image_dir, "etc/pardus-release"), "w").write("%s\n" % project.title)
        
        if project.type != "install" and "kdebase" in project.all_packages:
            setup_live_kdm(project)
        
        run('umount %s/proc' % image_dir)
        run('umount %s/sys' % image_dir)
    except KeyboardInterrupt:
        print "Keyboard Interrupt: make_image() cancelled."
        sys.exit(1)
Ejemplo n.º 11
0
def make_image(project):
    global bus

    print "Preparing install image..."
    xterm_title("Preparing install image")

    try:
        repo = project.get_repo()
        repo_dir = project.image_repo_dir()
        image_file = project.image_file()

        image_dir = project.image_dir()
        run('umount %s/proc' % image_dir, ignore_error=True)
        run('umount %s/sys' % image_dir, ignore_error=True)
        image_dir = project.image_dir(clean=True)

        run('pisi --yes-all -D"%s" ar pardus-install %s' % (image_dir, repo_dir + "/pisi-index.xml.bz2"))
        if project.type == "install":
            run('pisi --yes-all --ignore-comar -D"%s" it yali4' % image_dir)
            if project.plugin_package:
                plugin_package = project.plugin_package
                run('pisi --yes-all --ignore-comar -D"%s" it %s' % (image_dir, plugin_package))
        else:
            install_packages(project)

        def chrun(cmd):
            run('chroot "%s" %s' % (image_dir, cmd))

        os.mknod("%s/dev/null" % image_dir, 0666 | stat.S_IFCHR, os.makedev(1, 3))
        os.mknod("%s/dev/console" % image_dir, 0666 | stat.S_IFCHR, os.makedev(5, 1))
        os.mknod("%s/dev/random" % image_dir, 0666 | stat.S_IFCHR, os.makedev(1, 8))
        os.mknod("%s/dev/urandom" % image_dir, 0666 | stat.S_IFCHR, os.makedev(1, 9))

        path = "%s/usr/share/baselayout/" % image_dir
        path2 = "%s/etc" % image_dir
        for name in os.listdir(path):
            run('cp -p "%s" "%s"' % (os.path.join(path, name), os.path.join(path2, name)))
        run('/bin/mount --bind /proc %s/proc' % image_dir)
        run('/bin/mount --bind /sys %s/sys' % image_dir)

        chrun("/sbin/ldconfig")
        chrun("/sbin/update-environment")
        chroot_comar(image_dir)
        chrun("/usr/bin/pisi configure-pending baselayout")
        chrun("/usr/bin/pisi configure-pending")

        # FIXME : find a generic way to do this
        if "kdebase4" in project.all_packages:
            # Disable Nepomuk in live CDs
            if project.type == "live":
                os.unlink("%s/usr/kde/4/share/autostart/nepomukserver.desktop" % image_dir)

        if project.type == "install" and "xdm" in project.all_packages:
            # FIXME: Do not hard code installer name
            dm_config = "DISPLAY_MANAGER=yali4"

            # Write default display manager config
            image_dir = project.image_dir()
            dest = os.path.join(image_dir, "etc/default/xdm")

            f = file(dest, "w")
            f.write(dm_config)
            f.close()

        connectToDBus(image_dir)

        obj = bus.get_object("tr.org.pardus.comar", "/package/baselayout")

        obj.setUser(0, "", "", "", "pardus", "", dbus_interface="tr.org.pardus.comar.User.Manager")
        if project.type != "install":
            obj.addUser(1000, "pars", "Panter Pardus", "/home/pars", "/bin/bash", "pardus", ["wheel", "users", "pnp", "pnpadmin", "removable", "disk", "audio", "video", "power", "dialout"], [], [], dbus_interface="tr.org.pardus.comar.User.Manager")

        chrun("/sbin/depmod -a %s-%s" % (repo.packages["kernel"].version, repo.packages["kernel"].release))

        path1 = os.path.join(image_dir, "usr/share/baselayout/inittab.live")
        path2 = os.path.join(image_dir, "etc/inittab")
        os.unlink(path2)
        run('mv "%s" "%s"' % (path1, path2))

        file(os.path.join(image_dir, "etc/pardus-release"), "w").write("%s\n" % project.title)

        if project.type != "install" and ("kdebase" in project.all_packages or "kdebase4" in project.all_packages):
            setup_live_kdm(project)
            setup_live_policykit_conf(project)

        if project.type == "install":
            copyPisiIndex(project)

        # Make sure environment is updated regardless of the booting system, by setting comparison
        # files' atime and mtime to UNIX time 1

        os.utime(os.path.join(image_dir, "etc/profile.env"), (1, 1))

        run('umount %s/proc' % image_dir)
        run('umount %s/sys' % image_dir)
    except KeyboardInterrupt:
        print "Keyboard Interrupt: make_image() cancelled."
        sys.exit(1)
Ejemplo n.º 12
0
def generate_isolinux_conf(project):
    print "Generating isolinux config files..."
    xterm_title("Generating isolinux config files")

    dict = {}
    dict["title"] = project.title
    dict["exparams"] = project.exparams or ''

    image_dir = project.image_dir()
    iso_dir = project.iso_dir()

    lang_default = project.default_language
    lang_all = project.selected_languages

    isolinux_tmpl = """
prompt 1
timeout 200

gfxboot /boot/isolinux/init

label pardus
    kernel /boot/kernel
    append initrd=/boot/initrd root=/dev/ram0 vga=791 splash=silent quiet %(exparams)s

label harddisk
    localboot 0x80

label memtest
    kernel /boot/memtest
"""

    # write isolinux.cfg
    dest = os.path.join(iso_dir, "boot/isolinux/isolinux.cfg")
    data = isolinux_tmpl % dict

    f = file(dest, "w")
    f.write(data % dict)
    f.close()

    # write gfxboot config for title
    data = file(os.path.join(image_dir, "usr/share/gfxtheme/pardus/install/gfxboot.cfg")).read()
    f = file(os.path.join(iso_dir, "boot/isolinux/gfxboot.cfg"), "w")
    f.write(data % dict)
    f.close()

    if len(lang_all) and lang_default != "":
        langdata = ""

        if not lang_default in lang_all:
            lang_all.append(lang_default)

        lang_all.sort()

        for i in lang_all:
            langdata += "%s\n" % i


        # write default language
        f = file(os.path.join(iso_dir, "boot/isolinux/lang"), "w")
        f.write("%s\n" % lang_default)
        f.close()

        # write available languages
        f = file(os.path.join(iso_dir, "boot/isolinux/languages"), "w")
        f.write(langdata)
        f.close()