
    $i                         S SK r S SKrS SKrS SKrS SKr S SKrS rS r	S r
S rS rS rS rS	 rS
 rS rg! \ a     N'f = f)    Nc                     [         R                  R                  U 5      nU(       a	  U SU S3nOUnSSU S3SS/n[         R                  " XSS9  g	)
z:param pkgname: of the meta-package to depend on (e.g. osmocom-nightly)
:param version: of the meta-pkgname to depend on or Nonez (= )sedzs/^Depends: /Depends: z, /-izdebian/controlcwdN)libgitget_repo_pathrun_cmd)projectpkgnameversion	repo_pathdependcmds         /obs/lib/debian.pycontrol_add_dependr      sW     %%g.I9D	+*6(#6>N
OCKK#    c                    [         R                  R                  n[         R                  R	                  U 5      nU S3n[        U5      R                  5       nUR                  SS5      S   nU(       d   eUR                  SS5      n[        R                  R                  [        R                  R                  5      nUR                  S5      n[        US5       n	U	R                  U S	U S
35        U	R                  S5        U	R                  SU S35        U	R                  S5        U	R                  SU S35        U	R                  S5        U	R                  U5        SSS5        g! , (       d  f       g= f)z+:param version: for the new changelog entry/debian/changelog    r   -.z%a, %d %b %Y %H:%M:%S %zwz (z) unstable; urgency=medium

zE  * Automatically generated changelog entry for building the Osmocom z feed
z, -- Osmocom OBS scripts <info@osmocom.org>  N)r	   argsfeedr
   r   openreadsplitreplacedatetimenowtimezoneutcstrftimewrite)
