summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/buildSwaggerClient.sh37
-rwxr-xr-xscripts/build_deps.sh6
-rwxr-xr-xscripts/cleanProject.sh17
-rw-r--r--[-rwxr-xr-x]scripts/fetch-play-metadata.py200
-rwxr-xr-xscripts/prepareForScreenshots.sh2
-rwxr-xr-xscripts/prepareForTests.sh2
-rwxr-xr-xscripts/pullTranslations.py8
7 files changed, 153 insertions, 119 deletions
diff --git a/scripts/buildSwaggerClient.sh b/scripts/buildSwaggerClient.sh
new file mode 100755
index 00000000..3afe6fb9
--- /dev/null
+++ b/scripts/buildSwaggerClient.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+SWAGGER_MENSHEN_COMMIT=da64a69b26b4ca4eaa3ed865df7c01216a07cc54
+SCRIPT_DIR=$(dirname "$0")
+BASE_DIR="$SCRIPT_DIR/.."
+
+GREEN='\033[0;32m'
+NC='\033[0m'
+
+echo -e "${GREEN}Creating swagger build directory${NC}"
+mkdir -p ${BASE_DIR}/app/build/swagger
+
+echo -e "${GREEN}Fetching swagger specification for menshen commit ${SWAGGER_MENSHEN_COMMIT}${NC}"
+if [[ -z $MENSHEN_SWAGGER_YAML ]]; then
+ curl https://0xacab.org/leap/menshen/-/raw/${SWAGGER_MENSHEN_COMMIT}/api/swagger.yaml > ${BASE_DIR}/app/build/swagger/swagger.yaml
+else
+ cp $MENSHEN_SWAGGER_YAML ${BASE_DIR}/app/build/swagger/swagger.yaml
+fi
+
+echo -e "${GREEN}Pulling swagger-codegen docker image${NC}"
+docker pull swaggerapi/swagger-codegen-cli
+cd $BASE_DIR
+
+echo -e "${GREEN}Running swagger-codegen-cli in docker${NC}"
+docker run --rm --user $(id -u):$(id -g) -v ${PWD}:/bitmask_android swaggerapi/swagger-codegen-cli generate \
+ -i /bitmask_android/app/build/swagger/swagger.yaml \
+ -l java \
+ -o /bitmask_android/app/build/swagger \
+ -DuseAndroidMavenGradlePlugin=true \
+ -DhideGenerationTimestamp=true
+
+echo -e "${GREEN}Copying generated model classes${NC}"
+cp -r app/build/swagger/src/main/java/io/swagger/client/model/* app/src/main/java/io/swagger/client/model/.
+cp app/build/swagger/src/main/java/io/swagger/client/JSON.java app/src/main/java/io/swagger/client/.
+
+echo -e "${GREEN}Cleanup${NC}"
+rm -r app/build/swagger/
diff --git a/scripts/build_deps.sh b/scripts/build_deps.sh
index 51cc926d..dd75ccae 100755
--- a/scripts/build_deps.sh
+++ b/scripts/build_deps.sh
@@ -9,7 +9,7 @@ SCRIPT_DIR=$(dirname "$0")
BASE_DIR="$SCRIPT_DIR/.."
DIR_OVPNASSETS=./ics-openvpn/main/build/ovpnassets
DIR_OVPNLIBS=./ics-openvpn/main/build/intermediates/cmake/skeletonRelease/obj
-DIR_GOLIBS=./bitmaskcore/lib/
+DIR_GOLIBS=./bitmask-core-android/lib/
#FILE_X86=./go/out/x86/piedispatcherlib
#FILE_ARM=./go/out/armeabi-v7a/piedispatcherlib
DIR_TORLIBS=./tor-android/external/lib
@@ -82,12 +82,12 @@ then
echo "Dirty build: Reusing go libraries"
else
echo "Clean build: compiling Go libraries"
- cd ./bitmaskcore || quit "Directory go not found"
+ cd ./bitmask-core-android || quit "Directory go not found"
if [[ ! -d lib ]]
then
mkdir lib
fi
- ./build_core.sh || quit "failed to build bitmaskcore"
+ ./build_core.sh || quit "Failed to build Bitmask Core Android"
cp lib/bitmaskcore.aar ../lib-bitmask-core/.
cp lib/bitmaskcore-sources.jar ../lib-bitmask-core/.
cp lib/bitmaskcore_web.aar ../lib-bitmask-core-web/.
diff --git a/scripts/cleanProject.sh b/scripts/cleanProject.sh
index 49e2db44..0a354b66 100755
--- a/scripts/cleanProject.sh
+++ b/scripts/cleanProject.sh
@@ -11,15 +11,16 @@ git submodule foreach --recursive git clean -xfd
rm -r $BASE_DIR/ics-openvpn
rm -r $BASE_DIR/build
rm -r $BASE_DIR/app/build
-rm -r $BASE_DIR/bitmaskcore/lib/*
-rm -r $BASE_DIR/bitmaskcore/golang/
+rm -r $BASE_DIR/bitmask-core-android/lib/*
+rm -r $BASE_DIR/bitmask-core-android/golang/
rm -r $BASE_DIR/currentReleases
-rm -r $BASE_DIR/tor-android/build
-rm -r $BASE_DIR/tor-android/tor-android-binary/build
-rm -r $BASE_DIR/tor-android/external/bin
-rm -r $BASE_DIR/tor-android/external/include/
-rm -r $BASE_DIR/tor-android/external/*.build-stamp
-rm -r $BASE_DIR/tor-android/external/lib
+#rm -r $BASE_DIR/tor-android/build
+#rm -r $BASE_DIR/tor-android/tor-android-binary/build
+#rm -r $BASE_DIR/tor-android/external/bin
+#rm -r $BASE_DIR/tor-android/external/include/
+#rm -r $BASE_DIR/tor-android/external/*.build-stamp
+#rm -r $BASE_DIR/tor-android/external/lib
+rm -r $BASE_DIR/tor-android
git reset --hard
git submodule foreach --recursive git reset --hard HEAD
git submodule sync --recursive
diff --git a/scripts/fetch-play-metadata.py b/scripts/fetch-play-metadata.py
index 7c65b648..e94f4c73 100755..100644
--- a/scripts/fetch-play-metadata.py
+++ b/scripts/fetch-play-metadata.py
@@ -4,141 +4,137 @@ import json
from googleapiclient.discovery import build
from google.oauth2 import service_account
-# Load API key from environment variable
-api_key = os.environ.get('GOOGLE_PLAY_API_KEY')
-
-# Load command-line arguments
+# Command-line arguments
parser = argparse.ArgumentParser(description='Fetch app details from Google Play Store.')
parser.add_argument('package_name', help='Package name of the app')
-parser.add_argument('--source-language', action='store_true', help='Fetch app description in source language')
+parser.add_argument('--language', default=None, help='Specify the language to fetch details (default: None, fetch all supported languages)')
parser.add_argument('--list-languages', action='store_true', help='List all supported languages')
-parser.add_argument('--extract-details', action='store_true', help='Extract and save app details as JSON')
+parser.add_argument('--extract-details', action='store_true', help='Extract app details')
parser.add_argument('--extract-changelog', action='store_true', help='Extract and save changelog as JSON')
+parser.add_argument('--save', action='store_true', help='Save the fetched details to the correct location')
+parser.add_argument('--commit', action='store_true', help='Commit changes to the Play Store')
args = parser.parse_args()
+# Get the credentials file path from an environment variable
+credentials_path = os.environ.get('GOOGLE_PLAY_CREDENTIALS', None)
+if not credentials_path:
+ raise ValueError("Environment variable 'GOOGLE_PLAY_CREDENTIALS' is not set.")
+
# Create a service account credentials object
credentials = service_account.Credentials.from_service_account_file(
- '/home/kwadronaut/dev/leap/secrets/android-api.json',
+ credentials_path,
scopes=['https://www.googleapis.com/auth/androidpublisher']
)
-
-# Build the service object for the Google Play Developer API
service = build('androidpublisher', 'v3', credentials=credentials, cache_discovery=False)
+# Base path for Fastlane metadata
+def get_metadata_path(package_name):
+ if package_name == "se.leap.bitmaskclient":
+ return 'src/normalProductionFat/fastlane/metadata/android'
+ elif package_name == "se.leap.riseupvpn":
+ return 'src/customProductionFat/fastlane/metadata/android'
+ else:
+ raise ValueError(f"Unknown package name: {package_name}")
+
# Fetch app details
def fetch_app_details(package_name, language):
- # Create a new edit
- edit_request = service.edits().insert(body={}, packageName=package_name)
- edit_response = edit_request.execute()
- edit_id = edit_response['id']
-
- # Fetch the app listing for the specified language within the edit
- app_details = service.edits().listings().get(
- packageName=package_name,
- editId=edit_id,
- language=language
- ).execute()
+ try:
+ # Create a new edit
+ edit_request = service.edits().insert(body={}, packageName=package_name)
+ edit_response = edit_request.execute()
+ edit_id = edit_response['id']
- # Commit the edit (optional)
- service.edits().commit(
- packageName=package_name,
- editId=edit_id
- ).execute()
+ # Fetch the app listing for the specified language
+ app_details = service.edits().listings().get(
+ packageName=package_name,
+ editId=edit_id,
+ language=language
+ ).execute()
+
+ # Commit the edit if the --commit flag is provided
+ if args.commit:
+ service.edits().commit(
+ packageName=package_name,
+ editId=edit_id,
+ changesNotSentForReview=True
+ ).execute()
+
+ return app_details
+ except Exception as e:
+ print(f"Error fetching app details: {str(e)}")
+ return None
- return app_details, edit_id
+# Save app details in Fastlane structure
+def save_app_details(app_details, package_name, language):
+ try:
+ # Determine the correct metadata path based on the package name
+ metadata_path = get_metadata_path(package_name)
+ lang_dir = os.path.join(metadata_path, language)
+ os.makedirs(lang_dir, exist_ok=True)
-# Fetch changelog for a specific version
-def fetch_changelog(package_name, edit_id):
- # Fetch the tracks for the package
- tracks = service.edits().tracks().list(packageName=package_name, editId=edit_id).execute()
- track = tracks['tracks'][0]['track']
+ # Save `title`, `short_description`, and `full_description` as text files
+ with open(os.path.join(lang_dir, 'title.txt'), 'w', encoding='utf-8') as title_file:
+ title_file.write(app_details.get('title', ''))
- # Fetch the changelog for the track
- changelog = service.edits().tracks().get(packageName=package_name, editId=edit_id, track=track).execute()
+ with open(os.path.join(lang_dir, 'short_description.txt'), 'w', encoding='utf-8') as short_file:
+ short_file.write(app_details.get('shortDescription', ''))
- return changelog
+ with open(os.path.join(lang_dir, 'full_description.txt'), 'w', encoding='utf-8') as full_file:
+ full_file.write(app_details.get('fullDescription', ''))
-# Package name
-package_name = args.package_name
+ print(f"App details saved successfully in {lang_dir}")
+ except Exception as e:
+ print(f"Error saving app details: {str(e)}")
-# Fetch app details
-try:
- #app_details, edit_id = fetch_app_details(package_name, 'en-US')
- app_details, edit_id = fetch_app_details(package_name, 'nl-NL')
- print("App Details:")
- print(app_details)
-except Exception as e:
- print("An error occurred:", str(e))
-
-# List all supported languages
-if args.list_languages:
+# List langs in the store
+def list_supported_languages(package_name):
try:
# Create a new edit
edit_request = service.edits().insert(body={}, packageName=package_name)
edit_response = edit_request.execute()
edit_id = edit_response['id']
- # Fetch the app listings for the edit
+ # Fetch the app listings
listings = service.edits().listings().list(packageName=package_name, editId=edit_id).execute()
supported_languages = [listing['language'] for listing in listings['listings']]
print("Supported Languages:")
for language in supported_languages:
print(language)
- # Commit the edit
- service.edits().commit(packageName=package_name, editId=edit_id).execute()
- except Exception as e:
- print("An error occurred:", str(e))
+ # Commit the edit if the --commit flag is provided
+ if args.commit:
+ service.edits().commit(
+ packageName=package_name,
+ editId=edit_id,
+ changesNotSentForReview=True
+ ).execute()
-# Extract and save app details as JSON
-if args.extract_details:
- try:
- # Extract the text fields from app details
- title = app_details['title']
- full_description = app_details['fullDescription']
- short_description = app_details['shortDescription']
-
- # Create a dictionary to hold the extracted app details
- extracted_details = {
- 'title': title,
- 'full_description': full_description,
- 'short_description': short_description
- }
-
- # Determine the output file path based on the language
- language = 'en-US' # Update with the desired language
- json_file_path = f"locale/{language}/transifex.json"
-
- # Create the output directory if it doesn't exist
- os.makedirs(os.path.dirname(json_file_path), exist_ok=True)
-
- # Save the extracted details as JSON
- with open(json_file_path, 'w', encoding='utf-8') as json_file:
- json.dump(extracted_details, json_file, ensure_ascii=False, indent=4)
-
- print(f"App details extracted and saved to {json_file_path} as JSON successfully.")
+ return supported_languages
except Exception as e:
- print("An error occurred:", str(e))
-
-# Extract and save changelog as JSON
-if args.extract_changelog:
- try:
- changelog = fetch_changelog(package_name, edit_id)
- print("Changelog:")
- print(changelog)
-
- # Determine the output file path based on the language
- language = 'en-US' # Update with the desired language
- json_file_path = f"locale/{language}/transifex.json"
-
- # Create the output directory if it doesn't exist
- os.makedirs(os.path.dirname(json_file_path), exist_ok=True)
-
- # Save the changelog as JSON
- with open(json_file_path, 'w', encoding='utf-8') as json_file:
- json.dump(changelog, json_file, ensure_ascii=False, indent=4)
-
- print(f"Changelog extracted and saved to {json_file_path} as JSON successfully.")
- except Exception as e:
- print("An error occurred:", str(e))
+ print(f"Error listing languages: {str(e)}")
+ return []
+# Main script logic
+if args.list_languages:
+ list_supported_languages(args.package_name)
+elif args.extract_details:
+ if args.save:
+ # Fetch and save details for all supported languages
+ supported_languages = list_supported_languages(args.package_name)
+ for language in supported_languages:
+ app_details = fetch_app_details(args.package_name, language)
+ if app_details:
+ save_app_details(app_details, args.package_name, language)
+ elif args.language:
+ # Fetch and save details for a specific language
+ app_details = fetch_app_details(args.package_name, args.language)
+ if app_details:
+ if args.save:
+ save_app_details(app_details, args.package_name, args.language)
+ else:
+ print("Fetched app details (not saved):")
+ print(json.dumps(app_details, indent=4))
+ else:
+ print("Please specify a language with --language or use --list-languages to list supported languages.")
+else:
+ print("No valid action specified. Use --list-languages, --extract-details, or --extract-changelog.")
diff --git a/scripts/prepareForScreenshots.sh b/scripts/prepareForScreenshots.sh
index 0b38cfae..eba6f6a1 100755
--- a/scripts/prepareForScreenshots.sh
+++ b/scripts/prepareForScreenshots.sh
@@ -18,7 +18,7 @@
SCRIPT_DIR=$(dirname "$0")
BASE_DIR="$SCRIPT_DIR/.."
-rm -r $BASE_DIR/bitmaskcore/lib/*
+rm -r $BASE_DIR/bitmask-core-android/lib/*
git checkout -- \*
git checkout -- \.\*
diff --git a/scripts/prepareForTests.sh b/scripts/prepareForTests.sh
index d10a04b7..0a5ce709 100755
--- a/scripts/prepareForTests.sh
+++ b/scripts/prepareForTests.sh
@@ -20,7 +20,7 @@ BASE_DIR="$SCRIPT_DIR/.."
git checkout -- \*
git checkout -- \.\*
-rm -r $BASE_DIR/bitmaskcore/lib/*
+rm -r $BASE_DIR/bitmask-core-android/lib/*
git submodule foreach --recursive git reset --hard HEAD
git submodule sync --recursive
git submodule update --init --recursive
diff --git a/scripts/pullTranslations.py b/scripts/pullTranslations.py
index edfd5718..e688862a 100755
--- a/scripts/pullTranslations.py
+++ b/scripts/pullTranslations.py
@@ -46,9 +46,9 @@ def list_locales(app_type):
# If there's no file, tx will skip the translations
def create_metadata_files(locales, app_type):
if app_type == "main":
- metadata_dir = get_script_path() + "/../src/normal/fastlane/metadata/android"
+ metadata_dir = get_script_path() + "/../src/normalProductionFat/fastlane/metadata/android"
elif app_type == "custom":
- metadata_dir = get_script_path() + "/../src/custom/fastlane/metadata/android"
+ metadata_dir = get_script_path() + "/../src/customProductionFat/fastlane/metadata/android"
else:
raise ValueError("Invalid app type. Use 'main' or 'custom'.")
for locale_code in locales:
@@ -138,9 +138,9 @@ if __name__ == "__main__":
args = parser.parse_args()
if args.app_type == "main":
- metadata_dir = get_script_path() + "/../src/normal/fastlane/metadata/android"
+ metadata_dir = get_script_path() + "/../src/normalProductionFat/fastlane/metadata/android"
elif args.app_type == "custom":
- metadata_dir = get_script_path() + "/../src/custom/fastlane/metadata/android"
+ metadata_dir = get_script_path() + "/../src/customProductionFat/fastlane/metadata/android"
else:
raise ValueError("Invalid app type. Use 'main' or 'custom'.")