summaryrefslogtreecommitdiffstats
path: root/scripts/basic/Makefile
blob: 092a8876d6028bd6b6ab8169b79b6782a56631bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# SPDX-License-Identifier: GPL-2.0
###
# Makefile.basic lists the most basic programs used during the build process.
# The programs listed herein are what are needed to do the basic stuff,
# such as fix file dependencies.
# This initial step is needed to avoid files to be recompiled
# when kernel configuration changes (which is what happens when
# .config is included by main Makefile.
# ---------------------------------------------------------------------------
# fixdep: 	 Used to generate dependency information during build process

hostprogs-y	:= fixdep
always		:= $(hostprogs-y)

# fixdep is needed to compile other host programs
$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
#n69'>69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936
#
# packages.py: package management - mainly package installation
#
# Erik Troan <ewt@redhat.com>
# Matt Wilson <msw@redhat.com>
# Michael Fulbright <msf@redhat.com>
# Jeremy Katz <katzj@redhat.com>
#
# Copyright 2001-2003 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

import iutil
import isys
import rpm
import os
import timer
import time
import sys
import string
import pcmcia
import language
import fsset
import kudzu
from flags import flags
from product import *
from constants import *
from syslogd import syslog
from hdrlist import PKGTYPE_MANDATORY, PKGTYPE_DEFAULT
from installmethod import FileCopyException

from rhpl.translate import _
import rhpl.arch

import logging
log = logging.getLogger("anaconda")

def queryUpgradeContinue(intf, dir):
    if dir == DISPATCH_FORWARD:
        return

    rc = intf.messageWindow(_("Proceed with upgrade?"),
                       _("The file systems of the Linux installation "
                         "you have chosen to upgrade have already been "
                         "mounted. You cannot go back past this point. "
                         "\n\n") + 
                     _( "Would you like to continue with the upgrade?"),
                                      type = "yesno")
    if rc == 0:
        sys.exit(0)
    return DISPATCH_FORWARD

def doPostAction(id, instPath, intf = None):
    id.instClass.postAction(instPath, flags.serial, intf)

def firstbootConfiguration(id, instPath):
    if id.firstboot == FIRSTBOOT_RECONFIG:
        f = open(instPath + '/etc/reconfigSys', 'w+')
        f.close()
    elif id.firstboot == FIRSTBOOT_SKIP:
        f = open(instPath + '/etc/sysconfig/firstboot', 'w+')
        f.write('RUN_FIRSTBOOT=NO')
        f.close()

    return
        

def writeConfiguration(id, instPath):
    log.info("Writing main configuration")
    if not flags.test:
        id.write(instPath)

def writeKSConfiguration(id, instPath):
    log.info("Writing autokickstart file")
    if not flags.test:
	fn = instPath + "/root/anaconda-ks.cfg"
    else:
	fn = "/tmp/anaconda-ks.cfg"

    id.writeKS(fn)

def copyAnacondaLogs(instPath):
    log.info("Copying anaconda logs")
    for (fn, dest) in (("/tmp/anaconda.log", "anaconda.log"),
                       ("/tmp/syslog", "anaconda.syslog"),
                       ("/tmp/ramfs/X.log", "anaconda.xlog")):
        if os.access(fn, os.R_OK):
            try:
                iutil.copyFile(fn, "%s/var/log/%s" %(instPath, dest))
                os.chmod("%s/var/log/%s" %(instPath, dest), 0600)
            except:
                pass

def writeXConfiguration(id, instPath):
    testmode = flags.test

# comment out to test
    if testmode:
        return
# end code to comment to test 
# uncomment to test writing X config in test mode
#    try:
#	os.mkdir("/tmp/etc")
#    except:
#	pass
#    try:
#	os.mkdir("/tmp/etc/X11")
#    except:
#	pass
#    instPath = '/'
# end code for test writing

    if id.xsetup.skipx:
        return

    xserver = id.videocard.primaryCard().getXServer()
    if not xserver:
	return

    log.info("Writing X configuration")
    if not testmode:
        fn = instPath

        if os.access (instPath + "/etc/X11/X", os.R_OK):
            os.rename (instPath + "/etc/X11/X",
                       instPath + "/etc/X11/X.rpmsave")

        try:
            os.unlink (instPath + "/etc/X11/X")
        except OSError:
            pass
            
        os.symlink ("../../usr/X11R6/bin/" + xserver,
			    instPath + "/etc/X11/X")
    else:
        fn = "/tmp/"

    id.xsetup.write(fn+"/etc/X11", id.mouse, id.keyboard)
    id.desktop.write(instPath)

