コード例 #1
0
ファイル: port.py プロジェクト: mreschke/manup
def step_install(pb):
    """
    Install port to / (move from /usr/fakeroot/xxx to /)
    """
    console.line('Install ' + pb.nameverrel)

    if not core.config.debug:
        # Run PORTBUILD port_install()
        port.pbrun(pb, "port_install")
    
    # Delete fakeroot
    os.system('/bin/rm -rf ' + pb.fakeroot)
コード例 #2
0
ファイル: port.py プロジェクト: mreschke/manup
def step_fakeroot(pb):
    """
    Install port to /usr/fakeroot/xxx (a preinstall staging environment) 
    """
    console.line('Fakeroot ' + pb.nameverrel)

    # Create fakeroot/port dir
    os.system('/bin/mkdir -p ' + pb.fakeroot)

    if not core.config.debug:
        # Run PORTBUILD port_fakeroot()
        port.pbrun(pb, "port_fakeroot")
コード例 #3
0
ファイル: port.py プロジェクト: mreschke/manup
def step_configure(pb):
    console.line('Configure ' + pb.nameverrel)

    # Extract tmp build directory
    builddir = core.config.dir_build + pb.repo + '/' + pb.name
    os.chdir(builddir)
    os.system('tar -xf ' + core.config.dir_cache + pb.repo + '/' + pb.filename + ' -C ' + builddir)
    os.chdir(builddir + '/' + pb.folder)
    
    # Copy PORTBUILD and /files to tmp build directory
    os.system('/bin/cp -rf ' + core.config.dir_tree + pb.repo + '/' + pb.name + '/* ' + builddir)

    if not core.config.debug:   
        # Run PORTBUILD port_configure()
        port.pbrun(pb, "port_configure")
コード例 #4
0
ファイル: port.py プロジェクト: mreschke/manup
def upgrade(opts):
    """
    Find all outdated software taking dependencies first, no duplicates added
    This will ensure if an outdated port is a dependency if another oudated port it will come first
    So port dependencies installed first, then port and so on...
    """
    console.header("Upgrading all ports")
    reinstall = []
    for repo in core.config.repos:
        for portname in os.listdir(core.config.dir_db + 'installed/' + repo):
            # Get PORTBUILD of this app, but from portstree, not db directory
            pb = PortBuild(core.config.dir_tree + repo + '/' + portname + '/PORTBUILD', repo)
            if not port.is_installed(pb): # exact version NOT installed
                # Only add if not already in reinstall array
                deps = port.get_deps(repo + '/' + portname, True)
                for dep in deps:
                    add = True
                    for install in reinstall:
                        if install.name == dep.name:
                            add = False
                            break
                    if add:
                        reinstall.append(dep)
    
    if len(reinstall) == 0:
        console.out("All ports are current, nothing to upgrade.  Be sure to perform a manup sync first.")
        exit();
    
    console.line("The following outdated ports will be upgraded")
    inslist = ''
    for install in reinstall:
        inslist += install.name + '-' + install.verrel + '  '
    console.list(inslist)

    input = console.ask("Continue (Y/n)")
    if input != 'y' and input != '':
        exit()
        
    # Install each oudated port in dependency order
    opts.noconfirm = False
    opts.alldeps = None
    opts.nocolor = None
    for install in reinstall:
        # Install port
        port.install(install.repo, install.name, opts)
コード例 #5
0
ファイル: port.py プロジェクト: mreschke/manup
def step_postinstall(pb):
    """
    Perform any post install actions
    """
    console.line('Post Install ' + pb.nameverrel)
    repo = pb.repo
    name = pb.name

    if not core.config.debug:
        # Run PORTBUILD port_postinstall()
        port.pbrun(pb, "port_postinstall")
    
    # Delete temp build
    os.chdir("/")
    os.system('/bin/rm -rf ' + core.config.dir_build + repo + '/' + name)
    
    # Mark as installed
    os.system('/bin/cp -rf ' + core.config.dir_tree + repo + '/' + name + '/PORTBUILD ' + core.config.dir_db + 'installed/' + repo + '/' + name)
