-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More Python3-compatibility changes, add back the config directory + o…
…ther changes.
- Loading branch information
Showing
241 changed files
with
610 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
components/ | ||
templates/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include version.ini | ||
recursive-include components *.bin | ||
recursive-include templates *.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<html><head><title>Simple Index</title><meta name="api-version" value="2" /></head><body> | ||
<a href='grr-response-templates-3.1.0.tar.gz#md5=71525271a5fdbf0c72580ce56194d8a9'>grr-response-templates-3.1.0</a><br/> | ||
<a href="grr-response-templates-3.1.0post1.tar.gz#md5=93703b0a2c8fb385706970708af0b24b">grr-response-templates-3.1.0post1</a><br/> | ||
</body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#!/usr/bin/env python | ||
"""This package contains GRR client templates.""" | ||
from __future__ import print_function | ||
import ConfigParser | ||
import glob | ||
import os | ||
import re | ||
import shutil | ||
from setuptools import setup | ||
from setuptools.command.sdist import sdist | ||
|
||
THIS_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
# If you run setup.py from the root GRR dir you get very different results since | ||
# setuptools uses the MANIFEST.in from the root dir. Make sure we are in the | ||
# package dir. | ||
os.chdir(THIS_DIRECTORY) | ||
|
||
|
||
def get_config(): | ||
"""Get INI parser with version.ini data.""" | ||
ini_path = os.path.join(THIS_DIRECTORY, "version.ini") | ||
if not os.path.exists(ini_path): | ||
ini_path = os.path.join(THIS_DIRECTORY, "../../../version.ini") | ||
if not os.path.exists(ini_path): | ||
raise RuntimeError("Couldn't find version.ini") | ||
|
||
config = ConfigParser.SafeConfigParser() | ||
config.read(ini_path) | ||
return config | ||
|
||
|
||
VERSION = get_config() | ||
|
||
|
||
class Sdist(sdist): | ||
"""Make a sdist release.""" | ||
|
||
REQUIRED_TEMPLATES = [ | ||
"GRR_maj.minor_amd64.exe.zip", | ||
"GRR_maj.minor_i386.exe.zip", | ||
"grr_maj.minor_amd64.deb.zip", | ||
"grr_maj.minor_amd64.xar.zip", | ||
"grr_maj.minor_amd64.rpm.zip", | ||
"grr_maj.minor_i386.deb.zip", | ||
"grr_maj.minor_i386.rpm.zip", | ||
] | ||
|
||
def CheckTemplates(self, base_dir, version): | ||
"""Verify we have at least one template that matches maj.minor version.""" | ||
major_minor = ".".join(version.split(".")[0:2]) | ||
templates = glob.glob( | ||
os.path.join(base_dir, "templates/*%s*.zip" % major_minor)) | ||
required_templates = set( | ||
[x.replace("maj.minor", major_minor) for x in self.REQUIRED_TEMPLATES]) | ||
|
||
# Client templates have an extra version digit, e.g. 3.1.0.0 | ||
templates_present = set([ | ||
re.sub(r"_%s[^_]+_" % major_minor, "_%s_" % major_minor, | ||
os.path.basename(x)) for x in templates | ||
]) | ||
|
||
difference = required_templates - templates_present | ||
if difference: | ||
raise RuntimeError("Missing templates %s" % difference) | ||
|
||
def run(self): | ||
base_dir = os.getcwd() | ||
self.CheckTemplates(base_dir, setup_args["version"]) | ||
sdist.run(self) | ||
print("To upload a release, run upload.sh [version]") | ||
|
||
def make_release_tree(self, base_dir, files): | ||
sdist.make_release_tree(self, base_dir, files) | ||
sdist_version_ini = os.path.join(base_dir, "version.ini") | ||
if os.path.exists(sdist_version_ini): | ||
os.unlink(sdist_version_ini) | ||
shutil.copy( | ||
os.path.join(THIS_DIRECTORY, "../../../version.ini"), sdist_version_ini) | ||
|
||
|
||
def find_data_files(source, prefix=None): | ||
result = [] | ||
for directory, _, files in os.walk(source): | ||
files = [os.path.join(directory, x) for x in files] | ||
if prefix: | ||
result.append((os.path.join(prefix, directory), files)) | ||
else: | ||
result.append((directory, files)) | ||
|
||
return result | ||
|
||
|
||
if "VIRTUAL_ENV" not in os.environ: | ||
print("*****************************************************") | ||
print(" WARNING: You are not installing in a virtual") | ||
print(" environment. This configuration is not supported!!!") | ||
print(" Expect breakage.") | ||
print("*****************************************************") | ||
|
||
setup_args = dict( | ||
name="grr-response-templates", | ||
version=VERSION.get("Version", "packageversion"), | ||
description="GRR Rapid Response client templates", | ||
long_description=("This PyPi package is just a placeholder. The package" | ||
" itself is too large to distribute on PyPi so it is " | ||
"available from google cloud storage. See" | ||
" https://github.com/google/grr-doc/blob/master/" | ||
"installfrompip.adoc for installation instructions."), | ||
license="Apache License, Version 2.0", | ||
url="https://github.com/google/grr", | ||
data_files=(find_data_files("templates", prefix="grr-response-templates") + | ||
["version.ini"]), | ||
cmdclass={ | ||
"sdist": Sdist, | ||
}) | ||
|
||
setup(**setup_args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
# Helper script to release client templates. | ||
|
||
# Upload to the test bucket: | ||
# ./upload.sh 3.1.0 grr-releases-testing | ||
|
||
# Upload a release: | ||
# ./upload.sh 3.1.0 | ||
|
||
set -e | ||
|
||
VERSION=$1 | ||
RELEASE_NAME="grr-response-templates-${VERSION}" | ||
RELEASE_TAR="${RELEASE_NAME}.tar.gz" | ||
RELEASE_FILE="dist/${RELEASE_TAR}" | ||
if [[ $# -eq 1 ]] ; then | ||
BUCKET="releases.grr-response.com" | ||
else | ||
BUCKET=$2 | ||
fi | ||
|
||
md5fingerprint=$(md5sum "${RELEASE_FILE}" | cut -d" " -f1) | ||
|
||
# Upload tarball, make public | ||
gsutil cp "${RELEASE_FILE}" "gs://${BUCKET}/" | ||
gsutil acl ch -u AllUsers:R "gs://${BUCKET}/${RELEASE_TAR}" | ||
|
||
sed -i -e "s!</body></html>!<a href=\"${RELEASE_TAR}#md5=${md5fingerprint}\">${RELEASE_NAME}</a><br/>\n</body></html>!" index.html | ||
|
||
gsutil cp index.html "gs://${BUCKET}/" | ||
gsutil acl ch -u AllUsers:R "gs://${BUCKET}/index.html" | ||
|
||
echo "Test install with:" | ||
echo "pip install --no-cache-dir -f https://storage.googleapis.com/${BUCKET}/index.html grr-response-templates==${VERSION}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
grr/server/grr_response_server/bin/api_shell_raw_access_lib_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/usr/bin/env python | ||
from __future__ import unicode_literals | ||
|
||
import io | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
grr/server/grr_response_server/bin/config_updater_util_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/usr/bin/env python | ||
from __future__ import unicode_literals | ||
|
||
import getpass | ||
|
||
import builtins | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.