r   r   r   r   changelog_pathchangelog_oldr   datedate_strfs
             r   changelog_add_entryr/   !   s8   88==D%%g.I!{"34N(--/M !!#q)!,GN7 ooc3'G   !2!2!6!67D}}78H 
nc	"a	7)2gY&BCD		WX\W]]def		>xjKL		 
#	"	"s   BE++
E9c                 Z   [         R                  R                  U 5      nU S3n[        R                  R                  U5      (       d  gSn[        US5      R                  5       R                  5       nXC:X  a  g[        U  SU SU S35        [        US5      R                  U S	35        g)
zDAlways use format "3.0 (native)" (e.g. limesuite has "3.0 (quilt)").z/debian/source/formatNz3.0 (native)rz: fixing debian/source/format ( => r   r   r   )r	   r
   r   ospathexistsr    r!   rstripprintr)   )r   r   format_pathexpectedcurrents        r   fix_source_formatr;   ?   s    %%g.IK45K77>>+&&H;$))+224G	WI4WIT(1
MNc  H:R1r   c                 p   [         R                  R                  U 5      nU S3n[        R                  R                  U5      (       d
   U  S35       e[        U5      R                  5       nU(       d
   U  S35       eUR                  SS5      S   R                  SS5      S   nU(       d
   U  S35       eU$ )	Nr   z: missing debian/changelogz: debian/changelog is empty(r   r   r   z0: couldn't find last version in debian/changelog)	r	   r
   r   r3   r4   r5   r    r!   r"   )r   r   r*   	changelogrets        r   get_last_version_from_changelogr@   P   s    %%g.I!{"34N77>>.))QgY6P+QQ)^$))+I=	!<==9
//#q
!!
$
*
*3
21
5CL7)KLL3Jr   c                 j    U c  g SU ;   a  U R                  SSS5       S3n U R                  SS5      n U $ )Nz
osmo-epdg- r   z
-osmo-epdgr   r   )r#   )r   s    r   transform_versionrC   _   sA    w__\2q9:*Eooc3'GNr   c                 0   [        U 5      n [        R                  R                  UR	                  S5      S   5      [        R                  R                  UR	                  S5      S   5      :  aQ  [        U  SU SU S35        [        R                  R                  (       a  [        U  S35        O[        U  S35        g [        U5      nX!:X  a  g[        U  S	U S
U S35        [        X5        g! [        R                  R                   a     NQf = f)zYAdjust the changelog if the version in the changelog is different from
the given version.r   r   z#: WARNING: version from changelog (z+) is higher than version based on git tag (r   zE: WARNING: assuming commit from last git tag was amended, ignoring...zA: WARNING: using version from changelog (git tag not pushed yet?)Nz!: adding debian/changelog entry (r2   )r@   	packagingr   parser"   r7   r	   r   version_appendInvalidVersionrC   r/   )r   r   version_changelogs      r   changelog_add_entry_if_neededrJ   j   s,    8@""#4#:#:3#?#BCiFWFWF]F]^e^k^klo^pqr^sFtt)>?P>QQ|  ~E  }F  FG  H xx&&	!fgh	!bcd u   (G#	WI67H6IgYVW
XY) ++  		s   B%C4 3C4 4DDc                    [        U  SU 35        [        R                  R                  U 5       S3nSn[	        US5       nUR                  5       nSSS5        [        [        W5      5       Hy  nXV   nUR                  S5      (       a  SnM!  SU;  a  M)  U(       d   eS	UR                  S
S5      ;   a  UR                  SS	U 3S5      XV'   OUR                  SSU 3S5      XV'     O   U(       d  USSSU S3/-  n[	        US5       nUR                  U5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)zAdd one or more configure parameters like --enable-sanitize to the
dh_auto_configure line, also add the override_dh_auto_configure block
if missing.z: adding configure parameters: z/debian/rulesFr1   Nzoverride_dh_auto_configure:Tdh_auto_configurez -- 	r   z --r   zdh_auto_configure -- r   zoverride_dh_auto_configure:
z	dh_auto_configure -- r   )r7   r	   r
   r   r    	readlinesrangelen
startswithr#   
writelines)r   
parametersrulesoverride_foundr.   linesilines           r   configure_appendrY      sE    
WI4ZL
ABww$$W-.m<EN	eS	Q 
3u:x??899!Nd*~T\\$,,||ET*+>BEH||$7;PQ[P\9]_`aEH  +%j\4
 	

 
eS	Q	U 
	+ 
	* 
	s   D%
D6%
D36
Ec                    [        U  S35        [        R                  R                  U 5       S3n[        R                  " SSSU S3/5        [        R                  " SSSU S3/5        [        R                  " S[
        R                  " U5       S	3S
S9  [        R                  " SSSU S3/5        [        R                  " SSSU S3/5        [        R                  " SSSU S3/5        g)zjDisabling manuals speeds up the build time significantly, we don't
need them for e.g. the asan repository.z: disabling manualsz/debianr   r   z/osmo-gsm-manuals-dev/dz/controlz
/doxygen/dzrm -rf z/*-doc.installT)shellzs/--enable-manuals//gz/ruleszs/--enable-doxygen//gzs/$(MAKE) -C doc\/manuals//gN)r7   r	   r
   r   r   shlexquote)r   debians     r   disable_manualsr_      s     
WI(
)*%%g./w7FKK7F889LMNKKlvhh,?@AKK'%++f-.n=TJKK5&7HIJKK5&7HIJKK<>OPQr   c                     [        U 5        [        U  S35        [        R                  " / SQ[        R                  R                  U 5      S9  g )Nz : building debian source package)zdpkg-buildpackagez-Sz-ucz-usz-dr   )r;   r7   r	   r   r
   r   )r   s    r   build_source_packagera      s;    g	WI5
67KK7GG!!'*r   c                     [         R                  " U 5      n[         R                  " S[        R                  " U5       3S[         R
                  R                  S9  g )Nzmv *.tar* *.dsc T)r[   r   )r	   get_output_pathr   r\   r]   config
path_cache)r   path_outputs     r   move_files_to_outputrg      sB    %%g.KKK
5;;{345JJ!!r   )r$   r3   r\   r	   lib.gitpackaging.versionrE   ImportErrorr   r/   r;   r@   rC   rJ   rY   r_   ra   rg    r   r   <module>rl      sh     	  
 
	
$<2"*@@R i  		s   9 AA