add basic scripts

This commit is contained in:
idk
2023-06-30 15:10:59 -04:00
parent 6a63eaeefe
commit ffc3bc9488
3 changed files with 432 additions and 92 deletions

View File

@ -1,92 +1,2 @@
# I2P Development Environment Managing Stuff
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://i2pgit.org/i2p-hackers/i2p.devscripts.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](http://i2pgit.org/i2p-hackers/i2p.devscripts/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
I2P Development Environment
===========================

35
config.sh Normal file
View File

@ -0,0 +1,35 @@
I2P_VERSION="2.3.0"
I2P_PUBLISHED_VERSION="0.9.59"
I2P_REPOSITORY=https://i2pgit.org/i2p-hackers/i2p.i2p
I2P_REPOSITORY_DIR="i2p.i2p"
I2P_NEWS=https://i2pgit.org/i2p-hackers/i2p.newsxml
I2P_NEWS_DIR="i2p.newsxml"
I2P_WWW=https://i2pgit.org/i2p-hackers/i2p.www
I2P_WWW_DIR="i2p.www"
I2P_FIREFOX=https://i2pgit.org/i2p-hackers/i2p.firefox
I2P_FIREFOX_DIR="i2p.firefox"
I2P_ANDROID=https://i2pgit.org/i2p-hackers/i2p.android.base
I2P_ANDROID_DIR="i2p.android.base"
I2P_PLUGIN_FIREFOX="https://i2pgit.org/idk/i2p.plugins.firefox"
I2P_PLUGIN_FIREFOX_DIR="i2p.plugins.firefox"
OPENJDK_7_URL="https://github.com/eyedeekay/openjdk-7"
OPENJDK_7_DIR="$HOME/.i2p/eepsite/docroot/openjdk-7"
JAVA_COMPILER_ARGS="-bootclasspath $OPENJDK_7_DIR/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar:$OPENJDK_7_DIR/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jce.jar"
JAVA8_COMPILER_ARGS="-bootclasspath /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jce.jar"
JAVA_BUILT_BY="idk"
JUNIT_HOME="/usr/share/java"
HAMCREST_HOME="/usr/share/java"
MOCKITO_HOME="/usr/share/java"
IZPACK5_HOME="$HOME/IzPack"
PRIVKEY_SU3="$HOME/.i2p-plugin-keys/news-su3-keystore.ks"
PRIVKEY_SU3_ID="70D2060738BEF80523ACAFF7D75C03B39B5E14E1"
SIGNER_PRIVKEY_SU3="hankhill19580@gmail.com"

395
env.sh Executable file
View File