def handleX11Packages(dir, intf, disp, id, instPath):

    if dir == DISPATCH_BACK:
        return
        
    # skip X setup if it is not being installed
    #
    # uncomment this block if you want X configuration to be presented
    #
# START BLOCK
#     if (not id.grpset.hdrlist.has_key('XFree86') or
#         not id.grpset.hdrlist['XFree86'].isSelected()):
#         disp.skipStep("videocard")
#         disp.skipStep("monitor")
#         disp.skipStep("xcustom")
#         disp.skipStep("writexconfig")
#         id.xsetup.skipx = 1
#     elif disp.stepInSkipList("videocard"):
#         # if X is being installed, but videocard step skipped
#         # need to turn it back on
#         disp.skipStep("videocard", skip=0)
#         disp.skipStep("monitor", skip=0)
#         disp.skipStep("xcustom", skip=0)
#         disp.skipStep("writexconfig", skip=0)
#         id.xsetup.skipx = 0
# END BLOCK

    # set default runlevel based on packages
    gnomeSelected = (id.grpset.hdrlist.has_key('gnome-session')
                     and id.grpset.hdrlist['gnome-session'].isSelected())
    gdmSelected = (id.grpset.hdrlist.has_key('gdm')
                     and id.grpset.hdrlist['gdm'].isSelected())
    kdeSelected = (id.grpset.hdrlist.has_key('kdebase')
                   and id.grpset.hdrlist['kdebase'].isSelected())
    xinstalled = ((id.grpset.hdrlist.has_key('xorg-x11')
                   and id.grpset.hdrlist['xorg-x11'].isSelected()) or
                  (id.grpset.hdrlist.has_key('XFree86')
                   and id.grpset.hdrlist['XFree86'].isSelected()))

    if gnomeSelected:
        id.desktop.setDefaultDesktop("GNOME")
    elif kdeSelected:
        id.desktop.setDefaultDesktop("KDE")

    if (gdmSelected or kdeSelected) and (xinstalled) and (not flags.serial) and (not flags.virtpconsole):
        id.desktop.setDefaultRunLevel(5)
    else:
        id.desktop.setDefaultRunLevel(3)        

# verifies that monitor is not Unprobed, and if so we can skip monitor question
def checkMonitorOK(monitor, dispatch):
    rc = 0
    if monitor is not None:
	if monitor.getMonitorID() != "Unprobed Monitor":
	    rc = 1

    dispatch.skipStep("monitor", skip=rc)

# sets a reasonable default for X settings.
def setSaneXSettings(xsetup):
    if xsetup is not None and xsetup.xhwstate is not None:
	if not xsetup.imposed_sane_default:
	    # XXX HACK see if we have a user specified LCD display
	    import re
	    
	    regx = re.compile("LCD Panel .*x.*")
	    monid = xsetup.xhwstate.monitor.getMonitorID()
	    lcdres = None
	    if regx.match(monid):
		for testres in ["640x480", "800x600", "1024x480", "1024x768",
				"1280x960", "1280x1024", "1400x1050",
				"1600x1200"]:
		    if string.find(monid, testres) != -1:
			lcdres = testres
			break
		
	    if lcdres is not None:
		xsetup.xhwstate.set_resolution(lcdres)
	    else:
		xsetup.xhwstate.choose_sane_default()
		xsetup.imposed_sane_default = 1
	    
