Exemplo n.º 1
0
def prepare_sysroot():
    '''
    Creates intercept script and test package.
    '''
    # Add a intercept script for ls to the sysroot
    touch_dir('%s/usr/local/share/opkg/intercept' % cfg.offline_root)
    with open('%s/usr/local/share/opkg/intercept/ls' % cfg.offline_root,
              'w') as f:
        os.fchmod(f.fileno(), 0o755)
        f.write('\n'.join([
            '#!/bin/sh',
            'set -e',
            'exeFileName="`basename "$1"`"',
            'echo -n \"intercept from $exeFileName:\" >> \'%s\'' % TEST_LOG,
            'echo "ls $* was intercepted"',
        ]))

    o = opk.OpkGroup()

    # Add a test package
    a = opk.Opk(Package='a')
    a.postinst = '\n'.join([
        '#!/bin/sh',
        'set -e',
        'ls "$0"',
    ])
    o.addOpk(a)

    o.write_opk()
    o.write_list()
Exemplo n.º 2
0
    while index_start >= 0:
        index_end = status.find("\n\n", index_start)
        match = re_half_installed.search(status[index_start:index_end])
        if match is not None:
            return True
        index_start = status.find("Package: {}".format(pkg_name), index_end)
    return False


opk.regress_init()

o = opk.OpkGroup()

with open('conflict_file', 'w') as f:
    f.write('Test')
a = opk.Opk(Package='a', Version='1.0')
a.write(data_files=['conflict_file'])
b = opk.Opk(Package='b', Version='1.0')
b.write(data_files=['conflict_file'])

o.opk_list.append(a)
o.opk_list.append(b)
o.write_list()

opkgcl.update()

opkgcl.install('a')
opkgcl.install('b')
if not opkgcl.is_installed('a', '1.0'):
    opk.fail("Package 'a' failed to install")
if opkgcl.is_installed('b'):
Exemplo n.º 3
0
#!/usr/bin/env python3

import os
import opk, cfg, opkgcl

opk.regress_init()

o = opk.OpkGroup()

# Package A creates a symlink
os.mkdir('ro')
os.symlink('../rw/config', 'ro/config')
pkg = opk.Opk(Package='a')
pkg.write(data_files=['ro'])
o.addOpk(pkg)
os.remove('ro/config')

# Package B puts files in the directory
os.mkdir('ro/config')
with open('ro/config/b.conf', 'w') as f:
    f.write('Test')
pkg = opk.Opk(Package='b')
pkg.write(data_files=['ro'])
o.addOpk(pkg)
os.remove('ro/config/b.conf')
os.rmdir('ro/config')
os.rmdir('ro')

o.write_list()

opkgcl.update()
Exemplo n.º 4
0
#
# Status: Accepted
#

import os
import opk, cfg, opkgcl

opk.regress_init()

x1 = "x1"
x2 = "x2"
x3 = "x3"

open(x1, "w").close()
open(x2, "w").close()
a = opk.Opk(Package="a")
a.write(data_files=[x1, x2])
os.unlink(x1)
os.unlink(x2)
opkgcl.install("a_1.0_all.opk")

if not opkgcl.is_installed("a"):
    opk.fail("Package 'a' not installed.")

open(x2, "w").close()
open(x3, "w").close()
a = opk.Opk(Package="b", Replaces="a", Provides="a", Conflicts="a")
a.write(data_files=[x2, x3])
os.unlink(x2)
os.unlink(x3)
opkgcl.install("b_1.0_all.opk")
Exemplo n.º 5
0
#! /usr/bin/env python
#
# Within the function `pkg_hash_fetch_best_installation_candidate`, we wish to
# test the condition where `(held_pkg && good_pkg_by_name) == true`. So install
# a 1.0, mark it as on hold and explicitly install 'a_2.0_all.opk'. This
# installation should be blocked.
#

import os
import opk, cfg, opkgcl

opk.regress_init()

a_10 = opk.Opk(Package="a", Version="1.0")
a_10.write()
a_20 = opk.Opk(Package="a", Version="2.0")
a_20.write()

opkgcl.install("a_1.0_all.opk")
if not opkgcl.is_installed("a"):
	opk.fail("Package 'a' installed but reports as not installed.")

