@@ -843,32 +843,41 @@ def fetchDebianChangelog(packageInfo, codename = 'unstable'):
843843
844844 # ====== Get package status =================================================
845845 statusPageContents = None
846- sys .stderr .write ('Looking for package status on ' + statusPageURL + ' ... ' )
847- sys .stderr .flush ()
848- try :
849- statusPage = urllib .request .urlopen (statusPageURL )
850- statusPageContents = statusPage .readlines ()
851- statusPage .close ()
852-
853- re_debian_package = re .compile (r'.*Source Package: ' + packageInfo ['debian_package_name' ] + r' \(([0-9-+~\.a-z]+)\)' )
854- re_debian_archive = re .compile (r'.*href="((http|https)://[a-zA-Z0-9\./+-]+/' + \
855- packageInfo ['debian_package_name' ][0 :1 ] + '/' + \
856- packageInfo ['debian_package_name' ] + '/' + \
857- r')(' + packageInfo ['debian_package_name' ] + r'_[0-9-+~\.a-z]+\.debian\.tar\.[a-zA-Z]+)"' )
858- for line in statusPageContents :
859- line = line .decode ('utf-8' )
860- match = re_debian_package .match (line )
861- if match != None :
862- debianVersion = match .group (1 )
863- else :
864- match = re_debian_archive .match (line )
846+ maxTrials = 10
847+ for trial in range (0 , maxTrials ):
848+ if trial > 0 :
849+ sys .stderr .write ('\n ' )
850+ sys .stderr .write ('Looking for package status on ' + statusPageURL +
851+ ' (trial ' + str (trial + 1 ) + '/' + str (maxTrials ) + ') ... ' )
852+ sys .stderr .flush ()
853+
854+ try :
855+ statusPage = urllib .request .urlopen (statusPageURL )
856+ statusPageContents = statusPage .readlines ()
857+ statusPage .close ()
858+
859+ re_debian_package = re .compile (r'.*Source Package: ' + packageInfo ['debian_package_name' ] + r' \(([0-9-+~\.a-z]+)\)' )
860+ re_debian_archive = re .compile (r'.*href="((http|https)://[a-zA-Z0-9\./+-]+/' + \
861+ packageInfo ['debian_package_name' ][0 :1 ] + '/' + \
862+ packageInfo ['debian_package_name' ] + '/' + \
863+ r')(' + packageInfo ['debian_package_name' ] + r'_[0-9-+~\.a-z]+\.debian\.tar\.[a-zA-Z]+)"' )
864+ for line in statusPageContents :
865+ line = line .decode ('utf-8' )
866+ match = re_debian_package .match (line )
865867 if match != None :
866- debianLocation = match .group (1 )
867- debianArchive = match .group (3 )
868+ debianVersion = match .group (1 )
869+ else :
870+ match = re_debian_archive .match (line )
871+ if match != None :
872+ debianLocation = match .group (1 )
873+ debianArchive = match .group (3 )
868874
869- except urllib .error .HTTPError as e :
870- sys .stderr .write ('not found (HTTP ' + str (e .code ) + ')!\n ' )
871- sys .exit (1 )
875+ # Done!
876+ break
877+
878+ except urllib .error .HTTPError as e :
879+ sys .stderr .write ('not found (HTTP ' + str (e .code ) + ')!\n ' )
880+ sys .exit (1 )
872881
873882 if (debianVersion == None ) or (debianArchive == None ):
874883 sys .stderr .write ('not found!\n ' )
@@ -1367,7 +1376,7 @@ def makeSourceDeb(packageInfo, codenames, skipPackageSigning, summaryFile):
13671376
13681377
13691378# ###### Build Debian binary package ########################################
1370- def buildDeb (packageInfo , codenames , architectures , skipPackageSigning , summaryFile ):
1379+ def buildDeb (packageInfo , codenames , architectures , skipPackageSigning , summaryFile , twice ):
13711380
13721381 # ====== Build for each distribution codename ============================
13731382 printSection ('Creating binary Debian packages' )
@@ -1412,8 +1421,10 @@ def buildDeb(packageInfo, codenames, architectures, skipPackageSigning, summaryF
14121421 'pbuilder' ,
14131422 'build' ,
14141423 '--basetgz' , basetgz ,
1415- '--logfile' , buildlog ,
1416- dscFileName ]
1424+ '--logfile' , buildlog ]
1425+ if twice :
1426+ pbuilderCommand .append ('--twice' )
1427+ pbuilderCommand .append (dscFileName )
14171428 print (pbuilderCommand )
14181429 try :
14191430 subprocess .run (pbuilderCommand , check = True )
@@ -1716,7 +1727,7 @@ if len(sys.argv) < 2:
17161727 sys .stderr .write ('\n * ' + sys .argv [0 ] + ' info\n ' )
17171728 sys .stderr .write ('\n * ' + sys .argv [0 ] + ' make-source-tarball [--skip-signing]\n ' )
17181729 sys .stderr .write ('\n * ' + sys .argv [0 ] + ' make-source-deb [--summary=file] [codename ...] [--skip-signing]\n ' )
1719- sys .stderr .write (' ' + sys .argv [0 ] + ' build-deb [--summary=file] [codename ...] [--skip-signing] [--architecture=arch[,...]]\n ' )
1730+ sys .stderr .write (' ' + sys .argv [0 ] + ' build-deb [--summary=file] [codename ...] [--skip-signing] [--architecture=arch[,...]] [--twice] \n ' )
17201731 sys .stderr .write (' ' + sys .argv [0 ] + ' fetch-debian-changelog [codename]\n ' )
17211732 sys .stderr .write ('\n * ' + sys .argv [0 ] + ' make-source-rpm [--summary=file] [release ...] [--skip-signing]\n ' )
17221733 sys .stderr .write (' ' + sys .argv [0 ] + ' build-rpm [--summary=file] [release ...] [--skip-signing] [--architecture=[,...]]\n ' )
@@ -1782,6 +1793,7 @@ elif tool == 'build-deb':
17821793 summaryFile = None
17831794 codenames = []
17841795 architectures = []
1796+ twice = False
17851797 for i in range (2 , len (sys .argv )):
17861798 if sys .argv [i ][0 ] != '-' :
17871799 codenames .append (sys .argv [i ])
@@ -1797,10 +1809,12 @@ elif tool == 'build-deb':
17971809 elif sys .argv [i ][0 :15 ] == '--architecture=' :
17981810 for architecture in sys .argv [i ][15 :].split (',' ):
17991811 architectures .append (architecture )
1812+ elif sys .argv [i ] == '--twice' :
1813+ twice = True
18001814 else :
18011815 sys .stderr .write ('ERROR: Bad build-deb parameter ' + sys .argv [i ] + '!\n ' )
18021816 sys .exit (1 )
1803- buildDeb (packageInfo , codenames , architectures , skipPackageSigning , summaryFile )
1817+ buildDeb (packageInfo , codenames , architectures , skipPackageSigning , summaryFile , twice )
18041818
18051819# ====== Make source deb file ===============================================
18061820elif tool == 'make-source-rpm' :
0 commit comments