def doMigrateFilesystems(dir, thefsset, diskset, upgrade, instPath):
    if dir == DISPATCH_BACK:
        return DISPATCH_NOOP

    if thefsset.haveMigratedFilesystems():
        return DISPATCH_NOOP

    thefsset.migrateFilesystems (instPath)

    # if we're upgrading, we may need to do lvm device node hackery
    if upgrade:
        thefsset.makeLVMNodes(instPath, trylvm1 = 1)
    

def turnOnFilesystems(dir, thefsset, diskset, partitions, upgrade, instPath):
    if dir == DISPATCH_BACK:
        log.info("unmounting filesystems")
	thefsset.umountFilesystems(instPath)
	return

    if flags.setupFilesystems:
	if not upgrade:
            partitions.doMetaDeletes(diskset)
            thefsset.setActive(diskset)
            if not thefsset.isActive():
                diskset.savePartitions ()
            thefsset.checkBadblocks(instPath)
            if not thefsset.volumesCreated:
                thefsset.createLogicalVolumes(instPath)
            thefsset.formatSwap(instPath)
            thefsset.turnOnSwap(instPath)
	    thefsset.makeFilesystems (instPath)
            thefsset.mountFilesystems (instPath)

def setupTimezone(timezone, upgrade, instPath, dir):
    # we don't need this on an upgrade or going backwards
    if upgrade or (dir == DISPATCH_BACK):
        return

    # dont do this in test mode!
    if flags.test:
	return
    
    os.environ["TZ"] = timezone.tz
    tzfile = "/usr/share/zoneinfo/" + timezone.tz
    if not os.access(tzfile, os.R_OK):
        log.error("unable to set timezone")
    else:
        try:
            iutil.copyFile(tzfile, "/etc/localtime")
        except OSError, (errno, msg):
            log.error("Error copying timezone (from %s): %s" %(tzfile, msg))

    if iutil.getArch() == "s390":
        return
    args = [ "/usr/sbin/hwclock", "--hctosys" ]
    if timezone.utc:
        args.append("-u")
    elif timezone.arc:
        args.append("-a")

    try:
        iutil.execWithRedirect(args[0], args, stdin = None,
                               stdout = "/dev/tty5", stderr = "/dev/tty5")
    except RuntimeError:
        log.error("Failed to set clock")

# do miscellaneous package selections based on other installation selections
def handleMiscPackages(intf, id, dir):
    if dir == DISPATCH_BACK:
        return

    arch = iutil.getArch ()

    # this is a crappy hack, but I don't want bug reports from these people
    if (arch == "i386") and (not id.grpset.hdrlist.has_key("kernel")):
        intf.messageWindow(_("Error"),
                           _("You are trying to install on a machine "
                             "which isn't supported by this release of "
                             "%s.") %(productName,),
                           type="custom", custom_icon="error",
                           custom_buttons=[_("_Exit")])
        sys.exit(0)

    # shorthand
    upgrade = id.getUpgrade()

    def select(hdrlist, name):
        if hdrlist.has_key(name):
            hdrlist[name].select(isManual = 1)
            return 1
        return 0

    def selected(hdrlist, name):
        if hdrlist.has_key(name) and hdrlist[name].isSelected():
            return 1
        return 0

    if not upgrade:
        foundkernel = 0
	if isys.smpAvailable() or isys.htavailable():
            if id.grpset.hdrlist.has_key("kernel-smp") and \
               id.grpset.hdrlist["kernel-smp"][rpm.RPMTAG_ARCH] == \
               id.grpset.hdrlist["kernel"][rpm.RPMTAG_ARCH]:
                if select(id.grpset.hdrlist, 'kernel-smp'):
                    foundkernel = 1
                    if selected(id.grpset.hdrlist, "gcc"):
                        select(id.grpset.hdrlist, "kernel-smp-devel")

        if foundkernel == 0:
            # we *always* need to have some sort of kernel installed
            select(id.grpset.hdrlist, 'kernel')
            
        if (selected(id.grpset.hdrlist, "gcc") and
            selected(id.grpset.hdrlist, "kernel")):
            select(id.grpset.hdrlist, "kernel-devel")

	# if NIS is configured, install ypbind and dependencies:
	if id.auth.find("--enablenis") != -1:
            select(id.grpset.hdrlist, 'ypbind')
            select(id.grpset.hdrlist, 'yp-tools')
            select(id.grpset.hdrlist, 'portmap')

	if id.auth.find("--enableldap") != -1:
            select(id.grpset.hdrlist, 'nss_ldap')
            select(id.grpset.hdrlist, 'openldap')
            select(id.grpset.hdrlist, 'perl')

	if id.auth.find("--enablekrb5") != -1:
            select(id.grpset.hdrlist, 'pam_krb5')
            select(id.grpset.hdrlist, 'krb5-workstation')
            select(id.grpset.hdrlist, 'krbafs')
            select(id.grpset.hdrlist, 'krb5-libs')

	if id.auth.find("--enablesmbauth") != -1:
            select(id.grpset.hdrlist, 'pam_smb')

        if iutil.getArch() == "i386" and id.bootloader.useGrubVal == 1:
            select(id.grpset.hdrlist, 'grub')
        elif iutil.getArch() == "s390":
            select(id.grpset.hdrlist, 's390utils')
        elif iutil.getArch() == "ppc":
            select(id.grpset.hdrlist, 'yaboot')
        elif iutil.getArch() == "ia64":
            select(id.grpset.hdrlist, 'elilo')

        if pcmcia.pcicType():
            select(id.grpset.hdrlist, 'pcmcia-cs')

        for entry in id.fsset.entries:
            for pkg in entry.fsystem.getNeededPackages():
                if select(id.grpset.hdrlist, pkg):
                    log.info("Needed %s for %s" %(pkg, entry.getMountPoint()))

