hghooks: delete unused prevent_unlabelled_australis_changes hook (bug 1075318); rs=jaws, edmorley
The prevent_unlabelled_australis_changes hook was added in bug 943486 to
help with the Australis transition. According to comment 42 and after in
that bug and bkero's forensics in bug 1075318, this hook is no longer
used and is thus being deleted.
This patch didn't technically receive a review. But it's deleting a
single, untested file. What could go wrong?
#!/usr/bin/python3# This Source Code Form is subject to the terms of the Mozilla Public# License, v. 2.0. If a copy of the MPL was not distributed with this# file, You can obtain one at http://mozilla.org/MPL/2.0/.# This script runs on container start and is used to bootstrap the BMO# database and start an HTTP server.importosimportshutilimportsocketimportsubprocessimportsysimporttimeimportmysql.connector# Dirty hack to make stdout unbuffered. This matters for Docker log viewing.classUnbuffered(object):def__init__(self,s):self.s=sdefwrite(self,d):self.s.write(d)self.s.flush()def__getattr__(self,a):returngetattr(self.s,a)sys.stdout=Unbuffered(sys.stdout)# We also assign stderr to stdout because Docker sometimes doesn't capture# stderr by default.sys.stderr=sys.stdoutif'BMODB_PORT_3306_TCP_ADDR'notinos.environ:print('error: container invoked improperly. please link to a bmodb container')sys.exit(1)bz_home=os.environ['BUGZILLA_HOME']bz_dir=os.path.join(bz_home,'bugzilla')db_host=os.environ['BMODB_PORT_3306_TCP_ADDR']db_port=os.environ['BMODB_PORT_3306_TCP_PORT']db_user=os.environ.get('DB_USER','root')db_pass=os.environ.get('DB_PASS','password')db_name=os.environ.get('DB_NAME','bugs')db_timeout=int(os.environ.get('DB_TIMEOUT','60'))admin_email=os.environ.get('ADMIN_EMAIL','admin@example.com')admin_password=os.environ.get('ADMIN_PASSWORD','password')bmo_url=os.environ.get('BMO_URL','http://localhost:80/')ifnotbmo_url.endswith('/'):bmo_url+='/'reset_database='RESET_DATABASE'inos.environcc=subprocess.check_callpatches={'apache24.patch','fkpatch.patch','elasticsearch.patch'}patched_files={'.htaccess','Bugzilla/DB.pm','Bugzilla/Install/Requirements.pm'}# Ensure Bugzilla Git clone is up to date.# First unpatch changed files just in case they get modified.cc(['/usr/bin/git','checkout','--']+list(patched_files),cwd=bz_dir)# We want container startup to work when offline. So put this behind# an environment variable that can be specified by automation.if'FETCH_BMO'inos.environ:cc(['/usr/bin/git','fetch','origin'],cwd=bz_dir)bmo_commit=os.environ.get('BMO_COMMIT','origin/master')cc(['/usr/bin/git','checkout',bmo_commit],cwd=bz_dir)forpatchinsorted(patches):print('applying patch %s'%patch)cc(['/usr/bin/git','apply',os.path.join(bz_home,patch)],cwd=bz_dir)# If we start this and the BMODB container at the same time, MySQL may not be# running yet. Wait for it.time_start=time.time()whileTrue:try:print('attempting to connect to database...',end='')# There appear to be race conditions between MySQL opening the socket# and MySQL actually responding. So, we on a successful MySQL# connection before continuing.mysql.connector.connect(user=db_user,password=db_pass,host=db_host,port=db_port)print('connected to database at %s:%s as %s'%(db_host,db_port,db_user))breakexcept(ConnectionError,mysql.connector.errors.Error):print('error')iftime.time()-time_start>db_timeout:print('could not connect to database before timeout; giving up')sys.exit(1)time.sleep(1)j=os.path.joinh=os.environ['BUGZILLA_HOME']b=j(h,'bugzilla')answers=j(h,'checksetup_answers.txt')# We aren't allowed to embed environment variable references in Perl code in# checksetup_answers.txt because Perl executes that file in a sandbox. So we# hack up the file at run time to be sane.withopen(answers,'rb')asfh:lines=fh.readlines()lines=[lforlinlinesifb'#prune'notinl]defwriteanswer(fh,name,value):line="$answer{'%s'} = '%s'; #prune\n"%(name,value)fh.write(line.encode('utf-8'))withopen(answers,'wb')asfh:forlineinlines:fh.write(line)fh.write(b'\n')writeanswer(fh,'db_user',db_user)writeanswer(fh,'db_pass',db_pass)writeanswer(fh,'db_host',db_host)writeanswer(fh,'db_port',db_port)writeanswer(fh,'db_name',db_name)writeanswer(fh,'ADMIN_EMAIL',admin_email)writeanswer(fh,'ADMIN_PASSWORD',admin_password)writeanswer(fh,'urlbase',bmo_url)mysql_args=['/usr/bin/mysql','-u%s'%db_user,'-p%s'%db_pass,'-h',db_host,'-P',db_port,]fresh_database=bool(subprocess.call(mysql_args+['bugs'],stdin=subprocess.DEVNULL))ifreset_databaseandnotfresh_database:print(subprocess.check_output(mysql_args,input=b'DROP DATABASE bugs;'))fresh_database=True# Component watching throws a fit initializing against a fresh database.# Disable it.withopen(j(b,'extensions','ComponentWatching','disabled'),'a'):passifnotos.path.exists(j(h,'checksetup.done')):cc([j(b,'checksetup.pl',),answers],cwd=b)cc([j(b,'checksetup.pl',),answers],cwd=b)withopen(j(h,'checksetup.done'),'a'):pass# The base URL is dynamic at container start time. Since we don't always run# checksetup.pl (because it adds unacceptable container start overhead), we# hack up the occurrence of this variable in data/params.params_lines=open(j(b,'data','params'),'r').readlines()withopen(j(b,'data','params'),'w')asfh:forlineinparams_lines:if"'urlbase' =>"notinline:fh.write(line)else:fh.write(" 'urlbase' => '"+bmo_url+"',\n")# Ditto for the database host.localconfig_lines=open(j(b,'localconfig'),'r').readlines()withopen(j(b,'localconfig'),'w')asfh:defwrite_variable(k,v):fh.write("$%s = '%s';\n"%(k,v))forlineinlocalconfig_lines:ifline.startswith('$db_user'):write_variable('db_user',db_user)elifline.startswith('$db_pass'):write_variable('db_pass',db_pass)elifline.startswith('$db_host'):write_variable('db_host',db_host)elifline.startswith('$db_port'):write_variable('db_port',db_port)elifline.startswith('$db_name'):write_variable('db_name',db_name)else:fh.write(line)cc(['/bin/chown','-R','bugzilla:bugzilla',b])# If the container is aborted, the apache run file will be present and Apache# will refuse to start.try:os.unlink('/var/run/apache2/apache2.pid')exceptFileNotFoundError:passos.execl(sys.argv[1],*sys.argv[1:])