コード例 #6
0
ファイル: port.py プロジェクト: mreschke/manup
def rebuild_world(opts):
    console.header("Rebuilding World")
    console.line3("NOTICE: You should run manup sync then manup upgrade first", 3)
    world = []
    for repo in core.config.repos:
        if not os.path.exists(core.config.dir_db + 'world/' + repo):
            os.system('mkdir -p ' + core.config.dir_db + 'world/' + repo)
        for portname in os.listdir(core.config.dir_db + 'world/' + repo):
            pb = PortBuild(core.config.dir_db + '/world/' + repo + '/' + portname + '/PORTBUILD', repo)
            # Only add if not already in world array
            deps = port.get_deps(repo + '/' + portname, True, True, True)
            for dep in deps:
                add = True
                for install in world:
                    if install.name == dep.name:
                        add = False
                        break
                if add:
                    world.append(dep)
    
    console.line("The following ports (your world) will be reinstalled")
    inslist = ''
    for install in world:
        inslist += install.name + '-' + install.verrel + '  '
    console.list(inslist)

    input = console.ask("Continue (Y/n)")
    if input != 'y' and input != '':
        exit()
        
    # Install each oudated port in dependency order
    opts.noconfirm = False
    opts.alldeps = None
    opts.nocolor = None
    for install in world:
        # Install port
        port.install(install.repo, install.name, opts)
コード例 #7
0
ファイル: port.py プロジェクト: mreschke/manup
def step_preinstall(pb):
    """
    Perform any actions on /usr/fakeroot/xxx before actually installing to /
    """
    console.line('Pre Install ' + pb.nameverrel)

    if not core.config.debug:
        # Run PORTBUILD port_preinstall()
        port.pbrun(pb, "port_preinstall")
        
    # Set ownership of all files in fakeroot to root
    if not core.config.cygwin:
        os.system('chown -R 0:0 ' + pb.fakeroot)

    # Save text file of installed files (all files in /usr/fakeroot/xxx)
    # Must be done here, after port_preinstall (in case the function in the PORTBUILD creates files...)
    # but just before I move configs to .manupnew, don't want those in my installed.files list
    installed_files = core.config.dir_db + 'installed/' + pb.repo + '/' + pb.name + '/installed.files'
    os.system('/bin/mkdir -p ' + core.config.dir_db + 'installed/' + pb.repo + '/' + pb.name)
    os.system('cd ' + pb.fakeroot + '; find . > ' + installed_files)
    #Reverse installed files (could use tac, but only part of GNU, not BSD/OSX)
    os.system("sed '1!G;h;$!d' "  + installed_files + " > " + installed_files + ".rev")
    os.system ('/bin/mv -f ' + installed_files + '.rev ' + installed_files)
    if not core.config.debug:
        if os.stat(installed_files).st_size <= 2:
            # installed.files is empty. This means install to fakeroot failed, no files
            console.error("No files found in fakeroot path.\nThis means the package failed to install to fakeroot with DESTDIR or make-redir\nThis means manup uninstall will NOT be allowed for this package")
        
    # Rename config files to .manupnew
    #If this is an upgrade or reinstall rename any config files in this fakeroot to .manupnew
    if port.ISINSTALLED and not core.config.debug:
        for config in pb.configs:
            if os.path.exists(config):
                if os.path.exists(pb.fakeroot + config):
                    #Config exists in both system and fakeroot, so rename fakeroot's to .manupnew
                    os.system('/bin/mv -f ' + pb.fakeroot + config + ' ' + pb.fakeroot + config + '.manupnew')
                    port.BUILDMSG.append('New config file saved as ' + config + '.manupnew')