def doPreInstall(method, id, intf, instPath, dir):
    if dir == DISPATCH_BACK:
        for d in ("/selinux", "/dev"):
            try:
                isys.umount(instPath + d, removeDir = 0)
            except Exception, e:
                log.error("unable to unmount %s: %s" %(d, e))
        return

    if flags.test:
	return

    # shorthand
    upgrade = id.getUpgrade()

    if upgrade:
	# An old mtab can cause confusion (esp if loop devices are
	# in it)
	f = open(instPath + "/etc/mtab", "w+")
	f.close()

        # we really started writing modprobe.conf out before things were
        # all completely ready.  so now we need to nuke old modprobe.conf's
        # if you're upgrading from a 2.4 dist so that we can get the
        # transition right
        if (os.path.exists(instPath + "/etc/modules.conf") and
            os.path.exists(instPath + "/etc/modprobe.conf") and
            not os.path.exists(instPath + "/etc/modprobe.conf.anacbak")):
            log.info("renaming old modprobe.conf -> modprobe.conf.anacbak")
            os.rename(instPath + "/etc/modprobe.conf",
                      instPath + "/etc/modprobe.conf.anacbak")
            

    if method.systemMounted (id.fsset, instPath):
	id.fsset.umountFilesystems(instPath)
	return DISPATCH_BACK

    for i in ( '/var', '/var/lib', '/var/lib/rpm', '/tmp', '/dev', '/etc',
	       '/etc/sysconfig', '/etc/sysconfig/network-scripts',
	       '/etc/X11', '/root', '/var/tmp', '/etc/rpm' ):
	try:
	    os.mkdir(instPath + i)
	except os.error, (errno, msg):
            pass
