Add distclean to remove old build files

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2018-07-09 16:19:17 -04:00
parent cb1b88c4f8
commit d9545a5909
1 changed files with 33 additions and 0 deletions

View File

@ -4,6 +4,7 @@ from __future__ import unicode_literals
import argparse
import os
import shutil
import sys
import time
from distutils.core import run_setup
@ -130,8 +131,37 @@ def print_final_instructions(args):
)
def distclean():
print('Running distclean...')
dirs = [
os.path.join(REPO_ROOT, 'build'), os.path.join(REPO_ROOT, 'dist'),
os.path.join(REPO_ROOT, 'docker-compose.egg-info')
]
files = []
for base, dirnames, fnames in os.walk(REPO_ROOT):
for fname in fnames:
path = os.path.normpath(os.path.join(base, fname))
if fname.endswith('.pyc'):
files.append(path)
elif fname.startswith('.coverage.'):
files.append(path)
for dirname in dirnames:
path = os.path.normpath(os.path.join(base, dirname))
if dirname == '__pycache__':
dirs.append(path)
elif dirname == '.coverage-binfiles':
dirs.append(path)
for file in files:
os.unlink(file)
for folder in dirs:
shutil.rmtree(folder, ignore_errors=True)
def resume(args):
try:
distclean()
repository = Repository(REPO_ROOT, args.repo)
br_name = branch_name(args.release)
if not repository.branch_exists(br_name):
@ -183,6 +213,7 @@ def cancel(args):
bintray_api = BintrayAPI(os.environ['BINTRAY_TOKEN'], args.bintray_user)
print('Removing Bintray data repository for {}'.format(args.release))
bintray_api.delete_repository(args.bintray_org, branch_name(args.release))
distclean()
except ScriptError as e:
print(e)
return 1
@ -191,6 +222,7 @@ def cancel(args):
def start(args):
distclean()
try:
repository = Repository(REPO_ROOT, args.repo)
create_initial_branch(repository, args)
@ -213,6 +245,7 @@ def start(args):
def finalize(args):
distclean()
try:
repository = Repository(REPO_ROOT, args.repo)
img_manager = ImageManager(args.release)