summaryrefslogtreecommitdiffstats
path: root/src/tests/regress/.svn/text-base
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-02-09 10:56:43 (EST)
committer P. J. McDermott <pjm@nac.net>2012-02-09 10:56:43 (EST)
commitf431cd1a48a6a5186633bf5f16a2d21cb4399e8c (patch)
tree337e36fd9d7884fcf76ba769ab7b0039f52d9d31 /src/tests/regress/.svn/text-base
Initial commit.
TODO: Copyright information. Including source code and a patch to add files generated by GNU Autoconf is not very pretty... Running 'make dist' in the SVN trunk to generate a source archive might be better.
Diffstat (limited to 'src/tests/regress/.svn/text-base')
-rw-r--r--src/tests/regress/.svn/text-base/Makefile.svn-base15
-rw-r--r--src/tests/regress/.svn/text-base/cfg.py.svn-base5
-rw-r--r--src/tests/regress/.svn/text-base/filehash.py.svn-base35
-rw-r--r--src/tests/regress/.svn/text-base/issue26.py.svn-base35
-rw-r--r--src/tests/regress/.svn/text-base/issue31.py.svn-base25
-rw-r--r--src/tests/regress/.svn/text-base/issue45.py.svn-base33
-rw-r--r--src/tests/regress/.svn/text-base/issue46.py.svn-base39
-rw-r--r--src/tests/regress/.svn/text-base/issue50.py.svn-base43
-rw-r--r--src/tests/regress/.svn/text-base/issue51.py.svn-base70
-rw-r--r--src/tests/regress/.svn/text-base/issue55.py.svn-base25
-rw-r--r--src/tests/regress/.svn/text-base/issue58.py.svn-base31
-rw-r--r--src/tests/regress/.svn/text-base/issue72.py.svn-base52
-rw-r--r--src/tests/regress/.svn/text-base/issue79.py.svn-base33
-rw-r--r--src/tests/regress/.svn/text-base/issue84.py.svn-base45
-rw-r--r--src/tests/regress/.svn/text-base/issue85.py.svn-base29
-rw-r--r--src/tests/regress/.svn/text-base/opk.py.svn-base111
-rw-r--r--src/tests/regress/.svn/text-base/opkgcl.py.svn-base64
-rw-r--r--src/tests/regress/.svn/text-base/update_loses_autoinstalled_flag.py.svn-base63
18 files changed, 753 insertions, 0 deletions
diff --git a/src/tests/regress/.svn/text-base/Makefile.svn-base b/src/tests/regress/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..0accb31
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,15 @@
+PYTHON=/usr/bin/python3
+REGRESSION_TESTS=issue26.py issue31.py issue45.py issue46.py \
+ issue50.py issue51.py issue55.py issue58.py \
+ issue72.py issue79.py issue84.py issue85.py \
+ filehash.py \
+ update_loses_autoinstalled_flag.py
+
+regress:
+ @for test in $(REGRESSION_TESTS); do \
+ echo $$test; \
+ $(PYTHON) $$test; \
+ done
+
+clean:
+ rm -f *.pyc
diff --git a/src/tests/regress/.svn/text-base/cfg.py.svn-base b/src/tests/regress/.svn/text-base/cfg.py.svn-base
new file mode 100644
index 0000000..6f78996
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/cfg.py.svn-base
@@ -0,0 +1,5 @@
+import os
+
+opkdir = "/tmp/opk"
+offline_root = "/tmp/opkg"
+opkgcl = os.path.realpath("../../src/opkg-cl")
diff --git a/src/tests/regress/.svn/text-base/filehash.py.svn-base b/src/tests/regress/.svn/text-base/filehash.py.svn-base
new file mode 100644
index 0000000..e6cbe62
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/filehash.py.svn-base
@@ -0,0 +1,35 @@
+#!/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"):
+ print(__file__, ": Package 'a' not installed.")
+ exit(False)
+
+if not os.path.exists("{}/asdf".format(cfg.offline_root)):
+ print(__file__, ": asdf not created.")
+ exit(False)
+
+opkgcl.install("b_1.0_all.opk", "--force-overwrite")
+
+if "{}/asdf".format(cfg.offline_root) not in opkgcl.files("b"):
+ print(__file__, ": asdf not claimed by ``b''.")
+ exit(False)
+
+if "{}/asdf".format(cfg.offline_root) in opkgcl.files("a"):
+ print(__file__, ": asdf is still claimed by ``a''.")
+ exit(False)
+
+opkgcl.remove("b")
+opkgcl.remove("a")
diff --git a/src/tests/regress/.svn/text-base/issue26.py.svn-base b/src/tests/regress/.svn/text-base/issue26.py.svn-base
new file mode 100644
index 0000000..dd4ef92
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue26.py.svn-base
@@ -0,0 +1,35 @@
+#!/usr/bin/python3
+
+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"):
+ print(__file__, ": Package 'a_2.0' not installed.")
+ exit(False)
+
+opkgcl.install("a_1.0_all.opk", "--force-downgrade")
+if not opkgcl.is_installed("a", "1.0"):
+ print(__file__, ": Package 'a_1.0' not installed (1).")
+ exit(False)
+
+opkgcl.install("a_1.0_all.opk", "--force-downgrade")
+if not opkgcl.is_installed("a", "1.0"):
+ print(__file__, ": Package 'a_1.0' not installed (2).")
+ exit(False)
+
+opkgcl.remove("a")
diff --git a/src/tests/regress/.svn/text-base/issue31.py.svn-base b/src/tests/regress/.svn/text-base/issue31.py.svn-base
new file mode 100644
index 0000000..42e51e3
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue31.py.svn-base
@@ -0,0 +1,25 @@
+#!/usr/bin/python3
+
+import os
+import opk, cfg, opkgcl
+
+opk.regress_init()
+
+o = opk.OpkGroup()
+o.add(Package="a", Depends="b")
+o.add(Package="b", Depends="c")
+o.write_opk()
+o.write_list()
+
+opkgcl.update()
+
+opkgcl.install("a")
+if opkgcl.is_installed("a"):
+ print(__file__, ": Package 'a' installed, despite dependency "
+ "upon a package with an unresolved dependency.")
+ exit(False)
+
+if opkgcl.is_installed("b"):
+ print(__file__, ": Package 'b' installed, "
+ "despite unresolved dependency.")
+ exit(False)
diff --git a/src/tests/regress/.svn/text-base/issue45.py.svn-base b/src/tests/regress/.svn/text-base/issue45.py.svn-base
new file mode 100644
index 0000000..30735f9
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue45.py.svn-base
@@ -0,0 +1,33 @@
+#!/usr/bin/python3
+
+import os
+import opk, cfg, opkgcl
+
+opk.regress_init()
+
+o = opk.OpkGroup()
+o.add(Package="a", Depends="b")
+o.add(Package="b")
+o.write_opk()
+o.write_list()
+
+opkgcl.update()
+
+(status, output) = opkgcl.opkgcl("install --force-postinstall a")
+ln_a = output.find("Configuring a")
+ln_b = output.find("Configuring b")
+
+if ln_a == -1:
+ print(__file__, ": Didn't see package 'a' get configured.")
+ exit(False)
+
+if ln_b == -1:
+ print(__file__, ": Didn't see package 'b' get configured.")
+ exit(False)
+
+if ln_a < ln_b:
+ print(__file__, ": Packages 'a' and 'b' configured in wrong order.")
+ exit(False)
+
+opkgcl.remove("a")
+opkgcl.remove("b")
diff --git a/src/tests/regress/.svn/text-base/issue46.py.svn-base b/src/tests/regress/.svn/text-base/issue46.py.svn-base
new file mode 100644
index 0000000..ec56941
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue46.py.svn-base
@@ -0,0 +1,39 @@
+#!/usr/bin/python3
+
+import os
+import opk, cfg, opkgcl
+
+opk.regress_init()
+
+o = opk.OpkGroup()
+o.add(Package="a", Version="1.0", Recommends="b")
+o.add(Package="b", Version="2.0")
+o.write_opk()
+o.write_list()
+
+# prime the status file so 'b' is not installed as a recommendation
+status_filename = "{}/usr/lib/opkg/status".format(cfg.offline_root)
+f = open(status_filename, "w")
+f.write("Package: b\n")
+f.write("Version: 1.0\n")
+f.write("Architecture: all\n")
+f.write("Status: deinstall hold not-installed\n")
+f.close()
+
+opkgcl.update()
+
+opkgcl.install("a")
+if opkgcl.is_installed("b"):
+ print(__file__, ": Package 'b' installed despite "
+ "deinstall/hold status.")
+ exit(False)
+
+opkgcl.remove("a")
+opkgcl.install("a")
+if opkgcl.is_installed("b"):
+ print(__file__, ": Package 'b' installed - deinstall/hold status "
+ "not retained.")
+ exit(False)
+
+opkgcl.remove("a")
+open(status_filename, "w").close()
diff --git a/src/tests/regress/.svn/text-base/issue50.py.svn-base b/src/tests/regress/.svn/text-base/issue50.py.svn-base
new file mode 100644
index 0000000..19897b4
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue50.py.svn-base
@@ -0,0 +1,43 @@
+#!/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)
+
+foo_fullpath = "{}/foo".format(cfg.offline_root)
+
+if not os.path.exists(foo_fullpath):
+ print(__file__, ": File 'foo' incorrectly orphaned.")
+ exit(False)
+
+if not foo_fullpath in opkgcl.files("b"):
+ print(__file__, ": Package 'b' does not own file 'foo'.")
+ exit(False)
+
+opkgcl.remove("a")
+opkgcl.remove("b")
diff --git a/src/tests/regress/.svn/text-base/issue51.py.svn-base b/src/tests/regress/.svn/text-base/issue51.py.svn-base
new file mode 100644
index 0000000..9849dbc
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue51.py.svn-base
@@ -0,0 +1,70 @@
+#!/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)
+bar_fullpath = "{}/bar".format(cfg.offline_root)
+
+if not os.path.exists(foo_fullpath) or not os.path.exists(bar_fullpath):
+ print(__file__, ": Files foo and/or bar are missing.")
+ exit(False)
+
+a_files = opkgcl.files("a")
+if not foo_fullpath in a_files or not bar_fullpath in a_files:
+ print(__file__, ": Package 'a' does not own foo and/or bar.")
+ exit(False)
+
+opkgcl.remove("a")
+
+if os.path.exists(foo_fullpath) or os.path.exists(bar_fullpath):
+ print(__file__, ": Files foo and/or bar still exist "
+ "after removal of package 'a'.")
+ exit(False)
+
+# ----
+o = opk.OpkGroup()
+a2 = opk.Opk(Package="a")
+a2.write()
+o.opk_list.append(a2)
+o.write_list()
+
+
+opkgcl.update()
+
+opkgcl.install("a", "--force-reinstall")
+
+if os.path.exists(foo_fullpath):
+ print(__file__, ": File 'foo' not orphaned as it should be.")
+ exit(False)
+
+if foo_fullpath in opkgcl.files("a"):
+ print(__file__, ": Package 'a' incorrectly owns file 'foo'.")
+ exit(False)
+
+opkgcl.remove("a")
diff --git a/src/tests/regress/.svn/text-base/issue55.py.svn-base b/src/tests/regress/.svn/text-base/issue55.py.svn-base
new file mode 100644
index 0000000..8628306
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue55.py.svn-base
@@ -0,0 +1,25 @@
+#!/usr/bin/python3
+
+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"):
+ print(__file__, ": Package 'a' not installed.")
+ exit(False)
+
+if not os.path.lexists("{}/linky".format(cfg.offline_root)):
+ print(__file__, ": symlink to file with a name longer than 100 "
+ "characters not created.")
+ exit(False)
+
+opkgcl.remove("a")
diff --git a/src/tests/regress/.svn/text-base/issue58.py.svn-base b/src/tests/regress/.svn/text-base/issue58.py.svn-base
new file mode 100644
index 0000000..72a1854
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue58.py.svn-base
@@ -0,0 +1,31 @@
+#!/usr/bin/python3
+
+import os
+import opk, cfg, opkgcl
+
+opk.regress_init()
+
+o = opk.OpkGroup()
+o.add(Package="a", Recommends="b")
+o.add(Package="b")
+o.add(Package="c", Recommends="b")
+o.write_opk()
+o.write_list()
+
+opkgcl.update()
+
+opkgcl.install("a")
+opkgcl.install("c")
+
+opkgcl.remove("a", "--autoremove")
+if not opkgcl.is_installed("b"):
+ print(__file__, ": Pacakge 'b' orphaned despite remaining "
+ "recommending package 'c'.")
+ exit(False)
+
+opkgcl.remove("c", "--autoremove")
+if opkgcl.is_installed("b"):
+ print(__file__, ": Recommended package 'b' not autoremoved.")
+ exit(False)
+
+
diff --git a/src/tests/regress/.svn/text-base/issue72.py.svn-base b/src/tests/regress/.svn/text-base/issue72.py.svn-base
new file mode 100644
index 0000000..d0c511b
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue72.py.svn-base
@@ -0,0 +1,52 @@
+#!/usr/bin/python3
+
+import os
+import opk, cfg, opkgcl
+
+opk.regress_init()
+
+long_dir = 110*"a"
+long_b = 110*"b"
+long_filename = long_dir + "/"+ long_b
+long_filename2 = long_dir + "/" + 110*"c"
+
+os.mkdir(long_dir)
+open(long_filename, "w").close()
+os.symlink(long_b, long_filename2)
+a = opk.Opk(Package="a")
+a.write(data_files=[long_dir, long_filename, long_filename2])
+os.unlink(long_filename)
+os.unlink(long_filename2)
+os.rmdir(long_dir)
+opkgcl.install("a_1.0_all.opk")
+
+if not opkgcl.is_installed("a"):
+ print(__file__, ": Package 'a' not installed.")
+ exit(False)
+
+if not os.path.exists("{}/{}".format(cfg.offline_root, long_dir)):
+ print(__file__, ": dir with name longer than 100 "
+ "characters not created.")
+ exit(False)
+
+if not os.path.exists("{}/{}".format(cfg.offline_root, long_filename)):
+ print(__file__, ": file with a name longer than 100 characters, "
+ "in dir with name longer than 100 characters, "
+ "not created.")
+ exit(False)
+
+if not os.path.lexists("{}/{}".format(cfg.offline_root, long_filename2)):
+ print(__file__, ": symlink with a name longer than 100 characters, "
+ "pointing at a file with a name longer than "
+ "100 characters,"
+ "in dir with name longer than 100 characters, "
+ "not created.")
+ exit(False)
+
+linky = os.path.realpath("{}/{}".format(cfg.offline_root, long_filename2))
+linky_dst = "{}/{}".format(cfg.offline_root, long_filename)
+if linky != linky_dst:
+ print(__file__, ": symlink path truncated.")
+ exit(False)
+
+opkgcl.remove("a")
diff --git a/src/tests/regress/.svn/text-base/issue79.py.svn-base b/src/tests/regress/.svn/text-base/issue79.py.svn-base
new file mode 100644
index 0000000..30ba201
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue79.py.svn-base
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+import os
+import opk, cfg, opkgcl
+
+opk.regress_init()
+
+o = opk.OpkGroup()
+o.add(Package="a", Version="1.0", Depends="b")
+o.add(Package="b", Version="1.0")
+o.add(Package="c", Version="1.0", Depends="b")
+o.write_opk()
+o.write_list()
+
+opkgcl.update()
+opkgcl.install("a")
+opkgcl.install("c")
+
+opkgcl.flag_unpacked("a")
+
+o = opk.OpkGroup()
+o.add(Package="a", Version="1.0", Depends="b")
+o.add(Package="b", Version="1.0")
+o.add(Package="c", Version="2.0")
+o.write_opk()
+o.write_list()
+
+opkgcl.update()
+opkgcl.upgrade("--autoremove")
+
+if not opkgcl.is_installed("b", "1.0"):
+ print("b has been removed even though a still depends on it")
+ exit(False)
diff --git a/src/tests/regress/.svn/text-base/issue84.py.svn-base b/src/tests/regress/.svn/text-base/issue84.py.svn-base
new file mode 100644
index 0000000..1f5d43e
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue84.py.svn-base
@@ -0,0 +1,45 @@
+#!/usr/bin/python3
+
+import opk, cfg, opkgcl
+
+def cleanup():
+ opkgcl.remove("a1")
+ opkgcl.remove("b1")
+ opkgcl.remove("a")
+ opkgcl.remove("b")
+ opkgcl.remove('c')
+
+opk.regress_init()
+
+o = opk.OpkGroup()
+o.add(Package="a", Provides="v", Depends="a1")
+o.add(Package="b", Provides="v", Depends="b1")
+o.add(Package="c", Depends="v")
+o.add(Package="a1")
+o.add(Package="b1")
+
+o.write_opk()
+o.write_list()
+
+opkgcl.update()
+
+# install ``a1`` directly
+opkgcl.install("a1_1.0_all.opk")
+if not opkgcl.is_installed("a1"):
+ print(__file__, ": package ``a1'' not installed.")
+ cleanup()
+ exit(False)
+
+# install ``c'' from repository
+opkgcl.install("c")
+if not opkgcl.is_installed("c"):
+ print(__file__, ": package ``c'' not installed.")
+ cleanup()
+ exit(False)
+
+if opkgcl.is_installed("b1"):
+ print(__file__, ": package ``b1'' is installed, but should not be.")
+ cleanup()
+ exit(False)
+
+cleanup()
diff --git a/src/tests/regress/.svn/text-base/issue85.py.svn-base b/src/tests/regress/.svn/text-base/issue85.py.svn-base
new file mode 100644
index 0000000..3250075
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/issue85.py.svn-base
@@ -0,0 +1,29 @@
+#!/usr/bin/python3
+
+import opk, cfg, opkgcl
+
+def cleanup():
+ opkgcl.remove("a")
+ opkgcl.remove("b")
+ opkgcl.remove('c')
+
+opk.regress_init()
+
+o = opk.OpkGroup()
+o.add(Package="a", Provides="v")
+o.add(Package="b", Provides="v", Depends="b_nonexistant")
+o.add(Package="c", Depends="v")
+
+o.write_opk()
+o.write_list()
+
+opkgcl.update()
+
+# install ``c'' from repository
+opkgcl.install("c")
+if not opkgcl.is_installed("c"):
+ print(__file__, ": package ``c'' not installed.")
+ cleanup()
+ exit(False)
+
+cleanup()
diff --git a/src/tests/regress/.svn/text-base/opk.py.svn-base b/src/tests/regress/.svn/text-base/opk.py.svn-base
new file mode 100644
index 0000000..f96037e
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/opk.py.svn-base
@@ -0,0 +1,111 @@
+import tarfile, os
+import cfg
+
+class Opk:
+ valid_control_fields = ["Package", "Version", "Depends", "Provides",\
+ "Replaces", "Conflicts", "Suggests", "Recommends",\
+ "Section", "Architecture", "Maintainer", "MD5Sum",\
+ "Size", "InstalledSize", "Filename", "Source",\
+ "Description", "OE", "Homepage", "Priority",\
+ "Conffiles"]
+
+ def __init__(self, **control):
+ for k in control.keys():
+ if k not in self.valid_control_fields:
+ raise Exception("Invalid control field: "
+ "{}".format(k))
+ if "Package" not in control.keys():
+ print("Cannot create opk without Package name.\n")
+ return None
+ if "Architecture" not in control.keys():
+ control["Architecture"] = "all"
+ if "Version" not in control.keys():
+ control["Version"] = "1.0"
+ self.control = control
+
+ def write(self, tar_not_ar=False, data_files=None):
+ filename = "{Package}_{Version}_{Architecture}.opk"\
+ .format(**self.control)
+ if os.path.exists(filename):
+ os.unlink(filename)
+ if os.path.exists("control"):
+ os.unlink("control")
+ if os.path.exists("control.tar.gz"):
+ os.unlink("control.tar.gz")
+ if os.path.exists("data.tar.gz"):
+ os.unlink("data.tar.gz")
+
+ f = open("control", "w")
+ for k in self.control.keys():
+ f.write("{}: {}\n".format(k, self.control[k]))
+ f.close()
+
+ tar = tarfile.open("control.tar.gz", "w:gz")
+ tar.add("control")
+ tar.close()
+
+ tar = tarfile.open("data.tar.gz", "w:gz")
+ if data_files:
+ for df in data_files:
+ tar.add(df)
+ tar.close()
+
+
+ if tar_not_ar:
+ tar = tarfile.open(filename, "w:gz")
+ tar.add("control.tar.gz")
+ tar.add("data.tar.gz")
+ tar.close()
+ else:
+ os.system("ar q {} control.tar.gz data.tar.gz \
+ 2>/dev/null".format(filename))
+
+ os.unlink("control")
+ os.unlink("control.tar.gz")
+ os.unlink("data.tar.gz")
+
+class OpkGroup:
+ def __init__(self):
+ self.opk_list = []
+
+ def add(self, **control):
+ self.opk_list.append(Opk(**control))
+
+ def addOpk(self, opk):
+ self.opk_list.append(opk)
+
+ def write_opk(self, tar_not_ar=False):
+ for o in self.opk_list:
+ o.write(tar_not_ar)
+
+ def write_list(self, filename="Packages"):
+ f = open(filename, "w")
+ for opk in self.opk_list:
+ for k in opk.control.keys():
+ f.write("{}: {}\n".format(k, opk.control[k]))
+ f.write("Filename: {Package}_{Version}_{Architecture}"
+ ".opk\n".format(**opk.control))
+ f.write("\n")
+ f.close()
+
+
+def regress_init():
+ """
+ Initialisation and sanity checking.
+ """
+
+ if not os.access(cfg.opkgcl, os.X_OK):
+ print("Cannot exec {}".format(cfg.opkgcl))
+ exit(False)
+
+ os.chdir(cfg.opkdir)
+
+ os.system("rm -fr {}".format(cfg.offline_root))
+
+ os.makedirs("{}/usr/lib/opkg".format(cfg.offline_root))
+ os.makedirs("{}/etc/opkg".format(cfg.offline_root))
+
+ f = open("{}/etc/opkg/opkg.conf".format(cfg.offline_root), "w")
+ f.write("arch all 1\n")
+ f.write("src test file:{}\n".format(cfg.opkdir))
+ f.close()
diff --git a/src/tests/regress/.svn/text-base/opkgcl.py.svn-base b/src/tests/regress/.svn/text-base/opkgcl.py.svn-base
new file mode 100644
index 0000000..47e7dd3
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/opkgcl.py.svn-base
@@ -0,0 +1,64 @@
+#!/usr/bin/python3
+
+import os, subprocess
+import cfg
+
+def opkgcl(opkg_args):
+ cmd = "{} -o {} {}".format(cfg.opkgcl, cfg.offline_root, opkg_args)
+ #print(cmd)
+ return subprocess.getstatusoutput(cmd)
+
+def install(pkg_name, flags=""):
+ return opkgcl("{} install {}".format(flags, pkg_name))[0]
+
+def remove(pkg_name, flags=""):
+ return opkgcl("{} remove {}".format(flags, pkg_name))[0]
+
+def update():
+ return opkgcl("update")[0]
+
+def upgrade(params=None):
+ if params:
+ opkgcl("upgrade {}".format(params))[0]
+ else:
+ return opkgcl("upgrade")[0]
+
+def files(pkg_name):
+ output = opkgcl("files {}".format(pkg_name))[1]
+ return output.split("\n")[1:]
+
+
+def flag_unpacked(pkg_name):
+ out = opkgcl("flag unpacked {}".format(pkg_name))
+ return out == "Setting flags for package {} to unpacked.".format(pkg_name)
+
+def is_installed(pkg_name, version=None):
+ out = opkgcl("list_installed {}".format(pkg_name))[1]
+ if len(out) == 0 or out.split()[0] != pkg_name:
+ return False
+ if version and out.split()[2] != version:
+ return False
+ if not os.path.exists("{}/usr/lib/opkg/info/{}.control"\
+ .format(cfg.offline_root, pkg_name)):
+ return False
+ return True
+
+def is_autoinstalled(pkg_name):
+ status_path = "{}/usr/lib/opkg/status".format(cfg.offline_root)
+ if not os.path.exists(status_path):
+ return False
+ status_file = open(status_path, "r")
+ status = status_file.read()
+ status_file.close()
+ index_start = status.find("Package: {}".format(pkg_name))
+ if index_start < 0:
+ return False
+ index_end = status.find("\n\n", index_start)
+ return status.find("Auto-Installed: yes", index_start, index_end) >= 0
+
+
+if __name__ == '__main__':
+ import sys
+ (status, output) = opkgcl(" ".join(sys.argv[1:]))
+ print(output)
+ exit(status)
diff --git a/src/tests/regress/.svn/text-base/update_loses_autoinstalled_flag.py.svn-base b/src/tests/regress/.svn/text-base/update_loses_autoinstalled_flag.py.svn-base
new file mode 100644
index 0000000..5ae030c
--- /dev/null
+++ b/src/tests/regress/.svn/text-base/update_loses_autoinstalled_flag.py.svn-base
@@ -0,0 +1,63 @@
+#!/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"):
+ print("b is not autoinstalled")
+ exit(False)
+
+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"])
+
+ o = opk.OpkGroup()
+ o.addOpk(a)
+ o.addOpk(b)
+ o.write_list()
+
+ opkgcl.update()
+ opkgcl.upgrade();
+
+ if not opkgcl.is_autoinstalled("b"):
+ print("b is not autoinstalled anymore")
+ exit(False)
+
+a = opk.Opk(Package="a", Version="3.0")
+a.write(data_files=["asdf"])
+os.unlink("asdf")
+
+o = opk.OpkGroup()
+o.addOpk(a)
+o.write_list()
+
+opkgcl.update()
+opkgcl.upgrade();
+
+if opkgcl.is_installed("b", "2.0"):
+ print("b is still installed")
+ exit(False)
+
+if not opkgcl.is_installed("a", "3.0"):
+ print("a is not installed")
+ exit(False)