#            log.error("Error making directory %s: %s" % (i, msg))


    if flags.setupFilesystems:
        # setup /etc/rpm/platform for the post-install environment
        iutil.writeRpmPlatform(instPath)
        
	try:
            # FIXME: making the /var/lib/rpm symlink here is a hack to
            # workaround db->close() errors from rpm
            iutil.mkdirChain("/var/lib")
            for path in ("/var/tmp", "/var/lib/rpm"):
                if os.path.exists(path) and not os.path.islink(path):
                    iutil.rmrf(path)
                if not os.path.islink(path):
                    os.symlink("/mnt/sysimage/%s" %(path,), "%s" %(path,))
                else:
                    log.warning("%s already exists as a symlink to %s" %(path, os.readlink(path),))
	except Exception, e:
	    # how this could happen isn't entirely clear; log it in case
	    # it does and causes problems later
	    log.error("error creating symlink, continuing anyway: %s" %(e,))

        # SELinux hackery (#121369)
        if flags.selinux:
            try:
                os.mkdir(instPath + "/selinux")
            except Exception, e:
                pass
            try:
                isys.mount("/selinux", instPath + "/selinux", "selinuxfs")
            except Exception, e:
                log.error("error mounting selinuxfs: %s" %(e,))

        # we need to have a /dev during install and now that udev is
        # handling /dev, it gets to be more fun.  so just bind mount the
        # installer /dev
        if 1:
            log.warning("no dev package, going to bind mount /dev")
            isys.mount("/dev", "/mnt/sysimage/dev", bindMount = 1)

    # write out the fstab
    if not upgrade:
        id.fsset.write(instPath)
        # rootpath mode doesn't have this file around
        if os.access("/tmp/modprobe.conf", os.R_OK):
            iutil.copyFile("/tmp/modprobe.conf", 
                           instPath + "/etc/modprobe.conf")
        if os.access("/tmp/zfcp.conf", os.R_OK):
            iutil.copyFile("/tmp/zfcp.conf", 
                           instPath + "/etc/zfcp.conf")

    # make a /etc/mtab so mkinitrd can handle certain hw (usb) correctly
    f = open(instPath + "/etc/mtab", "w+")
    f.write(id.fsset.mtab())
    f.close()

#    delay writing migrate adjusted fstab till later, in case
#    rpm transaction set determines they don't have enough space to upgrade
#    else:
#        id.fsset.migratewrite(instPath)