コード例 #8
0
ファイル: port.py プロジェクト: mreschke/manup
def step_download(pb):
    cachedir = core.config.dir_cache + pb.repo
    cachefile = core.config.dir_cache + pb.repo + '/' + pb.filename
    firsttime = False
    
    if not os.path.exists(cachedir):
        os.mkdir(core.config.dir_cache + pb.repo)
    
    if not os.path.exists(cachefile):
        # Port source not found in cache, download it
        console.line('Downloading ' + pb.fileurl)
        #port.pbrun(pb, core.config.cmd_down + ' ' + pb.fileurl + ' -P ' + cachedir)
        port.pbrun(pb, core.config.cmd_down.replace('$source', pb.fileurl).replace('$dest', cachedir))
        firsttime = True
        
    # Check cached source md5sum and re-download if changed
    proc = subprocess.Popen(core.config.cmd_md5.replace('$file', cachefile), universal_newlines=True, executable='bash', shell=True, stdout=subprocess.PIPE).stdout
    cachefile_md5 = proc.read().strip()
    
    # if PORTBUILD md5sum is blank must download everytime
    if pb.md5sum != '' and pb.md5sum == cachefile_md5:
        if not firsttime:
            console.line('Local cached version of ' + pb.filename + ' found')
    else:
        if not firsttime:
            console.line('Downloading ' + pb.filename)
            os.system('/bin/rm -rf ' + cachefile)
            #port.pbrun(pb, core.config.cmd_down + ' ' + pb.fileurl + ' -P ' + cachedir)
            port.pbrun(pb, core.config.cmd_down.replace('$source', pb.fileurl).replace('$dest', cachedir))
        
        # Compare md5 again
        proc = subprocess.Popen(core.config.cmd_md5.replace('$file', cachefile), universal_newlines=True, executable='bash', shell=True, stdout=subprocess.PIPE).stdout
        cachefile_md5 = proc.read().strip()
        if pb.md5sum != '' and pb.md5sum != cachefile_md5:
            console.error("File failed to pass md5 check sum. File corrupt or Portbuild and source file md5 differ")
            exit()
        
    if not os.path.exists(cachefile):
        console.error("Could not download " + pb.filename + " check PORTBUILD file")
        exit()
        
    # Make tmp build dir
    if not os.path.exists(core.config.dir_build + pb.repo + '/' + pb.name):
        os.system('/bin/mkdir -p ' + core.config.dir_build + pb.repo + '/' + pb.name)
コード例 #9
0
ファイル: tree.py プロジェクト: mreschke/manup
def sync():
    """
    Sync the local ports tree with the online ports tree
    for all manup.conf defined repositories
    """
    if len(core.config.repos) == 0:
        console.error('You have no repositories setup, please edit your ' + core.config.dir_config + 'manup.conf file')
        exit()
        
    console.header('Syncing Subscribed Repositories')
    if not os.path.exists(core.config.dir_tree):
        os.mkdir(core.config.dir_tree)
    console.line('Deleting ports tree from ' + core.config.dir_tree + '*')
    os.system('/bin/rm -rf ' + core.config.dir_tree + '*')
    
    for i in range(len(core.config.repos)):
        repo = core.config.repos[i]
        repo_url = core.config.repo_urls[i]
        console.line('Downloading ' + repo_url)
        os.system(core.config.cmd_down.replace('$source', repo_url).replace('$dest', core.config.dir_tree))
        
        console.line('Extracting ' + repo)
        os.system('tar -xzmf ' + core.config.dir_tree + 'tree.tar.gz -C ' + core.config.dir_tree)
        os.system('/bin/rm -rf ' + core.config.dir_tree + 'tree.tar.gz')
コード例 #10
0
def continue_main_game():
    global game
    c.clear_screen()
    c.show_game(game)
    c.line()
    main_game()
コード例 #11
0
def first_move():
    global game
    game.first_move()
    c.clear_screen()
    c.show_game(game)
    c.line()