opkgcl.flag_hold("a")

# Try to explicitly install a version 2.0
opkgcl.install("a_2.0_all.opk")

if opkgcl.is_installed("a", "2.0"):
	opk.xfail("Old version of package 'a' flagged as on hold but was upgraded.")
if not opkgcl.is_installed("a", "1.0"):
	opk.fail("Package 'a' not upgraded but old version was removed.")
#!/usr/bin/python3

import os
import opk, cfg, opkgcl

bug = True

opk.regress_init()

open("asdf", "w").close()
a = opk.Opk(Package="a", Version="1.0", Depends="b")
a.write()
b = opk.Opk(Package="b", Version="1.0")
b.write(data_files=["asdf"])

o = opk.OpkGroup()
o.addOpk(a)
o.addOpk(b)
o.write_list()

opkgcl.update()
opkgcl.install("a")

if not opkgcl.is_autoinstalled("b"):
	opk.fail("b is not autoinstalled")

if (bug):
	a = opk.Opk(Package="a", Version="2.0", Depends="b")
	a.write()
	b = opk.Opk(Package="b", Version="2.0")
	b.write(data_files=["asdf"])
Exemplo n.º 7
0
#!/usr/bin/python3

import os
import opk, cfg, opkgcl

opk.regress_init()

open("foo", "w").close()
a1 = opk.Opk(Package="a", Version="1.0", Architecture="all")
a1.write(data_files=["foo"])

opkgcl.install("a_1.0_all.opk")

o = opk.OpkGroup()
a2 = opk.Opk(Package="a", Version="2.0", Architecture="all", Depends="b")
a2.write()
b1 = opk.Opk(Package="b", Version="1.0", Architecture="all")
b1.write(data_files=["foo"])
o.opk_list.append(a2)
o.opk_list.append(b1)
o.write_list()

os.unlink("foo")

opkgcl.update()
opkgcl.upgrade()

if not opkgcl.is_installed("a", "2.0"):
    print(__file__, ": Package 'a_2.0' not installed.")
    exit(False)
Exemplo n.º 8
0
#
# What is the expected output? What do you see instead?
# =====================================================
#
# Files /foo & /foo1 are expected to exist and be provided by packages b and c.
#
#

import os
import opk, cfg, opkgcl

opk.regress_init()

open("foo", "w").close()
open("foo1", "w").close()
a1 = opk.Opk(Package="a", Version="1.0")
a1.write(data_files=["foo", "foo1"])

opkgcl.install("a_1.0_all.opk")

o = opk.OpkGroup()
a2 = opk.Opk(Package="a", Version="2.0", Depends="b,c")
a2.write()
b1 = opk.Opk(Package="b",
             Version="1.0",
             Conflicts="a (<< 2.0)",
             Replaces="a (<< 2.0)")
