Skip to content

Commit

Permalink
Add the release_makepkg command and setup linting
Browse files Browse the repository at this point in the history
This is easier/cleaner to do this here than on Buildbot right now.
  • Loading branch information
lopter committed Jul 2, 2016
1 parent 0b394af commit 1ce57da
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 9 deletions.
2 changes: 2 additions & 0 deletions dist/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SET(
package_release
release_new_tag
release_debuild
release_makepkg
)
IF (SPHINX_FOUND)
LIST(APPEND RELEASE_COMMANDS release_docs)
Expand All @@ -42,6 +43,7 @@ ENDIF (SPHINX_FOUND)
SET(
EXTRA_OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/debuild" # release_debuild
"${CMAKE_CURRENT_BINARY_DIR}/makepkg" # release_makepkg
"${CMAKE_CURRENT_BINARY_DIR}/lightsd-${LIGHTSD_VERSION}.tar" # release_new_tag
"${VENV_DIRECTORY}"
"${VENV_STAMP}"
Expand Down
73 changes: 64 additions & 9 deletions dist/release.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ LIGHTSD_PKGS_DIR = "@LIGHTSD_RELEASE_PACKAGES_DIR@"
# where to put the generated archives served at
# https://downloads.lightsd.io/releases/:
LIGHTSD_ARCHIVES_DIR = "@LIGHTSD_RELEASE_ARCHIVES_DIR@"
# where to put generated debian packages
LIGHTSD_DEBS_DIR = "@LIGHTSD_RELEASE_DEBS_DIR@"
# where to put generated packages
LIGHTSD_PKGS_OUT_DIR = "@LIGHTSD_RELEASE_PACKAGES_OUT_DIR@"
# where to manage the documentation served at https://docs.lighsd.io/:
LIGHTSD_DOCS_DIR = "@LIGHTSD_RELEASE_DOCS_DIR@"

Expand Down Expand Up @@ -523,10 +523,11 @@ def release_docs():

@cli.command()
def release_debuild():
if not all([LIGHTSD_DEBS_DIR, LIGHTSD_ARCHIVES_DIR]):
if not all([LIGHTSD_PKGS_OUT_DIR, LIGHTSD_ARCHIVES_DIR]):
error_echo(
"Please configure the project with LIGHTSD_RELEASE_DEBS_DIR "
"and LIGHTSD_RELEASE_ARCHIVES_DIR to use this command."
"Please configure the project with "
"LIGHTSD_RELEASE_PACKAGES_OUT_DIR and "
"LIGHTSD_RELEASE_ARCHIVES_DIR to use this command."
)
sys.exit(1)

Expand All @@ -537,6 +538,7 @@ def release_debuild():
prereq_echo("Cleaning-up previous build in {}".format(debuild_dir))
shutil.rmtree(debuild_dir)
os.makedirs(debuild_dir, exist_ok=True)
os.makedirs(LIGHTSD_PKGS_OUT_DIR, exist_ok=True)
version = latest_released_version()
build_number = extract_build_number(version)
version = semver.format_version(**version)
Expand Down Expand Up @@ -571,16 +573,69 @@ def release_debuild():
dpkg_arch=dpkg_arch,
)
action_echo("Building {}".format(deb_pkg_name))
subprocess.check_call(["debuild", "-us", "-uc"], cwd=src_dir)
subprocess.check_call(
["debuild", "-us", "-uc", "--no-lintian"], cwd=src_dir
)
action_echo("Linting {}".format(deb_pkg_name))
deb_pkg_path = os.path.join(debuild_dir, deb_pkg_name)
subprocess.check_call(["lintian", deb_pkg_path])
shutil.copyfile(
os.path.join(debuild_dir, deb_pkg_name),
os.path.join(LIGHTSD_DEBS_DIR, deb_pkg_name),
deb_pkg_path, os.path.join(LIGHTSD_PKGS_OUT_DIR, deb_pkg_name),
)
click.echo("[+] Copied {} under {}".format(
deb_pkg_name, LIGHTSD_DEBS_DIR
deb_pkg_name, LIGHTSD_PKGS_OUT_DIR
))
result_echo("New Debian package {}".format(deb_pkg_name))


@cli.command()
def release_makepkg():
if not all([LIGHTSD_PKGS_OUT_DIR, LIGHTSD_ARCHIVES_DIR]):
error_echo(
"Please configure the project with "
"LIGHTSD_RELEASE_PACKAGES_OUT_DIR and "
"LIGHTSD_RELEASE_ARCHIVES_DIR to use this command."
)
sys.exit(1)

# This is just too painful to do from buildbot atm (we need to parametrize
# the build with the version):
makepkg_dir = os.path.join(LIGHTSD_BINARY_DIR, "dist", "makepkg")
if os.path.exists(makepkg_dir):
prereq_echo("Cleaning-up previous build in {}".format(makepkg_dir))
shutil.rmtree(makepkg_dir)
os.makedirs(makepkg_dir, exist_ok=True)
os.makedirs(LIGHTSD_PKGS_OUT_DIR, exist_ok=True)
version = latest_released_version()
build_number = extract_build_number(version)
version = semver.format_version(**version)
pkgbuild_src_dir = os.path.join(LIGHTSD_PKGS_DIR, "pkgbuild-lightsd")
for src in ("PKGBUILD", "lightsd.install"):
shutil.copy(os.path.join(pkgbuild_src_dir, src), makepkg_dir)
click.echo("[+] pkgbuild sources copied to {}".format(makepkg_dir))
pkg_arch = subprocess.check_output(["pacman", "-Qi", "pacman"])
pkg_arch = pkg_arch.decode(USER_ENCODING)
pkg_arch, = [
line for line in pkg_arch.split("\n") if line.startswith("Architecture")
]
_, pkg_arch = pkg_arch.split(":")
pkg_arch = pkg_arch.strip()
pkg_name = "lightsd-1:{version}-{build_number}-{arch}.pkg.tar.xz".format(
version=version.replace("-rc", "~rc"),
build_number=build_number,
arch=pkg_arch,
)
action_echo("Building {}".format(pkg_name))
subprocess.check_call(
["makepkg", "--ignorearch", "--force", "--clean", "--cleanbuild"],
cwd=makepkg_dir,
)
pkg_path = os.path.join(makepkg_dir, pkg_name)
action_echo("Linting {}".format(pkg_name))
subprocess.check_call(["namcap", pkg_path])
shutil.copyfile(pkg_path, os.path.join(LIGHTSD_PKGS_OUT_DIR, pkg_name))
click.echo("[+] Copied {} under {}".format(pkg_name, LIGHTSD_PKGS_OUT_DIR))
result_echo("New Arch Linux package {}".format(pkg_name))

if __name__ == "__main__":
cli()

0 comments on commit 1ce57da

Please sign in to comment.