@ -0,0 +1,395 @@
#! /usr/bin/env sh
. ./config.sh
WORK_HOME="$(pwd)"
sourced=0
if [ -n "$ZSH_VERSION" ]; then
case $ZSH_EVAL_CONTEXT in *:file) sourced=1;; esac
elif [ -n "$KSH_VERSION" ]; then
[ "$(cd -- "$(dirname -- "$0")" && pwd -P)/$(basename -- "$0")" != "$(cd -- "$(dirname -- "${.sh.file}")" && pwd -P)/$(basename -- "${.sh.file}")" ] && sourced=1
elif [ -n "$BASH_VERSION" ]; then
(return 0 2>/dev/null) && sourced=1
else # All other shells: examine $0 for known shell binary filenames.
# Detects `sh` and `dash`; add additional shell filenames as needed.
case ${0##*/} in sh|-sh|dash|-dash) sourced=1;; esac
fi
home() {
cd "$WORK_HOME"
}
setup_ant() {
if [ ! -f "$HOME/.ant/lib/maven-ant-tasks-2.1.3.jar" ]; then
mkdir -p "$HOME/.ant/lib/"
wget -O "$HOME/.ant/lib/maven-ant-tasks-2.1.3.jar" "https://archive.apache.org/dist/maven/ant-tasks/2.1.3/binaries/maven-ant-tasks-2.1.3.jar"
fi
}
setup_build_deps() {
DPKG_TEST=$(dpkg -l libc6 | grep "libc6:i386")
if [ -z "$DPKG_TEST" ]; then
sudo apt-get build-dep i2p
sudo dpkg --add-architecture i386
sudo apt-get install libc6:i386 po4a reprepro
fi
}
setup_python() {
# check if python is installed on the path:
PYTHON=$(which python)
if [ -z "$PYTHON" ]; then
PYTHON3=$(which python3)
if [ -z "$PYTHON3" ]; then
sudo ln -s /usr/bin/python3 /usr/bin/python
else
sudo apt-get install python3-minimal
setup_python
fi
fi
}
clone() {
if [ ! -d "$CLONE_DIR" ]; then
git clone --depth=1 "$CLONE" "$CLONE_DIR" && cd "$CLONE_DIR" && git fetch --unshallow
pwd
else
echo "Initial repository clone error: repository already exists and will be updated in the next step"
fi
home
}
update() {
if [ -d "$CLONE_DIR" ]; then
# get the name of the branch we're on and store it in CLONE_BRANCH
cd "$CLONE_DIR"
CLONE_BRANCH="$(git branch --show-current)"
git stash
# get the name of the default branch and store it in CLONE_DEFAULT_BRANCH
CLONE_DEFAULT_BRANCH="$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')"
echo git checkout "$CLONE_DEFAULT_BRANCH"
echo git pull origin "$CLONE_DEFAULT_BRANCH"
git pull --tags
git pull --all
echo git checkout "$CLONE_BRANCH"
echo git stash pop
pwd
else
echo "Repository update error, unknown repository"
fi
home
}
clone_i2p() {
CLONE="$I2P_REPOSITORY"
CLONE_DIR="$I2P_REPOSITORY_DIR"
clone
update
home
}
clone_www() {
CLONE="$I2P_WWW"
CLONE_DIR="$I2P_WWW_DIR"
clone
update
home
}
clone_news() {
CLONE="$I2P_NEWS"
CLONE_DIR="$I2P_NEWS_DIR"
clone
update
home
}
clone_android() {
CLONE="$I2P_ANDROID"
CLONE_DIR="$I2P_ANDROID_DIR"
clone
update
home
}
clone_firefox() {
CLONE="$I2P_FIREFOX"
CLONE_DIR="$I2P_FIREFOX_DIR"
clone
update
home
}
clone_plugin_firefox() {
CLONE="$I2P_PLUGIN_FIREFOX"
CLONE_DIR="$I2P_PLUGIN_FIREFOX_DIR"
clone
update
home
}
clone_openjdk() {
CLONE="$OPENJDK_7_URL"
CLONE_DIR="$OPENJDK_7_DIR"
clone
update
home
}
configure_i2p_build_maven() {
cd "$I2P_REPOSITORY_DIR"
echo "Configure i2p build"
setup_ant
echo javac.compilerargs="$JAVA_COMPILER_ARGS" | tee override.properties
echo build.built-by="$JAVA_BUILT_BY" | tee -a override.properties
echo junit.home="$JUNIT_HOME" | tee -a override.properties
echo hamcrest.home="$HAMCREST_HOME" | tee -a override.properties
echo mockito.home="$MOCKITO_HOME" | tee -a override.properties
echo izpack5.home="$IZPACK5_HOME" | tee -a override.properties
echo release.privkey.su3="$PRIVKEY_SU3" | tee -a override.properties
echo release.gpg.keyid="$PRIVKEY_SU3_ID" | tee -a override.properties
echo release.signer.su3="$SIGNER_PRIVKEY_SU3" | tee -a override.properties
home
}
configure_i2p_build() {
cd "$I2P_REPOSITORY_DIR"
echo "Configure i2p build"
echo javac.compilerargs="$JAVA8_COMPILER_ARGS" | tee override.properties
echo build.built-by="$JAVA_BUILT_BY" | tee -a override.properties
echo junit.home="$JUNIT_HOME" | tee -a override.properties
echo hamcrest.home="$HAMCREST_HOME" | tee -a override.properties
echo mockito.home="$MOCKITO_HOME" | tee -a override.properties
echo izpack5.home="$IZPACK5_HOME" | tee -a override.properties
echo release.privkey.su3="$PRIVKEY_SU3" | tee -a override.properties
echo release.gpg.keyid="$PRIVKEY_SU3_ID" | tee -a override.properties
echo release.signer.su3="$SIGNER_PRIVKEY_SU3" | tee -a override.properties
home
}
checkout_latest_tag() {
cd "$CLONE_DIR"
# get the name of the latest tag published to the repo by date and store it in LATEST_TAG
LATEST_TAG="$(git describe --tags --abbrev=0)"
git checkout "$LATEST_TAG"
home
}
checkout_latest_i2p_tag() {
CLONE_DIR="$I2P_REPOSITORY_DIR"
checkout_latest_tag
home
}
checkout_main() {
cd "$CLONE_DIR"
CLONE_DEFAULT_BRANCH="$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')"
echo git checkout "$CLONE_DEFAULT_BRANCH"
git checkout "$CLONE_DEFAULT_BRANCH"
home
}
checkout_i2p_main() {
CLONE_DIR="$I2P_REPOSITORY_DIR"
checkout_main
home
}
clean_i2p() {
cd "$I2P_REPOSITORY_DIR"
ant clean
home
}
compile_i2p() {
configure_i2p_build
cd "$I2P_REPOSITORY_DIR"
ant releaseRepack
home
}
build_i2p() {
cd "$I2P_REPOSITORY_DIR"
compile_i2p
home
}
compile_i2p_maven() {
configure_i2p_build_maven
cd "$I2P_REPOSITORY_DIR"
ant mavenCentral
home
}
build_i2p_mavencentral() {
cd "$I2P_REPOSITORY_DIR"
compile_i2p_maven
home
}
open_checklist() {
xdg-open "$I2P_REPOSITORY_DIR/installer/resources/checklist.md" || \
x-terminal-emulator -geometry 120x484+0+0 -e bash -c 'less ./i2p.i2p/installer/resources/checklist.md'
}
clone_all() {
clone_i2p
clone_news
clone_openjdk
clone_www
clone_firefox
clone_plugin_firefox
clone_android
}
build() {
checkout_latest_i2p_tag
build_i2p
build_i2p_mavencentral
checkout_i2p_main
}
update_install_xml() {
cd "$I2P_REPOSITORY_DIR"
OLD_VERSION=$(grep '<appversion>' "installer/install.xml")
NEW_VERSION=" <appversion>$I2P_VERSION</appversion>"
sed -i "s|$OLD_VERSION|$NEW_VERSION|g" "installer/install.xml"
home
}
update_install5_xml() {
cd "$I2P_REPOSITORY_DIR"
OLD_VERSION=$(grep '<appversion>' "installer/install5.xml")
NEW_VERSION=" <appversion>$I2P_VERSION</appversion>"
sed -i "s|$OLD_VERSION|$NEW_VERSION|g" "installer/install5.xml"
home
}
update_coreversion() {
cd "$I2P_REPOSITORY_DIR"
OLD_VERSION=$(grep 'public final static String VERSION' core/java/src/net/i2p/CoreVersion.java)
NEW_VERSION=" public final static String VERSION = \"$I2P_VERSION\";"
sed -i "s/$OLD_VERSION/$NEW_VERSION/g" 'core/java/src/net/i2p/CoreVersion.java'
OLD_VERSION=$(grep 'public final static String PUBLISHED_VERSION' core/java/src/net/i2p/CoreVersion.java)
NEW_VERSION=" public final static String PUBLISHED_VERSION = \"$I2P_PUBLISHED_VERSION\";"
sed -i "s/$OLD_VERSION/$NEW_VERSION/g" 'core/java/src/net/i2p/CoreVersion.java'
home
}
update_routerversion() {
cd "$I2P_REPOSITORY_DIR"
OLD_VERSION=$(grep 'public final static long BUILD' router/java/src/net/i2p/router/RouterVersion.java)
NEW_VERSION=" public final static long BUILD = 0;"
sed -i "s/$OLD_VERSION/$NEW_VERSION/g" 'router/java/src/net/i2p/router/RouterVersion.java'
OLD_VERSION=$(grep 'public final static String EXTRA' router/java/src/net/i2p/router/RouterVersion.java)
NEW_VERSION=" public final static String EXTRA = \"\";"
sed -i "s/$OLD_VERSION/$NEW_VERSION/g" 'router/java/src/net/i2p/router/RouterVersion.java'
home
}
upload_router_artifacts() {
GITHUB_RELEASE=$(which github-release)
if [ -z "$GITHUB_RELEASE" ]; then
echo "github-release is not installed, uploading router artifacts disabled"
return
fi
github_release
UPLOAD_FILE=i2pinstall_"$I2P_VERSION"-0.jar
github_upload
UPLOAD_FILE=i2pinstall_"$I2P_VERSION"-0_windows.exe
github_upload
UPLOAD_FILE=i2pinstall_"$I2P_VERSION".jar
github_upload
UPLOAD_FILE=i2pinstall_"$I2P_VERSION".jar.sig
github_upload
UPLOAD_FILE=i2pinstall_"$I2P_VERSION"_windows.exe
github_upload
UPLOAD_FILE=i2psource_"$I2P_VERSION".tar.bz2
github_upload
UPLOAD_FILE=i2psource_"$I2P_VERSION".tar.bz2.sig
github_upload
UPLOAD_FILE=i2pupdate-"$I2P_VERSION".su3
github_upload
UPLOAD_FILE=i2pupdate-"$I2P_VERSION".su3.torrent
github_upload
UPLOAD_FILE=i2pupdate.su3
github_upload
UPLOAD_FILE=i2pupdate.zip
github_upload
UPLOAD_FILE=i2pupdate_"$I2P_VERSION".zip
github_upload
UPLOAD_FILE=i2pupdate_"$I2P_VERSION".zip.sig
github_upload
}
github_release() {
#TODO: find only the first <article></article> section in i2p.newsxml/data/entries.html and obtain the text from it, store it in the variable NEWS_ARTICLE using sed
NEWS_ARTICLE=$(sed -n '/<article/,/<\/article/p' i2p.newsxml/data/entries.html)
FIRST_NEWS_ARTICLE=$(echo "$NEWS_ARTICLE" | sed -n '1,/<\/article>/p')
SUMMARY=$(echo "$FIRST_NEWS_ARTICLE" | grep "<summary>" | sed 's/<summary>//g' | sed 's/<\/summary>//g')
FINAL_NEWS_ARTICLE=$(echo "$FIRST_NEWS_ARTICLE" | sed -n '/<\/details>/,$p' | sed '1d')
PUBLISHABLE_NEWS_ARTICLE=$(echo "$FINAL_NEWS_ARTICLE" | sed 's/<\/\{0,1\}p>//g')
github-release release \
--user i2p \
--repo i2p.i2p \
--tag i2p-"$I2P_VERSION" \
--name "$SUMMARY" \
--description "$PUBLISHABLE_NEWS_ARTICLE" 2> /dev/null
}
github_upload() {
ls "$I2P_REPOSITORY_DIR/$UPLOAD_FILE"
SHASUM=$(sha256sum "$I2P_REPOSITORY_DIR/$UPLOAD_FILE")
HASH_VALUE=$(echo "$SHASUM" | awk '{print $1}')
echo "$HASH_VALUE"
github-release upload \
--user i2p \
--repo i2p.i2p \
--label "$UPLOAD_FILE - $HASH_VALUE" \
--tag i2p-"$I2P_VERSION" \
--name "$UPLOAD_FILE" \
--replace \
--file "$I2P_REPOSITORY_DIR/$UPLOAD_FILE"
}
normalize_release() {
update_install_xml
update_install5_xml
update_coreversion
update_routerversion
home
}
ensure_history() {
cd "$I2P_REPOSITORY_DIR"
grep "$I2P_VERSION" "history.txt" | grep -i i2p || return
home
}
git_tag() {
cd "$I2P_REPOSITORY_DIR"
git checkout i2p-"$I2P_VERSION" && return
home
ensure_history
update_install_xml
update_install5_xml
update_coreversion
update_routerversion
cd "$I2P_REPOSITORY_DIR"
git tag i2p-"$I2P_VERSION"
home
}
# - `history.txt`
run_all() {
open_checklist
clone_all
clean_i2p
build
clone_all
}
[ $sourced -eq 0 ] && run_all