b1.write(data_files=["foo"])
c1 = opk.Opk(Package="c",
             Version="1.0",
             Conflicts="a (<< 2.0)",
Exemplo n.º 9
0
#!/usr/bin/python3

import os
import opk, cfg, opkgcl

opk.regress_init()

open("foo", "w").close()
a1 = opk.Opk(Package="a")
a1.write(data_files=["foo"])
os.rename("a_1.0_all.opk", "a_with_foo.opk")

opkgcl.install("a_with_foo.opk")

# ----
opkgcl.install("a_with_foo.opk")

open("bar", "w").close()
o = opk.OpkGroup()
a2 = opk.Opk(Package="a")
a2.write(data_files=["foo", "bar"])
o.opk_list.append(a2)
o.write_list()

os.unlink("foo")
os.unlink("bar")

opkgcl.update()
opkgcl.install("a", "--force-reinstall")

foo_fullpath = "{}/foo".format(cfg.offline_root)
Exemplo n.º 10
0
# Graham Gower:
# > I can no longer reproduce this. I suspect it has been fixed as a side effect
# > of r465.

import os
import opk, cfg, opkgcl

opk.regress_init()

o = opk.OpkGroup()
o.add(Package="a", Version="2.0")
o.write_opk()
o.write_list()

# older version, not in Packages list
a1 = opk.Opk(Package="a", Version="1.0")
a1.write()

opkgcl.update()

# install v2 from repository
opkgcl.install("a")
if not opkgcl.is_installed("a", "2.0"):
	opk.fail("Package 'a_2.0' not installed.")

opkgcl.install("a_1.0_all.opk", "--force-downgrade")
if not opkgcl.is_installed("a", "1.0"):
	opk.fail("Package 'a_1.0' not installed (1).")

opkgcl.install("a_1.0_all.opk", "--force-downgrade")
if not opkgcl.is_installed("a", "1.0"):
Exemplo n.º 11
0
#!/usr/bin/python3

import os
import opk, cfg, opkgcl

opk.regress_init()

open("foo", "w").close()
a1 = opk.Opk(Package="a", Version="1.0")
a1.write(data_files=["foo"])

opkgcl.install("a_1.0_all.opk")

o = opk.OpkGroup()
a2 = opk.Opk(Package="a", Version="2.0", Depends="b")
a2.write()
b1 = opk.Opk(Package="b", Version="1.0")
b1.write(data_files=["foo"])
o.opk_list.append(a2)
o.opk_list.append(b1)
o.write_list()

os.unlink("foo")

opkgcl.update()
opkgcl.upgrade()

if not opkgcl.is_installed("a", "2.0"):
    print(__file__, ": Package 'a_2.0' not installed.")
    exit(False)
Exemplo n.º 12
0
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-only

import os
import opk, cfg, opkgcl

opk.regress_init()

o = opk.OpkGroup()

# Package A creates a symlink
os.mkdir('lib64')
os.symlink('lib64', 'lib')
with open('static_file.txt', 'w') as f:
    f.write('Test')
pkg = opk.Opk(Package='a')
pkg.write(data_files=['lib', 'lib64', 'static_file.txt'])
o.addOpk(pkg)
os.remove('static_file.txt')

# Package B creates the same symlink
pkg = opk.Opk(Package='b')
pkg.write(data_files=['lib', 'lib64'])
o.addOpk(pkg)
os.remove('lib')
os.rmdir('lib64')

# Package C creates a different symlink
os.mkdir('lib32')
os.symlink('lib32', 'lib')
pkg = opk.Opk(Package='c')
Exemplo n.º 13
0
# opkg_remove.c: remove_data_files_and_list() should double check that the file
# belongs to the package before removing it.
#
#
# Status
# ======
#
# Fixed by r531-r534,r536

import os
import opk, cfg, opkgcl

opk.regress_init()

open("foo", "w").close()
a1 = opk.Opk(Package="a", Version="1.0")
a1.write(data_files=["foo"])

opkgcl.install("a_1.0_all.opk")

o = opk.OpkGroup()
a2 = opk.Opk(Package="a", Version="2.0", Depends="b")
a2.write()
b1 = opk.Opk(Package="b", Version="1.0", Conflicts="a (<< 2.0)")
b1.write(data_files=["foo"])
o.opk_list.append(a2)
o.opk_list.append(b1)
o.write_list()

os.unlink("foo")
Exemplo n.º 14
0
# Install this second version of the package by URI to the package file rather
# than by name. Ensure that the upgrade is performed properly.
#

import os
import opk, cfg, opkgcl

opk.regress_init()

o = opk.OpkGroup()

# Create a 1.0 containing file "test1" and install by name
f = open("test1", "w")
f.write("Test")
f.close()
pkg = opk.Opk(Package="a", Version="1.0")
pkg.write(data_files=["test1"])
o.addOpk(pkg)
o.write_list()
os.unlink("test1")

opkgcl.update()

opkgcl.install("a")
if not opkgcl.is_installed("a"):
    opk.fail("Package 'a' installed but reports as not installed.")
if not os.path.exists("%s/test1" % cfg.offline_root):
    opk.fail("Package 'a' installed but file 'test1' not created.")

# Create a 2.0 containing file "test2" and upgrade by URI
f = open("test2", "w")
Exemplo n.º 15
0
#!/usr/bin/python3

import os
import opk, cfg, opkgcl

opk.regress_init()

open("foo", "w").close()
a1 = opk.Opk(Package="a", Version="1.0", Architecture="all")
a1.write(data_files=["foo"])
os.rename("a_1.0_all.opk", "a_with_foo.opk")

opkgcl.install("a_with_foo.opk")

# ----
opkgcl.install("a_with_foo.opk")

open("bar", "w").close()
o = opk.OpkGroup()
a2 = opk.Opk(Package="a", Version="1.0", Architecture="all")
a2.write(data_files=["foo", "bar"])
o.opk_list.append(a2)
o.write_list()

os.unlink("foo")
os.unlink("bar")

opkgcl.update()
opkgcl.install("a", "--force-reinstall")

foo_fullpath = "{}/foo".format(cfg.offline_root)
Exemplo n.º 16
0
#!/usr/bin/python3

import os
import opk, cfg, opkgcl

opk.regress_init()

open("asdf", "w").close()
a = opk.Opk(Package="a", Version="1.0", Architecture="all")
a.write(data_files=["asdf"])
b = opk.Opk(Package="b", Version="1.0", Architecture="all")
b.write(data_files=["asdf"])
os.unlink("asdf")
opkgcl.install("a_1.0_all.opk")

if not opkgcl.is_installed("a"):
    opk.fail("Package 'a' not installed.")

if not os.path.exists("{}/asdf".format(cfg.offline_root)):
    opk.fail("asdf not created.")

opkgcl.install("b_1.0_all.opk", "--force-overwrite")

if "{}/asdf".format(cfg.offline_root) not in opkgcl.files("b"):
    opk.fail("asdf not claimed by ``b''.")

if "{}/asdf".format(cfg.offline_root) in opkgcl.files("a"):
    opk.fail("asdf is still claimed by ``a''.")

opkgcl.remove("b")
opkgcl.remove("a")
Exemplo n.º 17
0
# The symlink should be created and point to the appropriate file. Instead, the
# symlink is not created at all.
#
#
# Status
# ======
#
# Fixed in r544.

import os
import opk, cfg, opkgcl

opk.regress_init()

long_filename = 110 * "a"

os.symlink(long_filename, "linky")
a = opk.Opk(Package="a")
a.write(data_files=["linky"])
os.unlink("linky")
opkgcl.install("a_1.0_all.opk")

if not opkgcl.is_installed("a"):
    opk.fail("Package 'a' not installed.")

if not os.path.lexists("{}/linky".format(cfg.offline_root)):
    opk.fail("symlink to file with a name longer than 100 "
             "characters not created.")

opkgcl.remove("a")
Exemplo n.º 18
0
# 4.- Install 'a'
#
# What is the expected output? What do you see instead?
# =====================================================
#
# The order of installation should be c -> b -> a,
# instead it is b -> c -> a.
#

import os
import opk, cfg, opkgcl

opk.regress_init()
o = opk.OpkGroup()

a = opk.Opk(Package='a', Depends='b')
a.write()

# Package 'b' has a preinst script that relies
# on a file installed by package 'c'
b = opk.Opk(Package='b', Depends='c')
b.preinst = '\n'.join([
    '#!/bin/sh',
    'set e',
    'ls %s/test_file' % cfg.offline_root,
])
b.write()

f = open('test_file', 'w')
f.write('Test')
f.close()
Exemplo n.º 19
0
#! /usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-only
#

import os
import opk, cfg, opkgcl

opk.regress_init()

o = opk.OpkGroup()

# Package 'a' creates a dir, and a symlink to that dir
os.mkdir('lib64')
os.symlink('lib64', 'lib')
open('lib64/testfile.txt', 'w').close()
a = opk.Opk(Package='a')
a.write(data_files=['lib', 'lib64', 'lib64/testfile.txt'])
o.addOpk(a)
os.remove('lib64/testfile.txt')
os.remove('lib')
os.rmdir('lib64')

# Package 'b' creates a file in a dir that follows the symlink created by 'a'
os.mkdir('lib')
open('lib/testfile2.txt', 'w').close()
b = opk.Opk(Package='b')
b.write(data_files=['lib', 'lib/testfile2.txt'])
o.addOpk(b)
os.remove('lib/testfile2.txt')
os.rmdir('lib')