コード例 #12
0
ファイル: core.py プロジェクト: mreschke/manup
def configure_defaults():
    """
    Creates default manup environment (folders, configs...) if none exists
    Used for first time installs or to check if things are setup properly
    """
    is_initial = False
    
    # Create the config dir
    if not os.path.exists('/etc/manup'):
        require_root()
        os.system('/bin/mkdir -p /etc/manup')
        is_initial = True
    
    # Create the main config file
    if not os.path.exists('/etc/manup/manup.conf'):
        require_root()
        console.line('Creating default /etc/manup/manup.conf', 0)
        is_initial = True
        os.system('''cat > /etc/manup/manup.conf << "EOF"
[repositories]
# The first repository in the list is your primary repo.
# When installing ports from the primary you do not need to reference the repo.
# So you can use 'manup install xxx' instead of 'manup install repo/xxx'
# Repositories should be 0n their own line with a space(s) or tab(s) before them
repos:
 http://manup.mreschke.net/nwq
 http://manup.mreschke.net/manup

[portbuild]
# Most linux systems install all apps to /usr
# This should be set to /usr/local if using a Mac or BSD style OS
prefix = /usr

# Temporary install staging environment
fakeroot = /usr/fakeroot

# Command used to download all repos and ports
# $source and $dest are required
# On Linux use: wget -q $source -P $dest
# On Mac use: s=$source && curl -Ls $source -o $dest/${s##*/}
cmd_down = wget -q $source -P $dest

# Command used for md5 checksums
# This command must output ONLY the md5 string and contain the $file
# On Linux use: md5sum $file | cut -d\  -f1
# On Mac use: md5 -q $file
cmd_md5 = md5sum $file | cut -d\  -f1

[manup]
# Debug for development only.
# Enabling this will not actually install the port, but manup
# will think they are installed, not a good idea unless
# you know what your doing
debug = false

# Cygwin
# If you are in a cygwin environment choose true here or manup does not work
cygwin = false


[locations]
# Recommended these remain at their defaults
# Some items like config are hard coded in the python scripts
# Only change them if you plan on hacking the code a bit
# Feel free to change the build dir if you don't have space on /tmp
config = /etc/manup/
bin = /usr/local/lib/manup/
cache = /var/cache/manup/
db = /var/lib/manup/
tree = /var/manup/
build = /tmp/manup/
EOF
                  ''')

    # Refresh new config file for use below
    config = Config()
    
    # Create the cache dir
    if not os.path.exists(config.dir_cache):
        require_root()
        console.line('Creating cache directory at ' + config.dir_cache, 0)
        os.system('/bin/mkdir -p ' + config.dir_cache)
        is_initial = True

    # Create the database dir
    if not os.path.exists(config.dir_db):
        require_root()
        console.line('Creating database directory at ' + config.dir_db, 0)
        os.system('/bin/mkdir -p ' + config.dir_db)
        is_initial = True

    # Create the ports tree dir
    if not os.path.exists(config.dir_tree):
        require_root()
        console.line('Creating ports tree directory at ' + config.dir_tree, 0)
        os.system('/bin/mkdir -p ' + config.dir_tree)
        is_initial = True
    
    # Make sure /usr/bin/touch exists (for auto-destdir)
    if not os.path.exists('/usr/bin/touch'):
        require_root()
        if os.path.exists('/bin/touch'):
            console.line('Found that /usr/bin/touch does not exist, creating symlink from /bin', 0)
            os.system('/bin/ln -s /bin/touch /usr/bin/')

    if is_initial:
        # Found and fixed items, display message to re-run manup
        console.error("Some manup critical files/folders were not found.\nThis is normal for an initial installation or if some files/folders were deleted.")
        console.out("Initializing defaults for items listed above is complete.")
        console.out("Please re-run your manup query")
        exit()
