33import sys
44from pathlib import Path
55
6- repo_root = Path (__file__ ).parent .parent / "src"
7- sys .path .append (str (repo_root ))
6+ packages_root = Path (__file__ ).parent .parent / "packages"
7+ sys .path .extend (
8+ [
9+ str (packages_root / "debmagic-common" / "src" ),
10+ str (packages_root / "debmagic-pkg" / "src" ),
11+ ]
12+ )
813
9- from debmagic .v0 import package
10- from debmagic .v0 import dh as dh_mod
14+ from debmagic .v0 import package , dh , Build
1115
12- dh = dh_mod .Preset (dh_args = ["--with" , "python3" , "--buildsystem=pybuild" ])
16+ dhp = dh .Preset (dh_args = ["--with" , "python3" , "--buildsystem=pybuild" ])
1317
1418pkg = package (
15- preset = [dh ],
19+ preset = [dhp ],
1620)
1721
18- pkg .pack ()
22+ packages = {
23+ "python3-debmagic-common" : ("packages/debmagic-common" , "debmagic-common" ),
24+ "debmagic" : ("packages/debmagic" , "debmagic" ),
25+ "debmagic-pkg" : ("packages/debmagic-pkg" , "debmagic-pkg" ),
26+ }
27+
28+ def dh_auto (build : Build , stage : str , use_destdir : bool = False ):
29+ for pkg_name , (path , python_pkg_name ) in packages .items ():
30+ destdir = f" --destdir debian/{ pkg_name } " if use_destdir else ""
31+ build .cmd (f"{ stage } -p { pkg_name } --sourcedirectory { path } --buildsystem=pybuild { destdir } -- --name { python_pkg_name } " )
32+
33+ @dhp .override
34+ def dh_auto_configure (build : Build ):
35+ dh_auto (build , "dh_auto_configure" )
36+
37+
38+ @dhp .override
39+ def dh_auto_build (build : Build ):
40+ dh_auto (build , "dh_auto_build" )
41+
42+
43+ @dhp .override
44+ def dh_auto_install (build : Build ):
45+ dh_auto (build , "dh_auto_install" , use_destdir = True )
46+
47+
48+ @dhp .override
49+ def dh_auto_test (build : Build ):
50+ dh_auto (build , "dh_auto_test" )
51+
52+
53+ @dhp .override
54+ def dh_auto_clean (build : Build ):
55+ dh_auto (build , "dh_auto_clean" )
56+
57+
58+ pkg .pack ()
0 commit comments