Skip to content

Commit

Permalink
modified: .conf/VERSIONID
Browse files Browse the repository at this point in the history
	modified:   scripts/bash/build/build.github.bash
	modified:   scripts/bash/build/build.github.topics.bash
	deleted:    scripts/bash/ushlibs.bash
	modified:   sha512.sum
  • Loading branch information
SDRausty committed Nov 3, 2019
1 parent bae74ff commit c19b26d
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 176 deletions.
2 changes: 1 addition & 1 deletion .conf/VERSIONID
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.4.108
4.5.0
156 changes: 101 additions & 55 deletions scripts/bash/build/build.github.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ set -Eeuo pipefail
shopt -s nullglob globstar
export RDR="$HOME/buildAPKs"
. "$RDR"/scripts/bash/init/ushlibs.bash
. "$RDR"/scripts/bash/shlibs/trap.bash 67 68 69
. "$RDR"/scripts/bash/shlibs/trap.bash 67 68 69 "${0##*/}"

_AND_ () { # write configuration file for git repository tarball if AndroidManifest.xml file is found in git repositoryr.
_AND_ () { # writes configuration file for git repository tarball if AndroidManifest.xml file is found in git repositoryr
export CK=0
printf "%s\\n" "$COMMIT" > "$JDR/.conf/$USER.${NAME##*/}.${COMMIT::7}.ck"
printf "%s\\n" "0" >> "$JDR/.conf/$USER.${NAME##*/}.${COMMIT::7}.ck"
Expand Down Expand Up @@ -75,7 +75,7 @@ _CKAT_ () {
if [[ $CKFILE = "" ]] # configuration file is not found
then
printf "%s" "Checking $USENAME $REPO for last commit: "
COMMIT="$(_GC_)" || _SIGNAL_ "60" "_CKAT_ COMMIT"
COMMIT="$(_GC_)" ||:
printf "%s\\n" "Found ${COMMIT::7}; Continuing..."
_ATT_
else # load configuration information from file
Expand All @@ -88,18 +88,75 @@ _CKAT_ () {
done
}

_CUTE_ () { # check whether username is an organization
. "$RDR"/scripts/bash/shlibs/lock.bash
. "$RDR"/scripts/bash/shlibs/buildAPKs/bnchn.bash bch.st
mapfile -t TYPE < <(curl "https://api.github.com/users/$USER")
if [[ "${TYPE[@]}" == *Organization* ]]
then
export ISUSER=users
export ISOTUR=orgs
else
_CUTE_ () { # checks if USENAME is found in GNAMES and if it is an organization or a user
if [[ $(grep -iw "$USENAME" "$RDR/var/db/GNAMES" | awk '{print $2}') == User ]] && [[ -f "$RDR/sources/github/users/$USER/profile" ]] && [[ -f "$RDR/sources/github/users/$USER/repos" ]]
then
export ISUSER=users
export ISOTUR=users
export USENAME="$(grep -iw "$USENAME" "$RDR/var/db/GNAMES" | awk '{print $1}')"
export JDR="$RDR/sources/github/$ISOTUR/$USER"
export JID="git.$ISOTUR.$USER"
elif [[ $(grep -iw "$USENAME" "$RDR/var/db/GNAMES" | awk '{print $2}') == Organization ]] && [[ -f "$RDR/sources/github/orgs/$USER/profile" ]] && [[ -f "$RDR/sources/github/orgs/$USER/repos" ]]
then
export ISUSER=users
export ISOTUR=orgs
export USENAME="$(grep -iw "$USENAME" "$RDR/var/db/GNAMES" | awk '{print $1}')"
export JDR="$RDR/sources/github/$ISOTUR/$USER"
export JID="git.$ISOTUR.$USER"
else # get USENAME and type of USENAME from GitHub
mapfile -t TYPE < <(curl "https://api.github.com/users/$USENAME")
if [[ "${TYPE[1]}" == *\"message\":\ \"Not\ Found\"* ]]
then
printf "\\n%s\\n\\n" "Could not find a GitHub login with $USENAME: Exiting..."
exit 44
fi
if [[ -z "${TYPE[17]}" ]]
then
_SIGNAL_ "404" "${TYPE[17]} undefined!"
exit 34
fi
USENAME="$(printf "%s" "${TYPE[1]}" | sed 's/"//g' | sed 's/,//g' | awk '{print $2}')" || _SIGNAL_ "73" "_CUTE_ \$USENAME"
NAPKS="$(printf "%s" "${TYPE[17]}" | sed 's/"//g' | sed 's/,//g' | awk '{print $2}')" || (_SIGNAL_ "74" "_CUTE_ \$NAPKS: create \$NAPKS failed; Exiting..." && exit 24)
if [[ "${TYPE[17]}" == *User* ]]
then
export ISUSER=users
export ISOTUR=users
else
export ISUSER=users
export ISOTUR=orgs
fi
export JDR="$RDR/sources/github/$ISOTUR/$USER"
export JID="git.$ISOTUR.$USER"
if [[ ! -d "$JDR" ]]
then
mkdir -p "$JDR"
fi
printf "%s\\n" "${TYPE[@]}" > "$JDR"/profile
_NAMESMAINBLOCK_ GNAMES
fi
if [[ ! -d "$JDR/.conf" ]]
then
mkdir -p "$JDR/.conf"
printf "%s\\n\\n" "This directory contains results from query for \` AndroidManifest.xml \` files in GitHub $USENAME repositores. " > "$JDR/.conf/README.md"
fi
printf "%s\\n" "Processing $USENAME:"
KEYT=("\"login\"" "\"id\"" "\"type\"" "\"name\"" "\"company\"" "\"blog\"" "\"location\"" "\"hireable\"" "\"bio\"" "\"public_repos\"" "\"public_gists\"" "\"followers\"" "\"following\"" "\"created_at\"" )
for KEYS in "${KEYT[@]}" # print selected information from profile file
do
grep "$KEYS" "$JDR/profile" | sed 's/\,//g' | sed 's/\"//g'
done
if [[ ! -f "$JDR/repos" ]]
then
printf "%s\\n" "Downloading GitHub $USENAME repositories information: "
if [[ "$OAUT" != "" ]] # see $RDR/.conf/GAUTH file for information
then
curl -u "$OAUT" "https://api.github.com/$ISUSER/$USER/repos" > "$JDR/repos"
else
curl "https://api.github.com/$ISUSER/$USER/repos" > "$JDR/repos"
fi
fi
_WAKELOCK_
. "$RDR"/scripts/bash/shlibs/buildAPKs/bnchn.bash bch.st
}

_FJDX_ () {
Expand All @@ -110,18 +167,22 @@ _FJDX_ () {
_GC_ () {
if [[ "$OAUT" != "" ]] # see $RDR/.conf/GAUTH file for information
then # https://unix.stackexchange.com/questions/117992/download-only-first-few-bytes-of-a-source-page
curl -u "$OAUT" https://api.github.com/repos/"$USER/$REPO"/commits -s 2>&1 | head -n 3 | tail -n 1 | awk '{ print $2 }' | sed 's/"//g' | sed 's/,//g'
curl -u "$OAUT" -r 0-1 https://api.github.com/repos/"$USER/$REPO"/commits -s 2>&1 | head -n 3 | tail -n 1 | awk '{ print $2 }' | sed 's/"//g' | sed 's/,//g'
else
curl -r 0-1 https://api.github.com/repos/"$USER/$REPO"/commits -s 2>&1 | head -n 3 | tail -n 1 | awk '{ print $2 }' | sed 's/"//g' | sed 's/,//g'
fi
}

_NAND_ () { # write configuration file for repository if AndroidManifest.xml file is NOT found in git repository.
_NAND_ () { # writed configuration file for repository if AndroidManifest.xml file is NOT found in git repository
printf "%s\\n" "$COMMIT" > "$JDR/.conf/$USER.${NAME##*/}.${COMMIT::7}.ck"
printf "%s\\n" "1" >> "$JDR/.conf/$USER.${NAME##*/}.${COMMIT::7}.ck"
printf "\\n%s\\n\\n" "Could not find an AndroidManifest.xml file in Java language repository $USER ${NAME##*/} ${COMMIT::7}: NOT downloading ${NAME##*/} tarball."
}

_PRINTAS_ () {
printf "\\n\\e[1;34mSearching for AndroidManifest.xml files:\\e[0m\\n"'\033]2;Searching for AndroidManifest.xml files: OK\007'
}

_PRINTCK_ () {
if [[ "$CK" = 1 ]]
then
Expand All @@ -131,17 +192,17 @@ _PRINTCK_ () {
fi
}

_PRINTJD_() {
_PRINTJD_ () {
printf "\\e[1;32mDONE\\e[0m\\n"
}

_PRINTJS_() {
_PRINTJS_ () {
printf "\\n\\e[1;34mSearching for Java language repositories: "'\033]2;Searching for Java language repositories: OK\007'
}

_SIGNAL_ () {
STRING="SIGNAL $1 found in $2 ${0##*/}!"
printf "\\e[2;2;38;5;208m%s\\e[0m\\n\\n" "$STRING"
STRING="SIGNAL $1 found in $2 ${0##*/} build.github.bash! Continuing... "
printf "\\e[2;7;38;5;210m%s\\e[0m" "$STRING"
}

if [[ -z "${1:-}" ]]
Expand All @@ -158,64 +219,49 @@ export USENAME="${UONE##*/}"
export USER="${USENAME,,}"
export OAUT="$(cat "$RDR/.conf/GAUTH" | awk 'NR==1')" # loads login:token key from GAUTH file
printf "\\n\\e[1;38;5;116m%s\\n\\e[0m" "${0##*/}: Beginning BuildAPKs with build.github.bash $1:"
. "$RDR/scripts/bash/shlibs/buildAPKs/fandm.bash"
. "$RDR/scripts/bash/shlibs/buildAPKs/prep.bash"
. "$RDR/scripts/sh/shlibs/buildAPKs/fapks.sh"
. "$RDR/scripts/sh/shlibs/buildAPKs/names.sh"
. "$RDR"/scripts/bash/shlibs/buildAPKs/fandm.bash
. "$RDR"/scripts/bash/shlibs/buildAPKs/prep.bash
. "$RDR"/scripts/sh/shlibs/buildAPKs/fapks.sh
. "$RDR"/scripts/sh/shlibs/buildAPKs/names.sh
. "$RDR"/scripts/sh/shlibs/mkfiles.sh
. "$RDR"/scripts/sh/shlibs/mkdirs.sh
_MKDIRS_ "cache/stash" "cache/tarballs" "db" "db/log" "log/signal"
_MKFILES_ "db/CNAMES" "db/ENAMES" "db/GNAMES" "db/QNAMES" "db/RNAMES" "db/ZNAMES"
if grep -iw "$USENAME" "$RDR"/var/db/[PZ]NAMES
then # create null directory, repos file and exit
# $USENAME is in the pending or zero lists
then # create null directory and repos file, and exit
if grep -iw "$USENAME" "$RDR"/var/db/ONAMES
then
JDR="$RDR/sources/github/orgs/$USER"
else
JDR="$RDR/sources/github/users/$USER"
fi
mkdir -p "$JDR"
touch "$JDR"/repos
printf "\\e[7;38;5;208mUsername %s is found in %s: See preceeding output. Not processing username %s! Remove the username from the corresponding file(s) and the user's build directory in %s to proccess %s. File %s has more information:\\n\\n\\e[0m" "$USENAME" "~/${RDR##*/}/var/db/[PZ]NAMES" "$USENAME" "~/${RDR##*/}/sources/github/{orgs,users}" "$USENAME" "~/${RDR##*/}/var/db/README.md"
mkdir -p "$JDR" # create null directory
touch "$JDR"/repos # create null repos file
printf "\\e[7;38;5;208mUsername %s is found in %s: See preceeding output. Not processing username %s! Remove the username from the corresponding file(s) and the user's build directory in %s to process %s. Then run \` %s \` again to attempt to build %s's APK projects, if any. File %s has more information:\\n\\n\\e[0m" "$USENAME" "~/${RDR##*/}/var/db/[PZ]NAMES" "$USENAME" "~/${RDR##*/}/sources/github/{orgs,users}" "$USENAME" "${0##*/} $USENAME" "$USENAME" "~/${RDR##*/}/var/db/README.md"
cat "$RDR/var/db/README.md" | grep -v \<\!
printf "\\e[7;38;5;208m\\nUsername %s is found in %s: Not processing username %s! Remove the username from the corresponding file(s) and the user's build directory in %s to proccess %s. Then run %s again to build %s. Scroll up to read the %s file.\\e[0m\\n" "$USENAME" "~/${RDR##*/}/var/db/[PZ]NAMES" "$USENAME" "~/${RDR##*/}/sources/github/{orgs,users}" "$USENAME" "${0##*/}" "$USENAME" "~/${RDR##*/}/var/db/README.md"
exit 4
else # check whether login is a user or an organization.
printf "\\e[7;38;5;208m\\nUsername %s is found in %s: Not processing username %s! Remove the username from the corresponding file(s) and the user's build directory in %s to process %s. Then run \` %s \` again to attempt to build %s's APK projects, if any. Scroll up to read the %s file.\\e[0m\\n" "$USENAME" "~/${RDR##*/}/var/db/[PZ]NAMES" "$USENAME" "~/${RDR##*/}/sources/github/{orgs,users}" "$USENAME" "${0##*/} $USENAME" "$USENAME" "~/${RDR##*/}/var/db/README.md"
exit 0 # and exit
else # check whether login is a user or an organization
_CUTE_
fi
export JDR="$RDR/sources/github/$ISOTUR/$USER"
export JID="git.$ISOTUR.$USER"
if [[ ! -d "$JDR" ]]
then
mkdir -p "$JDR"
fi
if [[ ! -d "$JDR/.conf" ]]
then
mkdir -p "$JDR/.conf"
printf "%s\\n\\n" "This directory contains results from query for \` AndroidManifest.xml \` files in GitHub $USENAME repositores. " > "$JDR/.conf/README.md"
fi
cd "$JDR"
printf "%s" "${TYPE[@]}" > profile
if [[ ! -f "repos" ]]
then
printf "%s\\n" "Downloading GitHub $USENAME repositories information: "
if [[ "$OAUT" != "" ]] # see $RDR/.conf/GAUTH file for information
then
curl -u "$OAUT" "https://api.github.com/$ISUSER/$USER/repos" > repos
else
curl "https://api.github.com/$ISUSER/$USER/repos" > repos
fi
fi
_PRINTJS_
JARR=($(grep -v JavaScript repos | grep -B 5 Java | grep svn_url | awk -v x=2 '{print $x}' | sed 's/\,//g' | sed 's/\"//g')) # creates array of Java language repositories
JARR=($(grep -v JavaScript "$JDR/repos" | grep -B 5 Java | grep svn_url | awk -v x=2 '{print $x}' | sed 's/\,//g' | sed 's/\"//g')) # creates array of Java language repositories
_PRINTJD_
if [[ "${JARR[@]}" == *ERROR* ]]
then
_SIGNAL_ "404" "search for Java language repository"
_SIGNAL_ "404" "search for Java language repositories"
_NAMESMAINBLOCK_ CNAMES ZNAMES
exit 0
fi
F1AR=($(find . -maxdepth 1 -type d)) # creates array of $JDR contents
F1AR=($(find "$JDR" -maxdepth 1 -type d)) # creates array of $JDR contents
cd "$JDR"
_PRINTAS_
for NAME in "${JARR[@]}" # lets you delete partial downloads and repopulates from GitHub. Directories can be deleted, too. They are repopulated from the tarballs.
do # This creates a "slate" within each github/$JDR that can be selectively reset when desired. This can be important on a slow connection.
_CKAT_
done
_PRINTJD_
_ANDB_
_APKBC_
. "$RDR"/scripts/bash/shlibs/buildAPKs/bnchn.bash bch.gt
Expand Down
64 changes: 11 additions & 53 deletions scripts/bash/build/build.github.topics.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,88 +4,46 @@
#####################################################################
set -Eeuo pipefail
shopt -s nullglob globstar

_SGTRPERROR_() { # run on script error
local RV="$?"
printf "\\e[?25h\\e[1;7;38;5;0mbuildAPKs %s ERROR: Signal %s received!\\e[0m\\n" "${0##*/}" "$RV"
exit 201
}

_SGTRPEXIT_() { # run on exit
printf "\\e[?25h\\e[0m"
set +Eeuo pipefail
exit 0
}

_SGTRPSIGNAL_() { # run on signal
local RV="$?"
printf "\\e[?25h\\e[1;7;38;5;0mbuildAPKs %s WARNING: Signal %s received!\\e[0m\\n" "${0##*/}" "$RV"
exit 211
}

_SGTRPQUIT_() { # run on quit
local RV="$?"
printf "\\e[?25h\\e[1;7;38;5;0mbuildAPKs %s WARNING: Quit signal %s received!\\e[0m\\n" "${0##*/}" "$RV"
exit 221
}

trap '_SGTRPERROR_ $LINENO $BASH_COMMAND $?' ERR
trap _SGTRPEXIT_ EXIT
trap _SGTRPSIGNAL_ HUP INT TERM
trap _SGTRPQUIT_ QUIT

export RDR="$HOME/buildAPKs"
. "$RDR"/scripts/bash/init/ushlibs.bash
. "$RDR"/scripts/bash/shlibs/trap.bash 77 78 79 "${0##*/}"
if [[ -z "${1:-}" ]]
then
printf "\\e[1;7;38;5;203m%s\\e[1;7;38;5;201m%s\\e[1;7;38;5;203m%s\\e[1;7;38;5;201m%s\\e[1;7;38;5;203m%s\\e[1;7;38;5;201m%s\\e[1;7;38;5;203m%s\\n\\e[0m\\n" "GitHub topic name must be provided; See " "~/${RDR##*/}/var/conf/TNAMES" " for topic names that build APKs on device with BuildAPKs! To build all the topic names contained in this file run " "for NAME in \$(cat ~/${RDR##*/}/var/conf/TNAMES) ; do ~/${RDR##*/}/scripts/bash/build/${0##*/} \$NAME ; done" ". File " "~/${RDR##*/}/var/conf/GAUTH" " has important information should you choose to run this command regarding bandwidth supplied by GitHub. "
exit 227
exit 4
fi
if [[ -z "${NUM:-}" ]]
then
export NUM="$(date +%s)"
fi
. "$RDR"/scripts/bash/init/ushlibs.bash
. "$RDR"/scripts/bash/shlibs/lock.bash wake.start
. "$RDR"/scripts/bash/shlibs/buildAPKs/bnchn.bash bch.st
export NUM="$(date +%s)"
export TOPI="${1%/}"
export TOPIC="${TOPI##*/}"
export TOPNAME="${TOPIC,,}"
export JDR="$RDR/sources/github/topics/$TOPIC"
export JID="git.$TOPIC"
export OAUT="$(cat "$RDR/var/conf/GAUTH" | awk 'NR==1')"
export OAUT="$(cat "$RDR/.conf/GAUTH" | awk 'NR==1')"
export RDR="$HOME/buildAPKs"
export STRING="ERROR FOUND; build.github.topics.bash $1: CONTINUING... "
printf "\\n\\e[1;38;5;116m%s\\n\\e[0m" "${0##*/}: Beginning BuildAPKs with build.github.topics.bash $1:"
if [[ ! -d "$JDR" ]]
then
mkdir -p "$JDR"
fi
cd "$JDR"
if [[ ! -d "$JDR/.config" ]]
then
mkdir -p "$JDR/.config"
printf "%s\\n\\n" "This directory contains results from query for \`AndroidManifest.xml\` files in GitHub $TOPNAME repositores. " > "$JDR/.config/README.md"
fi
if [[ ! -f "repos" ]]
if [[ ! -f "$JDR"/topic ]]
then
printf "%s\\n" "Downloading GitHub $TOPNAME repositories information: "
printf "%s\\n" "Downloading GitHub $TOPNAME topic repositories information:"
if [[ "$OAUT" != "" ]] # see $RDR/var/conf/GAUTH file for information
then
curl -u "$OAUT" -H "Accept: application/vnd.github.mercy-preview+json" "https://api.github.com/search/repositories?q=topic:$TOPIC+language:Java" -o repos
curl -u "$OAUT" -H "Accept: application/vnd.github.mercy-preview+json" "https://api.github.com/search/repositories?q=topic:$TOPIC+language:Java" -o "$JDR"/topic
else
curl -H "Accept: application/vnd.github.mercy-preview+json" "https://api.github.com/search/repositories?q=topic:$TOPIC+language:Java" -o repos
curl -H "Accept: application/vnd.github.mercy-preview+json" "https://api.github.com/search/repositories?q=topic:$TOPIC+language:Java" -o "$JDR"/topic
fi
fi
TARR=($(grep -v JavaScript repos | grep -B 5 Java | grep svn_url | awk -v x=2 '{print $x}' | sed 's/\,//g' | sed 's/\"//g' | sed 's/https\:\/\/github.com\///g' | cut -d\/ -f1)) # creates array of Java language repositories
TARR=($(grep -v JavaScript "$JDR"/topic | grep -B 5 Java | grep svn_url | awk -v x=2 '{print $x}' | sed 's/\,//g' | sed 's/\"//g' | sed 's/https\:\/\/github.com\///g' | cut -d\/ -f1)) # creates array of Java language repositories for topic
for NAME in "${TARR[@]}"
do
read TYPE < <(curl "https://api.github.com/users/$NAME/repos" -s 2>&1 | head -n 25 | tail -n 1 | grep -o Organization) # https://stackoverflow.com/questions/2559076/how-do-i-redirect-output-to-a-variable-in-shell/
if [[ "$TYPE" == Organization ]]
then
"$RDR"/scripts/bash/components/build.github.orgs.bash "$NAME"
else
"$RDR"/scripts/bash/components/build.github.users.bash "$NAME"
fi
"$RDR"/scripts/bash/build/build.github.bash "$NAME"
done
. "$RDR"/scripts/bash/shlibs/lock.bash wake.stop
. "$RDR"/scripts/bash/shlibs/buildAPKs/bnchn.bash bch.gt
Expand Down
Loading

0 comments on commit c19b26d

Please sign in to comment.