def doPostInstall(method, id, intf, instPath):
    if flags.test:
	return

    w = intf.progressWindow(_("Post Install"),
                            _("Performing post install configuration..."), 6)

    upgrade = id.getUpgrade()
    arch = iutil.getArch ()

    if upgrade:
	logname = '/root/upgrade.log'
    else:
	logname = '/root/install.log'

    instLogName = instPath + logname
    instLog = open(instLogName, "a")
    
    try:
	if not upgrade:
	    w.set(1)

	    copyExtraModules(instPath, id.grpset, id.extraModules)

	    w.set(2)

	    # pcmcia is supported only on i386 at the moment
	    if arch == "i386":
		pcmcia.createPcmciaConfig(
			instPath + "/etc/sysconfig/pcmcia")

            # we need to write out the network bits before kudzu runs
            # to avoid getting devices in the wrong order (#102276)
            id.network.write(instPath)
		       
	    w.set(3)

	    # blah.  If we're on a serial mouse, and we have X, we need to
	    # close the mouse device, then run kudzu, then open it again.

	    # turn it off
	    mousedev = None

	    # XXX currently Bad Things (X async reply) happen when doing
	    # Mouse Magic on Sparc (Mach64, specificly)
	    # The s390 doesn't even have a mouse!
            if os.environ.get('DISPLAY') == ':1' and arch != 'sparc':
		try:
                    import xmouse
		    mousedev = xmouse.get()[0]
		except RuntimeError:
		    pass

	    if mousedev:
		try:
		    os.rename (mousedev, "/dev/disablemouse")
		except OSError:
		    pass
		try:
		    xmouse.reopen()
		except RuntimeError:
		    pass

	    if arch != "s390" and flags.setupFilesystems:
		# we need to unmount usbdevfs before mounting it
		usbWasMounted = iutil.isUSBDevFSMounted()
		if usbWasMounted:
                    isys.umount('/proc/bus/usb', removeDir = 0)

		    # see if unmount suceeded, if not pretent it isnt mounted
		    # because we're screwed anywyas if system is going to
		    # lock up
		    if iutil.isUSBDevFSMounted():
			usbWasMounted = 0
		    
                unmountUSB = 0
                try:
                    isys.mount('/usbfs', instPath+'/proc/bus/usb', 'usbfs')
                    unmountUSB = 1
                except:
                    log.error("Mount of /proc/bus/usb in chroot failed")
                    pass

                argv = [ "/usr/sbin/kudzu", "-q" ]
                if id.grpset.hdrlist.has_key("kernel"):
                    ver = "%s-%s" %(id.grpset.hdrlist["kernel"][rpm.RPMTAG_VERSION],
                                    id.grpset.hdrlist["kernel"][rpm.RPMTAG_RELEASE])
                    argv.extend(["-k", ver])
                
                devnull = os.open("/dev/null", os.O_RDWR)
                iutil.execWithRedirect(argv[0], argv, root = instPath,
                                       stdout = devnull)
                # turn it back on            
                if mousedev:
                    try:
                        os.rename ("/dev/disablemouse", mousedev)
                    except OSError:
                        pass
                    try:
                        xmouse.reopen()
                    except RuntimeError:
                        pass

                if unmountUSB:
                    try:
                        isys.umount(instPath + '/proc/bus/usb', removeDir = 0)
                    except SystemError:
                        # if we fail to unmount, then we should just not
                        # try to remount it.  this protects us from random
                        # suckage
                        usbWasMounted = 0

		if usbWasMounted:
                    isys.mount('/usbfs', '/proc/bus/usb', 'usbfs')

	w.set(4)

        if upgrade and id.dbpath is not None:
            # remove the old rpmdb
	    try:
		iutil.rmrf (id.dbpath)
	    except OSError:
		pass

        if upgrade:
	    # needed for prior systems which were not xinetd based
	    migrateXinetd(instPath, instLogName)

            # needed for prior to 2.6 so that mice have some chance
            # of working afterwards. FIXME: this is a hack
            migrateMouseConfig(instPath, instLogName)

        #if id.grpset.hdrlist.has_key("rhgb") and id.grpset.hdrlist["rhgb"].isSelected():
        #    log.info("rhgb installed, adding to boot loader config")
        #   id.bootloader.args.append("rhgb quiet")

        w.set(5)

        w.set(6)


    finally:
	pass

    if upgrade:
        instLog.write(_("\n\nThe following packages were available in "
                        "this version but NOT upgraded:\n"))
    else:
        instLog.write(_("\n\nThe following packages were available in "
                        "this version but NOT installed:\n"))
        
    # XXX hack - we should really write a proper lvm "config".  but for now
    # just vgscan if they have /sbin/lvm and some appearance of volumes
    if (os.access(instPath + "/sbin/lvm", os.X_OK) and
        os.access(instPath + "/dev/mapper", os.X_OK) and
        len(os.listdir("/dev/mapper")) > 1):
        rc = iutil.execWithRedirect("/sbin/lvm",
                                    ["lvm", "vgscan", "-v"],
                                    stdout = "/dev/tty5",
                                    stderr = "/dev/tty5",
                                    root = instPath,
                                    searchPath = 1)

    # write out info on install method used
    try:
	if id.methodstr is not None:
	    if os.access (instPath + "/etc/sysconfig/installinfo", os.R_OK):
		os.rename (instPath + "/etc/sysconfig/installinfo",
			   instPath + "/etc/sysconfig/installinfo.rpmsave")

	    f = open(instPath + "/etc/sysconfig/installinfo", "w+")
	    f.write("INSTALLMETHOD=%s\n" % (string.split(id.methodstr, ':')[0],))

	    try:
		ii = open("/tmp/isoinfo", "r")
		il = ii.readlines()
		ii.close()
		for line in il:
		    f.write(line)
	    except:
		pass
	    f.close()
	else:
	    log.warning("methodstr not set for some reason")
    except:
	log.error("Failed to write out installinfo")
        
    w.pop ()

    sys.stdout.flush()
    
    if flags.setupFilesystems:
	syslog.stop()