コード例 #13
0
ファイル: port.py プロジェクト: mreschke/manup
def uninstall(rname, pname, opts):
    # rpname is repo/p
    rpname = rname + '/' + pname
    console.header("Uninstalling " + rpname)
    if port.exist(rpname):
        pb = PortBuild(core.config.dir_db + 'installed/' + rpname + '/PORTBUILD', rname)
        if pb.found:
            installed_files = core.config.dir_db + 'installed/' + rpname + '/installed.files'
            if os.path.exists(installed_files):
                console.line('Found ' + rname + '/' + pb.nameverrel + ' installed')
                if os.stat(installed_files).st_size <= 2:
                    console.error(installed_files + " is empty\nThis means the fakeroot portion of the port installation failed\nManup cannot uninstall this package.")
                else:
                    # Display files to delete
                    for line in open(installed_files):
                        line = line.strip()
                        if line != '.':
                            file = line[1:]
                            console.line3(file, 5)
                    input = console.ask('Uninstalling ' + pname + ' will delete the files and EMPTY folders listed above.\nTo ignore a certian file, remove it from ' + installed_files + '\nDon\'t worry it wont delete a folder unless its empty (like /usr...)\nDo you want to continue the uninstall (y/N)')
                    if input != 'y':
                         exit()
                         
                    # Run PORTBUILD preuninstall
                    port.step_preuninstall(pb)

                    # Remove any .manupnew files first, as defind in configs()
                    console.line('Deleting any .manupnew files used by ' + pb.nameverrel)
                    for config in pb.configs:
                        if os.path.exists(config + '.manupnew'):
                            console.line3('Deleting file ' + config + '.manupnew', 5)
                            os.system('rm -rf ' + config + '.manupnew')

                    # Delete all files and non empty folders
                    console.line('Deleting all files installed by ' + pb.nameverrel)
                    for line in open(installed_files):
                        line = line.strip()
                        if line != '.':
                            file = line[1:]
                            if os.path.exists(file):
                                if os.path.isfile(file):
                                    console.line3('Deleting file ' + file, 5)
                                    if not core.config.debug:
                                        # Delete file
                                        os.system('/bin/rm -rf ' + file)
                                elif os.path.isdir(file):
                                    if os.listdir(file) == []:
                                        console.line3('Deleting empty folder ' + file, 5)
                                        if not core.config.debug:
                                            # Delete empty directory
                                            os.system('/bin/rm -rf ' + file)
                    
                    # Run PORTBUILD postuninstall
                    port.step_postuninstall(pb)

                    # Mark port deleted
                    console.line('Updating manup database')
                    if not core.config.debug:
                        os.system('/bin/rm -rf ' + core.config.dir_db + 'world/' + rpname)
                        os.system('/bin/rm -rf ' + core.config.dir_db + 'installed/' + rpname)
                        if os.path.exists(core.config.dir_cache + rname + '/' + pb.filename):
                            os.system('/bin/rm -rf ' + core.config.dir_cache + rname + '/' + pb.filename)

        else:
            console.error(rpname + ' is not installed')
コード例 #14
0
ファイル: port.py プロジェクト: mreschke/manup
def step_postuninstall(pb):
    console.line('Post Uninstall ' + pb.nameverrel)
    if not core.config.debug:
        # Run PORTBUILD port_postuninstall()
        port.pbrun(pb, "port_postuninstall")
