a lgc@sddlZddlZddlZddlZddlZz ddlZWneyFYn0ddZddZ ddZ dd Z d d Z d d Z ddZddZddZddZdS)NcCsLtj|}|r"|d|d}n|}dd|dddg}tj||dd S) z :param pkgname: of the meta-package to depend on (e.g. osmocom-nightly) :param version: of the meta-pkgname to depend on or None z (= )sedzs/^Depends: /Depends: z, /-izdebian/controlcwdN)libgit get_repo_pathrun_cmd)projectpkgnameversion repo_pathZdependcmdrX/home/osmocom-build/jenkins/workspace/gerrit-binpkgs@2/osmo-ci/scripts/obs/lib/debian.pycontrol_add_depends  rc Cstjj}tj|}|d}t|}|ddd}|sBJ|dd}t j t j j }| d}t|dr} | |d |d | d | d |d | d | d|d | d | |Wdn1s0YdS)z- :param version: for the new changelog entry /debian/changelog r-.z%a, %d %b %Y %H:%M:%S %zwz (z) unstable; urgency=medium  zE * Automatically generated changelog entry for building the Osmocom z feed z, -- Osmocom OBS scripts N)rargsfeedrr openreadsplitreplacedatetimeZnowtimezoneZutcstrftimewrite) r r rrchangelog_pathZ changelog_oldr dateZdate_strfrrrchangelog_add_entry s&          r'cCs|tj|}|d}tj|s&dSd}t|d}||krHdSt |d|d|dt|d |d dS) zE Always use format "3.0 (native)" (e.g. limesuite has "3.0 (quilt)").z/debian/source/formatNz 3.0 (native)rz: fixing debian/source/format ( => rrr) rrr ospathexistsrrrstripprintr#)r rZ format_pathZexpectedcurrentrrrfix_source_format?s   r0cCstj|}|d}tj|s0J|dt|}|sNJ|d|dddddd}|s|J|d|S) Nrz: missing debian/changelogz: debian/changelog is empty(rrrz0: couldn't find last version in debian/changelog) rrr r*r+r,rrr)r rr$Z changelogretrrrget_last_version_from_changelogPs   r3cCs8|dur dSd|vr(|dddd}|dd}|S)Nz osmo-epdg-rz -osmo-epdgrr)r)r rrrtransform_version_s  r5cCst|}zPtj|ddtj|ddkrVt|d|d|dWdSWntjjynYn0t|}||krdSt|d|d|d t||dS) zc Adjust the changelog if the version in the changelog is different from the given version. rrz#: WARNING: version from changelog (z+) is higher than version based on git tag (z9), using version from changelog (git tag not pushed yet?)Nz!: adding debian/changelog entry (r)r) r3 packagingr parserr.ZInvalidVersionr5r')r r Zversion_changelogrrrchangelog_add_entry_if_neededjs(   r8c Cs8t|d|tj|d}d}d}t|d}|}Wdn1sT0Ytt|D]x}||}|drd}qjd|vrqj|sJd | d d vr| d d |d ||<n| dd|d ||<d}qqj|s|ddd|dg7}t|d}| |Wdn1s*0YdS)z Add 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/rulesFr(Nzoverride_dh_auto_configure:TZdh_auto_configurez --  rz --rzdh_auto_configure -- rzoverride_dh_auto_configure: z dh_auto_configure -- r) r.rrr r readlinesrangelen startswithr writelines) r parametersZrulesZoverride_foundZreplacedr&linesilinerrrconfigure_appends8 &    rCcCst|dtj|d}tddd|dgtddd|dgtjdt|d d d tddd |d gtddd|d gdS)zt Disabling manuals speeds up the build time significantly, we don't need them for e.g. the asan repository. z: disabling manualsz/debianrrz/osmo-gsm-manuals-dev/dz/controlz /doxygen/dzrm -rf z/*-doc.installT)shellzs/--enable-manuals//gz/ruleszs/--enable-doxygen//gN)r.rrr r shlexquote)r debianrrrdisable_manualssrHcCs4t|t|dtjgdtj|ddS)Nz : building debian source package)zdpkg-buildpackagez-Sz-ucz-usz-dr)r0r.rr rr )r rrrbuild_source_packages   rIcCs.t|}tjdt|dtjjddS)Nzmv *.tar* *.dsc T)rDr)rget_output_pathr rErFconfig path_cache)r Z path_outputrrrmove_files_to_outputs rM)r r*rErlib.gitZpackaging.versionr6 ImportErrorrr'r0r3r5r8rCrHrIrMrrrrs$   !