diff options
author | davidovski <david@davidovski.xyz> | 2022-01-16 02:51:39 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-01-16 02:51:39 +0000 |
commit | b52d6d7381320960416b02cf0836527c09529d37 (patch) | |
tree | a353c64357c11888301532f64e1e910d33503a4a | |
parent | 14d93500ff5024aee0d82220ad52f09dede036a2 (diff) |
made changes allowing for meta packages
-rwxr-xr-x | build-repo.sh | 21 | ||||
-rwxr-xr-x | xibuild | 103 |
2 files changed, 75 insertions, 49 deletions
diff --git a/build-repo.sh b/build-repo.sh index a4aeb8c..b6dc93f 100755 --- a/build-repo.sh +++ b/build-repo.sh @@ -17,13 +17,14 @@ build () { for REPO in $(du -h buildfiles/repo/* | awk '{print $2}' | sort -r ); do REPO_NAME=$(echo $REPO | cut -d"/" -f2-) - - REPO_INDEX=dist/$REPO_NAME/index.html - REPO_LIST_OLD=dist/$REPO_NAME/packages.txt - REPO_LIST=dist/$REPO_NAME/packages.list - mkdir -pv dist/$REPO_NAME - mkdir -pv dist/$REPO_NAME/logs - mkdir -pv dist/$REPO_NAME/src + REPO_DIR=$(realpath dist/$REPO_NAME) + + REPO_INDEX=$REPO_DIR/index.html + REPO_LIST_OLD=$REPO_DIR/packages.txt + REPO_LIST=$REPO_DIR/packages.list + mkdir -pv $REPO_DIR + mkdir -pv $REPO_DIR/logs + #mkdir -pv dist/$REPO_NAME/src touch $REPO_INDEX touch $REPO_LIST_OLD touch $REPO_LIST @@ -98,7 +99,7 @@ extend-index () { echo " <tr class='$COLOR'> <td>$PKG_NAME</td> - <td><a href='src/$PKG_NAME.xibuild'>src</a></td> + <td><a href='$PKG_NAME.xibuild'>src</a></td> <td><a href='logs/$PKG_NAME.log'>log</a></td> <td>$DESC</td> <td><a href='$PKG_NAME.xipkg'>$PKG_NAME.xipkg</a></td> @@ -140,8 +141,8 @@ add-additional () { mkdir -pv dist/$REPO_NAME/logs mv logs/* dist/$REPO_NAME/logs - mkdir -p dist/$REPO_NAME/src - mv $REPO/* dist/$REPO_NAME/src/ + #mkdir -p dist/$REPO_NAME/src + #mv $REPO/* dist/$REPO_NAME/src/ # add key for whole repo mkdir dist/keychain @@ -38,21 +38,30 @@ pkgname () { xibuild () { BUILD_FILE=${@: -1} + BUILD_HASH=$(md5sum $BUILD_FILE | cut -f1 -d" ") cd $XI_ROOT [[ $# = 0 ]] && usage && return 1 [ ! -f "$BUILD_FILE" ] && echo "$BUILD_FILE not found" && return 1 + BUILD_FILE_PATH=$(realpath $BUILD_FILE) + clean () { # clean up rm -rf $PKG_BUILD_DIR rmdir $XI_ROOT/tmp > /dev/null 2>&1 } + patch () { + echo "Passing missing patch stage" + } build () { printf "\tpassing missing build stage..." } + check () { + echo "Passing missing check stage" + } package () { echo "Passing missing package stage" } @@ -87,52 +96,62 @@ xibuild () { # fetch, build then package the package ############ - # try get the commit hash for the package - if git ls-remote -q $SOURCE &> /dev/null; then - VER_HASH=$(git ls-remote $SOURCE $BRANCH ) - elif hg identify $SOURCE &> /dev/null; then - VER_HASH=$(hg identify $SOURCE) - else - VER_HASH=$(curl -Ls $SOURCE | md5sum) - fi - - VER_HASH=$(echo $VER_HASH | awk '{ print $1 }') - - # If we already have this package, don't waste our time - if [ -f "$PKG_FILE.info" ] && [ -f "$PKG_FILE" ]; then - EXISTING_HASH=$(grep -a "VER_HASH" $PKG_FILE.info | sed "s/VER_HASH=//") - - echo "Comparing $EXISTING_HASH to $VER_HASH" >> $LOGFILE - - printf "$INFO\tvalidating commit hash..."; - if echo "$EXISTING_HASH" | grep -q "$VER_HASH"; then - printf "$NEUTRAL package exists$RESET\n" - echo "exists $PKG_NAME $DESC" >> $REPORT_LOG - rm $LOGFILE - return; - else - printf "$NEUTRAL package outdated\n" + if [ ! -z ${SOURCE+x} ]; then + # try get the commit hash for the package + if git ls-remote -q $SOURCE &> /dev/null; then + VER_HASH=$(git ls-remote $SOURCE $BRANCH ) + elif hg identify $SOURCE &> /dev/null; then + VER_HASH=$(hg identify $SOURCE) + else + VER_HASH=$(curl -Ls $SOURCE | md5sum) + fi + + VER_HASH=$(echo $VER_HASH | awk '{ print $1 }') + + # If we already have this package, don't waste our time + if [ -f "$PKG_FILE.info" ] && [ -f "$PKG_FILE" ]; then + EXISTING_HASH=$(grep -a "VER_HASH" $PKG_FILE.info | sed "s/VER_HASH=//") + + echo "Comparing $EXISTING_HASH to $VER_HASH" >> $LOGFILE + + printf "$INFO\tvalidating commit hash..."; + + EXISTING_BUILD_HASH=$(md5sum $PKGS_OUTPUT/$PKG_NAME.xibuild | cut -f1 -d" ") + if [ "$EXISTING_HASH" = "$VER_HASH" ] && [ "$EXISTING_BUILD_HASH" = "$BUILD_HASH" ]; then + printf "$NEUTRAL package exists$RESET\n" + echo "exists $PKG_NAME $DESC" >> $REPORT_LOG + rm $LOGFILE + return; + else + printf "$NEUTRAL package outdated\n" + fi fi - fi - - printf "$INFO\tfetching package..."; - if git ls-remote -q $SOURCE $BRANCH &> /dev/null; then - git clone $SOURCE . >> $LOGFILE 2>&1 && printf "$PASS fetched $(du -sh $PKG_BUILD_DIR | awk '{ print $1 }') source\n" || return 1; - git checkout $BRANCH >> $LOGFILE 2>&1 - elif hg identify $SOURCE &> /dev/null; then - hg clone $SOURCE . >> $LOGFILE 2>&1 && printf "$PASS fetched $(du -sh $PKG_BUILD_DIR | awk '{ print $1 }') source\n" || return 1; + printf "$INFO\tfetching package..."; + if git ls-remote -q $SOURCE $BRANCH &> /dev/null; then + git clone $SOURCE . >> $LOGFILE 2>&1 && printf "$PASS fetched $(du -sh $PKG_BUILD_DIR | awk '{ print $1 }') source\n" || return 1; + git checkout $BRANCH >> $LOGFILE 2>&1 + + elif hg identify $SOURCE &> /dev/null; then + hg clone $SOURCE . >> $LOGFILE 2>&1 && printf "$PASS fetched $(du -sh $PKG_BUILD_DIR | awk '{ print $1 }') source\n" || return 1; + else + DOWNLOADED=$(basename $SOURCE) + curl -Ls $SOURCE > $DOWNLOADED + extract $DOWNLOADED >> $LOGFILE 2>&1 && printf "$PASS fetched $(du -sh $PKG_BUILD_DIR | awk '{ print $1 }') source\n" || return 1; + cd $(ls -d */) + fi else - DOWNLOADED=$(basename $SOURCE) - curl -Ls $SOURCE > $DOWNLOADED - extract $DOWNLOADED >> $LOGFILE 2>&1 && printf "$PASS fetched $(du -sh $PKG_BUILD_DIR | awk '{ print $1 }') source\n" || return 1; - cd $(ls -d */) + SOURCE="none" fi + printf "\033[0;34m\tpatching package...\033[0m"; + patch >> $LOGFILE 2>&1 && printf "$PASS patched\n" || return 1; + printf "$INFO\tbuilding package..."; build >> $LOGFILE 2>&1 && printf "$PASS built\n" || return 1; - + printf "\033[0;34m\ttesting package...\033[0m"; + check >> $LOGFILE 2>&1 && printf "$PASS checked\n" || return 1; printf "\033[0;34m\tpackaging package...\033[0m"; package >> $LOGFILE 2>&1 && printf "$PASS packaged\n" || return 1; @@ -151,7 +170,7 @@ xibuild () { # go back to root, make things easier cd $XI_ROOT - if [ -z "$(ls -A $PKG_DEST)" ]; then + if [ -z "$(ls -A $PKG_DEST)" ] && [ ! $SOURCE = "none" ]; then printf "$FAIL!!!Package is empty!!!$RESET\n" return 1; fi @@ -164,6 +183,8 @@ xibuild () { printf "$INFO\tcreating xipkg.info..."; PKG_INFO=$PKGS_OUTPUT/$PKG_NAME.xipkg.info + cp $BUILD_FILE $PKGS_OUTPUT/$PKG_NAME.xibuild + echo "" > $PKG_INFO echo "NAME=$PKG_NAME" >> $PKG_INFO echo "DESCRIPTION=$DESC" >> $PKG_INFO @@ -190,6 +211,10 @@ xibuild () { printf "$PASS successfully built $PKG_NAME to $(basename $PKG_FILE)$RESET\n" clean + + unset SOURCE DESC DEPS install package check + + echo "new $PKG_NAME $DESC" >> $REPORT_LOG return 0 } |