コード例 #15
0
ファイル: port.py プロジェクト: mreschke/manup
def install(rname, pname, opts):
    """
    Full automated port install with dependencies
    """
    rpname = rname + '/' + pname
    
    # Rebuild world if instructed by 'manup install world'
    if rpname == 'world/world':
        port.rebuild_world(opts)
        exit()

    console.header('Processing full install of ' + rpname)
    if port.exist(rpname):
        pb = PortBuild(core.config.dir_tree + rpname + '/PORTBUILD', rname)
        
        # Check if port already installed (exact version installed, not an older version)
        reinstall = False
        if port.is_installed(pb):
            if opts.noconfirm is None:
                input = console.ask("Port already installed AND current.  Install anyway (Y/n)")
                if input != 'y' and input != '':
                    exit()
                else:
                    reinstall = True
            else:
                reinstall = True
            
        # Get Dependencies
        alldeps = True
        if opts.alldeps is None: alldeps = False

        deps = port.get_deps(rpname, alldeps, reinstall)

        #map(lambda dep: not dep in deps and deps.append(dep), 1)

        console.line("The following ports will be installed from the " + rname + " repository")
        
        deplist = ''
        for dep in deps:
            deplist += dep.name + '-' + dep.verrel + '  '
        console.list(deplist)
        if opts.noconfirm is None:
            input = console.ask("Continue (Y/n)")
            if input != 'y' and input != '':
                exit()

        # Clear Notices
        port.BUILDMSG = []

        # Download each ports source first
        console.header('Downloading all files to ' + core.config.dir_cache + rname)
        for dep in deps:
            port.step_download(dep)
        
        # Install each port
        for dep in deps:
            print('')
            console.header("Installing " + dep.name + '-' + dep.verrel)
            
            # Checks if ANY version installed, not just exact version
            port.ISINSTALLED = False
            if port.is_installed(pb, False): port.ISINSTALLED = True
            
            # Begin steps from PORTBUILD
            port.step_configure(dep)
            port.step_build(dep)
            port.step_fakeroot(dep)
            port.step_preinstall(dep)
            port.step_install(dep)
            port.step_postinstall(dep)
        
        #Mark explicitely installed p as installed world
        if os.path.exists(core.config.dir_db + 'installed/' + rpname + '/PORTBUILD'):
            os.system('/bin/mkdir -p ' + core.config.dir_db + 'world/' + rname)
            if not os.path.exists(core.config.dir_db + 'world/' + rpname):
                os.system('/bin/ln -s ../../installed/' + rpname + ' ' + core.config.dir_db + 'world/' + rname)
                
        # Display any important messages
        if port.BUILDMSG:
            console.notice('\n'.join(port.BUILDMSG))
コード例 #16
0
ファイル: port.py プロジェクト: mreschke/manup
def info(rname, pname, opts):
    rpname = rname + '/' + pname
    console.header("Port Information for " + rpname)
    if port.exist(rpname):
        pb = PortBuild(core.config.dir_tree + rpname + '/PORTBUILD', rname)
        console.line('Name: ' + pb.name)
        console.line('Version: ' + pb.ver)
        console.line('Release: ' + pb.rel)
        console.line('Dependencies: ' + str(pb.dep))
        console.line('Optional Dependencies: ' + str(pb.depopt))
        console.line('Config Files: ' + str(pb.configs))
        console.line('Description: ' + pb.desc)
        if port.is_installed(pb):
            console.line2('Status: Installed', 3)
            console.header("Installed Files and Folders")
            #os.system('cat ' + core.config.dir_db + 'installed/' + pb.repo + '/' + pb.name + '/installed.files')
            for line in open(core.config.dir_db + 'installed/' + pb.repo + '/' + pb.name + '/installed.files'):
                line = line.strip()
                if line != '.':
                    file = line[1:]
                    console.line2(file, 3)

        else:
            console.line3('Status: Not Installed', 3)
コード例 #17
0
ファイル: pythonhead.py プロジェクト: boothj5/pythonhead
def continue_main_game():
    global game
    c.clear_screen()
    c.show_game(game)
    c.line()
    main_game()
コード例 #18
0
ファイル: port.py プロジェクト: mreschke/manup
def step_build(pb):
    console.line('Build ' + pb.nameverrel)
    if not core.config.debug:
        # Run PORTBUILD port_configure()
        port.pbrun(pb, "port_build")
コード例 #19
0
ファイル: tree.py プロジェクト: mreschke/manup
def clean():
    console.header("Cleaning manup")
    console.line("Deleting manup cache from " + core.config.dir_cache)
    os.system('rm -rf ' + core.config.dir_cache + '*')
コード例 #20
0
ファイル: pythonhead.py プロジェクト: boothj5/pythonhead
def first_move():
    global game
    game.first_move()
    c.clear_screen()
    c.show_game(game)
    c.line()