Changeset 3513 for trunk


Ignore:
Timestamp:
Jul 4, 2007, 1:08:53 AM (18 years ago)
Author:
bird
Message:

Working around various OS/2 limitations.

Location:
trunk/essentials/sys-apps/prefix-portage
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/essentials/sys-apps/prefix-portage/bin/dispatch-conf

    r3511 r3513  
    356356        # from ASPN - Danny Yoo
    357357        #
    358         import sys, tty, termios
    359 
    360         fd = sys.stdin.fileno()
    361         old_settings = termios.tcgetattr(fd)
    362         try:
    363                 tty.setraw(sys.stdin.fileno())
     358
     359        # bird: XXX: termios.tcgetattr ++ doesn't exist on OS/2 yet.
     360        if sys.platform != "os2knix":
     361                import sys, tty, termios
     362       
     363                fd = sys.stdin.fileno()
     364                old_settings = termios.tcgetattr(fd)
     365                try:
     366                        tty.setraw(sys.stdin.fileno())
     367                        ch = sys.stdin.read(1)
     368                finally:
     369                        termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
     370        else
    364371                ch = sys.stdin.read(1)
    365         finally:
    366                 termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
    367372        return ch
    368373
  • trunk/essentials/sys-apps/prefix-portage/pym/portage/__init__.py

    r3511 r3513  
    23712371                elif 1 not in fd_pipes or 2 not in fd_pipes:
    23722372                        raise ValueError(fd_pipes)
    2373                 from pty import openpty
    2374                 master_fd, slave_fd = openpty()
    2375                 fd_pipes.setdefault(0, sys.stdin.fileno())
    2376                 stdin_fd = fd_pipes[0]
    2377                 if os.isatty(stdin_fd):
    2378                         # Copy the termios attributes from stdin_fd to the slave_fd and put
    2379                         # the stdin_fd into raw mode with ECHO disabled.  The stdin
    2380                         # termios attributes are reverted before returning, or via the
    2381                         # atexit hook in portage.process when killed by a signal.
    2382                         import termios, tty
    2383                         stdin_termios = termios.tcgetattr(stdin_fd)
    2384                         tty.setraw(stdin_fd)
    2385                         term_attr = termios.tcgetattr(stdin_fd)
    2386                         term_attr[3] &= ~termios.ECHO
    2387                         termios.tcsetattr(stdin_fd, termios.TCSAFLUSH, term_attr)
    2388                         termios.tcsetattr(slave_fd, termios.TCSAFLUSH, stdin_termios)
    2389                         from output import get_term_size, set_term_size
    2390                         rows, columns = get_term_size()
    2391                         set_term_size(rows, columns, slave_fd)
    2392                         pre_exec = keywords.get("pre_exec")
    2393                         def setup_ctty():
    2394                                 os.setsid()
    2395                                 # Make it into the "controlling terminal".
    2396                                 import termios
    2397                                 if hasattr(termios, "TIOCSCTTY"):
    2398                                         # BSD 4.3 approach
    2399                                         import fcntl
    2400                                         fcntl.ioctl(0, termios.TIOCSCTTY)
    2401                                 else:
    2402                                         # SVR4 approach
    2403                                         fd = os.open(os.ttyname(0), os.O_RDWR)
    2404                                         for x in 0, 1, 2:
    2405                                                 os.dup2(fd, x)
    2406                                         os.close(fd)
    2407                                 if pre_exec:
    2408                                         pre_exec()
    2409                         keywords["pre_exec"] = setup_ctty
    2410                 # tee will always exit with an IO error, so ignore it's stderr.
    2411                 null_file = open('/dev/null', 'w')
    2412                 mypids.extend(portage.process.spawn(['tee', '-i', '-a', logfile],
    2413                         returnpid=True, fd_pipes={0:master_fd, 1:fd_pipes[1],
    2414                         2:null_file.fileno()}))
    2415                 output_pid = mypids[-1]
    2416                 mypids.extend(portage.process.spawn(['cat'],
    2417                         returnpid=True, fd_pipes={0:fd_pipes[0], 1:master_fd,
    2418                         2:null_file.fileno()}))
    2419                 input_pid = mypids[-1]
    2420                 os.close(master_fd)
    2421                 null_file.close()
    2422                 fd_pipes[0] = slave_fd
    2423                 fd_pipes[1] = slave_fd
    2424                 fd_pipes[2] = slave_fd
    2425                 keywords["fd_pipes"] = fd_pipes
    2426 
     2373                # bird: XXX: pty and termios.tcgetattr doesn't work/exist on OS/2 yet.
     2374        if sys.platform == "os2knix":
     2375                        pr, pw = os.pipe()
     2376                        mypids.extend(portage.process.spawn(('tee', '-i', '-a', logfile),
     2377                                      returnpid=True, fd_pipes={0:pr, 1:fd_pipes[1], 2:fd_pipes[2]}))
     2378                        os.close(pr)
     2379                        fd_pipes[1] = pw
     2380                        fd_pipes[2] = pw
     2381                        keywords["fd_pipes"] = fd_pipes
     2382        else:
     2383                        from pty import openpty
     2384                        master_fd, slave_fd = openpty()
     2385                        fd_pipes.setdefault(0, sys.stdin.fileno())
     2386                        stdin_fd = fd_pipes[0]
     2387                        if os.isatty(stdin_fd):
     2388                                # Copy the termios attributes from stdin_fd to the slave_fd and put
     2389                                # the stdin_fd into raw mode with ECHO disabled.  The stdin
     2390                                # termios attributes are reverted before returning, or via the
     2391                                # atexit hook in portage.process when killed by a signal.
     2392                                import termios, tty
     2393                                stdin_termios = termios.tcgetattr(stdin_fd)
     2394                                tty.setraw(stdin_fd)
     2395                                term_attr = termios.tcgetattr(stdin_fd)
     2396                                term_attr[3] &= ~termios.ECHO
     2397                                termios.tcsetattr(stdin_fd, termios.TCSAFLUSH, term_attr)
     2398                                termios.tcsetattr(slave_fd, termios.TCSAFLUSH, stdin_termios)
     2399                                from output import get_term_size, set_term_size
     2400                                rows, columns = get_term_size()
     2401                                set_term_size(rows, columns, slave_fd)
     2402                                pre_exec = keywords.get("pre_exec")
     2403                                def setup_ctty():
     2404                                        os.setsid()
     2405                                        # Make it into the "controlling terminal".
     2406                                        import termios
     2407                                        if hasattr(termios, "TIOCSCTTY"):
     2408                                                # BSD 4.3 approach
     2409                                                import fcntl
     2410                                                fcntl.ioctl(0, termios.TIOCSCTTY)
     2411                                        else:
     2412                                                # SVR4 approach
     2413                                                fd = os.open(os.ttyname(0), os.O_RDWR)
     2414                                                for x in 0, 1, 2:
     2415                                                        os.dup2(fd, x)
     2416                                                os.close(fd)
     2417                                        if pre_exec:
     2418                                                pre_exec()
     2419                                keywords["pre_exec"] = setup_ctty
     2420                        # tee will always exit with an IO error, so ignore it's stderr.
     2421                        null_file = open('/dev/null', 'w')
     2422                        mypids.extend(portage.process.spawn(['tee', '-i', '-a', logfile],
     2423                                returnpid=True, fd_pipes={0:master_fd, 1:fd_pipes[1],
     2424                                2:null_file.fileno()}))
     2425                        output_pid = mypids[-1]
     2426                        mypids.extend(portage.process.spawn(['cat'],
     2427                                returnpid=True, fd_pipes={0:fd_pipes[0], 1:master_fd,
     2428                                2:null_file.fileno()}))
     2429                        input_pid = mypids[-1]
     2430                        os.close(master_fd)
     2431                        null_file.close()
     2432                        fd_pipes[0] = slave_fd
     2433                        fd_pipes[1] = slave_fd
     2434                        fd_pipes[2] = slave_fd
     2435                        keywords["fd_pipes"] = fd_pipes
     2436   
    24272437        features = mysettings.features
    24282438        restrict = mysettings.get("PORTAGE_RESTRICT","").split()
  • trunk/essentials/sys-apps/prefix-portage/pym/portage/util.py

    r3511 r3513  
    655655                                raise OperationNotPermitted(func_call)
    656656                        elif oe.errno == errno.EACCES:
     657                                # For now, just ignore this on OS/2 since triggers on the /var/../temp/build.log.
     658                                if sys.platform == "os2knix":
     659                                        return modified;
    657660                                raise PermissionDenied(func_call)
    658661                        elif oe.errno == errno.EROFS:
Note: See TracChangeset for help on using the changeset viewer.