# FIXME: this is a huge gross hack.  hard coded list of files
# created by anaconda so that we can not be killed by selinux
def setFileCons(instPath, partitions):
    import partRequests
    
    if flags.selinux:
        log.info("setting SELinux contexts for anaconda created files")

        files = ["/etc/rpm/platform", "/etc/rpm/macros",
                 "/etc/lilo.conf.anaconda",
                 "/etc/mtab", "/etc/fstab", "/etc/resolv.conf",
                 "/etc/modprobe.conf", "/etc/modprobe.conf~",
                 "/var/log/wtmp", "/var/run/utmp",
                 "/dev/log", "/var/lib/rpm", "/", "/etc/raidtab",
                 "/etc/mdadm.conf"]

        vgs = []
        for entry in partitions.requests:
            if isinstance(entry, partRequests.VolumeGroupRequestSpec):
                vgs.append("/dev/%s" %(entry.volumeGroupName,))

        # ugh, this is ugly
        for dir in ["/var/lib/rpm", "/etc/lvm", "/dev/mapper"] + vgs:
            def addpath(x): return dir + "/" + x

            if not os.path.isdir(instPath + dir):
                continue
            dirfiles = os.listdir(instPath + dir)
            files.extend(map(addpath, dirfiles))
            files.append(dir)

        # blah, to work in a chroot, we need to actually be inside so the
        # regexes will work
        child = os.fork()
        if (not child):
            os.chroot(instPath)
            for f in files:
                if not os.access("%s" %(f,), os.R_OK):
                    log.warning("%s doesn't exist" %(f,))
                    continue
                ret = isys.resetFileContext(f)
                log.info("set fc of %s to %s" %(f, ret))
            os._exit(0)

        try:
            os.waitpid(child, 0)
        except OSError, (num, msg):
            pass
            

    return

# XXX: large hack lies here
def migrateMouseConfig(instPath, instLog):
    if not os.access (instPath + "/usr/sbin/fix-mouse-psaux", os.X_OK):
        return

    argv = [ "/usr/sbin/fix-mouse-psaux" ]

    logfile = os.open (instLog, os.O_APPEND)
    iutil.execWithRedirect(argv[0], argv, root = instPath,
			   stdout = logfile, stderr = logfile)
    os.close(logfile)


def migrateXinetd(instPath, instLog):
    if not os.access (instPath + "/usr/sbin/inetdconvert", os.X_OK):
	return

    if not os.access (instPath + "/etc/inetd.conf.rpmsave", os.R_OK):
	return

    argv = [ "/usr/sbin/inetdconvert", "--convertremaining",
	     "--inetdfile", "/etc/inetd.conf.rpmsave" ]

    logfile = os.open (instLog, os.O_APPEND)
    iutil.execWithRedirect(argv[0], argv, root = instPath,
			   stdout = logfile, stderr = logfile)
    os.close(logfile)

def copyExtraModules(instPath, grpset, extraModules):
    kernelVersions = grpset.kernelVersionList()
    foundModule = 0

    try:
        f = open("/etc/arch")
        arch = f.readline().strip()
        del f
    except IOError:
        arch = os.uname()[2]

    for (path, name) in extraModules:
        if not path:
            path = "/modules.cgz"
	pattern = ""
	names = ""
	for (n, tag) in kernelVersions:
            if tag == "up":
                pkg = "kernel"
            else:
                pkg = "kernel-%s" %(tag,)
            arch = grpset.hdrlist[pkg][rpm.RPMTAG_ARCH]
            # version 1 path
            pattern = pattern + " %s/%s/%s.ko " % (n, arch, name)
            # version 0 path
            pattern = pattern + " %s/%s.ko " % (n, name)
            names = names + " %s.ko" % (name,)
	command = ("cd %s/lib/modules; gunzip < %s | "
                   "%s/bin/cpio --quiet -iumd %s" % 
                   (instPath, path, instPath, pattern))
	log.info("running: '%s'" % (command, ))
	os.system(command)

	for (n, tag) in kernelVersions:
            if tag == "up":
                pkg = "kernel"
            else:
                pkg = "kernel-%s" %(tag,)
            
	    toDir = "%s/lib/modules/%s/updates" % \
		    (instPath, n)
	    to = "%s/%s.ko" % (toDir, name)

            if (os.path.isdir("%s/lib/modules/%s" %(instPath, n)) and not
                os.path.isdir("%s/lib/modules/%s/updates" %(instPath, n))):
                os.mkdir("%s/lib/modules/%s/updates" %(instPath, n))
            if not os.path.isdir(toDir):
                continue