1#!/usr/bin/python3 2 3import os 4import opk, cfg, opkgcl 5 6opk.regress_init() 7 8open("foo", "w").close() 9a1 = opk.Opk(Package="a", Version="1.0", Architecture="all") 10a1.write(data_files=["foo"]) 11os.rename("a_1.0_all.opk", "a_with_foo.opk") 12 13opkgcl.install("a_with_foo.opk") 14 15# ---- 16opkgcl.install("a_with_foo.opk") 17 18open("bar", "w").close() 19o = opk.OpkGroup() 20a2 = opk.Opk(Package="a", Version="1.0", Architecture="all") 21a2.write(data_files=["foo", "bar"]) 22o.opk_list.append(a2) 23o.write_list() 24 25os.unlink("foo") 26os.unlink("bar") 27 28opkgcl.update() 29opkgcl.install("a", "--force-reinstall") 30 31foo_fullpath = "{}/foo".format(cfg.offline_root) 32bar_fullpath = "{}/bar".format(cfg.offline_root) 33 34if not os.path.exists(foo_fullpath) or not os.path.exists(bar_fullpath): 35 print(__file__, ": Files foo and/or bar are missing.") 36 exit(False) 37 38a_files = opkgcl.files("a") 39if not foo_fullpath in a_files or not bar_fullpath in a_files: 40 print(__file__, ": Package 'a' does not own foo and/or bar.") 41 exit(False) 42 43opkgcl.remove("a") 44 45if os.path.exists(foo_fullpath) or os.path.exists(bar_fullpath): 46 print(__file__, ": Files foo and/or bar still exist " 47 "after removal of package 'a'.") 48 exit(False) 49 50# ---- 51o = opk.OpkGroup() 52a2 = opk.Opk(Package="a", Version="1.0", Architecture="all") 53a2.write() 54o.opk_list.append(a2) 55o.write_list() 56 57 58opkgcl.update() 59 60opkgcl.install("a", "--force-reinstall") 61 62if os.path.exists(foo_fullpath): 63 print(__file__, ": File 'foo' not orphaned as it should be.") 64 exit(False) 65 66if foo_fullpath in opkgcl.files("a"): 67 print(__file__, ": Package 'a' incorrectly owns file 'foo'.") 68 exit(False) 69 70opkgcl.remove("a") 71