From b5d8f7895aa24bdb8f12825c0652a568beda96aa Mon Sep 17 00:00:00 2001 From: Wouter R Date: Wed, 16 Oct 2013 17:32:43 +0200 Subject: [PATCH] Rework feed creation scripts: they now support uploading to doodle3d.com (with corresponding changes to opkg.conf) and they are more location independent. --- extra/scripts/create-packages-feed-dir.sh | 55 ------------ extra/scripts/create-wifibox-updates-dir.sh | 91 ++++++++++++++++++++ extra/scripts/recreate-Sites-packagedir.sh | 8 -- extra/scripts/release-wifibox-updates-dir.sh | 48 +++++++++++ src/opkg.conf | 4 +- 5 files changed, 141 insertions(+), 65 deletions(-) delete mode 100755 extra/scripts/create-packages-feed-dir.sh create mode 100755 extra/scripts/create-wifibox-updates-dir.sh delete mode 100755 extra/scripts/recreate-Sites-packagedir.sh create mode 100755 extra/scripts/release-wifibox-updates-dir.sh diff --git a/extra/scripts/create-packages-feed-dir.sh b/extra/scripts/create-packages-feed-dir.sh deleted file mode 100755 index 8dabeaa..0000000 --- a/extra/scripts/create-packages-feed-dir.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -OPENWRT_BASE=/Volumes/openwrt-image-10gb/openwrt -PKG_SRC_DIR=$OPENWRT_BASE/bin/ar71xx/packages -PKG_DEST_DIR=wifibox-packages -MAKE_INDEX_SCRIPT=$OPENWRT_BASE/scripts/ipkg-make-index.sh -INDEX_FILE=Packages -INDEX_GZ_FILE=Packages.gz - -if [ "x$1" == "x-h" ]; then - echo "This script creates a directory with wifibox and ultifi ipk files found in the openWrt build environment. The feed dir is called $PKG_DEST_DIR and will be created in the current directory. (currently `pwd`)" - echo "If specified, the -z option also compresses the result for easier transfer to a webserver." - exit -fi - -if [ ! -d $PKG_DEST_DIR ]; then mkdir $PKG_DEST_DIR; fi -cp $PKG_SRC_DIR/wifibox*.ipk $PKG_DEST_DIR -cp $PKG_SRC_DIR/ultifi*.ipk $PKG_DEST_DIR -cp $PKG_SRC_DIR/print3d*.ipk $PKG_DEST_DIR -cd $PKG_DEST_DIR -rm -f $INDEX_FILE -rm -f $INDEX_GZ_FILE - - -# NOTE: the aliasing construct in the indexing script does not work (and even then, the md5 command defaults to a different output format), so we hack around it here. -MD5_HACK_ENABLED=0 -which md5sum >/dev/null 2>&1 -if [ $? -eq 1 ]; then - MD5_HACK_ENABLED=1 - TEMPBIN_DIR=/tmp/tempbin23QQDBR - mkdir $TEMPBIN_DIR - - cat < $TEMPBIN_DIR/md5sum -`type -p md5` -q \$1 -EOF - - chmod +x $TEMPBIN_DIR/md5sum - PATH=$PATH:$TEMPBIN_DIR -fi - -$MAKE_INDEX_SCRIPT . > $INDEX_FILE - -if [ $MD5_HACK_ENABLED -eq 1 ]; then - rm $TEMPBIN_DIR/md5sum - rmdir $TEMPBIN_DIR -fi - - -gzip -c $INDEX_FILE > $INDEX_GZ_FILE - -if [ "x$1" == "x-z" ]; then - cd .. - echo "Compressing generated package directory..." - tar czvf $PKG_DEST_DIR.tgz $PKG_DEST_DIR -fi diff --git a/extra/scripts/create-wifibox-updates-dir.sh b/extra/scripts/create-wifibox-updates-dir.sh new file mode 100755 index 0000000..78fe10c --- /dev/null +++ b/extra/scripts/create-wifibox-updates-dir.sh @@ -0,0 +1,91 @@ +#!/bin/sh + +OPENWRT_BASE=. +PKG_SRC_DIR=$OPENWRT_BASE/bin/ar71xx/packages +PKG_DEST_SUBPATH=updates +MAKE_INDEX_SCRIPT=$OPENWRT_BASE/scripts/ipkg-make-index.sh +INDEX_FILE=Packages +INDEX_GZ_FILE=Packages.gz + +COMPRESS_RESULT=0 +PKG_DEST_BASE=. + +for arg in "$@"; do + case $arg in + -h) + echo "This script creates a directory with wifibox and ultifi ipk files found in the openWrt build environment." + echo "The feed dir is called $PKG_DEST_DIR and will be created in the current directory. (currently `pwd`)" + echo "If specified, the -z option also compresses the result for easier transfer to a webserver." + exit + ;; + -z) + COMPRESS_RESULT=1 + ;; + -*) + echo "Unrecognized option '$arg'" + exit 1 + ;; + *) + PKG_DEST_BASE=$arg + ;; + esac +done + +grep "^This is the buildsystem for the OpenWrt Linux distribution\.$" README >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "Please run this script from the Openwrt build root (on OSX this is probably an image mounted under /Volumes)." + exit 1 +fi + +#setup paths +PKG_DEST_DIR=$PKG_DEST_BASE/$PKG_DEST_SUBPATH +PKG_FEED_DIR=$PKG_DEST_DIR/feed +PKG_IMG_DIR=$PKG_DEST_DIR/images +if [ ! -d $PKG_DEST_DIR ]; then mkdir -p $PKG_DEST_DIR; fi +echo "Using $PKG_DEST_DIR as target directory" + + +#clear directory and copy package files +if [ ! -d $PKG_FEED_DIR ]; then mkdir $PKG_FEED_DIR; fi +cp $PKG_SRC_DIR/wifibox*.ipk $PKG_FEED_DIR +cp $PKG_SRC_DIR/ultifi*.ipk $PKG_FEED_DIR +cp $PKG_SRC_DIR/print3d*.ipk $PKG_FEED_DIR +rm -f $PKG_FEED_DIR/$INDEX_FILE +rm -f $PKG_FEED_DIR/$INDEX_GZ_FILE + + +# NOTE: the aliasing construct in the indexing script does not work (and even then, the md5 command defaults to a different output format), so we hack around it here. +MD5_HACK_ENABLED=0 +which md5sum >/dev/null 2>&1 +if [ $? -eq 1 ]; then + MD5_HACK_ENABLED=1 + TEMPBIN_DIR=/tmp/tempbin23QQDBR + mkdir $TEMPBIN_DIR + + cat < $TEMPBIN_DIR/md5sum +`type -p md5` -q \$1 +EOF + + chmod +x $TEMPBIN_DIR/md5sum + PATH=$PATH:$TEMPBIN_DIR +fi + +#this cwd juggling is required to have the package indexer generate correct paths (i.e. no paths) in the Packages file +OPENWRT_DIR=`pwd` +pushd $PKG_FEED_DIR +$OPENWRT_DIR/$MAKE_INDEX_SCRIPT . > $PKG_FEED_DIR/$INDEX_FILE +popd + +if [ $MD5_HACK_ENABLED -eq 1 ]; then + rm $TEMPBIN_DIR/md5sum + rmdir $TEMPBIN_DIR +fi + +gzip -c $PKG_FEED_DIR/$INDEX_FILE > $PKG_FEED_DIR/$INDEX_GZ_FILE + + +if [ $COMPRESS_RESULT -eq 1 ]; then + cd $PKG_DEST_BASE + echo "Compressing generated package directory..." + tar czvf "doodle3d-wifibox-update-dist.tgz" $PKG_DEST_SUBPATH +fi diff --git a/extra/scripts/recreate-Sites-packagedir.sh b/extra/scripts/recreate-Sites-packagedir.sh deleted file mode 100755 index b131763..0000000 --- a/extra/scripts/recreate-Sites-packagedir.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -# This script is merely for conveniently generating the packages feed directory in ~/Sites (e.g. for use with XAMPP or the like). Modify WIFIBOX_BASE_DIR to point to your wifibox directory tree. - -WIFIBOX_BASE_DIR=~/Files/_devel/eclipse-workspace/wifibox - -cd ~/Sites -$WIFIBOX_BASE_DIR/extra/scripts/create-packages-feed-dir.sh diff --git a/extra/scripts/release-wifibox-updates-dir.sh b/extra/scripts/release-wifibox-updates-dir.sh new file mode 100755 index 0000000..f3891f3 --- /dev/null +++ b/extra/scripts/release-wifibox-updates-dir.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# This script copies the packages feed & images directory to ~/Sites (e.g. for use with XAMPP or the like). +# Using the -u option, it can also upload to doodle3d.com/updates (make sure ssh automatically uses the correct username, or change the rsync command below). +# Modify WIFIBOX_BASE_DIR to point to your wifibox directory tree. + +WIFIBOX_BASE_DIR=~/Files/_devel/eclipse-workspace/wifibox +DEST_DIR=~/Sites/wifibox +UPDATES_DIR=updates +BASE_URL=doodle3d.com + +OPTIONS=$DEST_DIR +UPLOAD_FILES=0 + +for arg in "$@"; do + case $arg in + -h) + echo "This script calls 'create-wifibox-updates-dir.sh' to generate feed/image directories in $DEST_DIR" + echo "Use '-z' to also create a compressed file containing the 'updates' directory." + echo "Used '-u' to also upload the directory to doodle3d.com/updates" + exit + ;; + -z) + OPTIONS="$OPTIONS -z" + ;; + -u) + UPLOAD_FILES=1 + ;; + *) + echo "Unrecognized option '$arg'" + exit 1 + ;; + esac +done + +$WIFIBOX_BASE_DIR/extra/scripts/create-wifibox-updates-dir.sh $OPTIONS + +if [ $UPLOAD_FILES -eq 1 ]; then + UPLOAD_PATH=$BASE_URL:public_html/updates + + cat <<-'EOM' > $DEST_DIR/$UPDATES_DIR/.htaccess + Options +Indexes +EOM + + echo "Uploading files to $UPLOAD_PATH (if you are asked for your password, please add an entry to your ~/.ssh/config and upload your public ssh key)" + #options are: recursive, preserve perms, symlinks and timestamps, be verbose and use compression + rsync -rpltvz -e ssh --progress $DEST_DIR/$UPDATES_DIR/.htaccess $DEST_DIR/$UPDATES_DIR/* $UPLOAD_PATH +fi diff --git a/src/opkg.conf b/src/opkg.conf index 255327a..85d0194 100644 --- a/src/opkg.conf +++ b/src/opkg.conf @@ -1,5 +1,5 @@ -#src/gz wifibox http://doodle3d.com/static/wifibox-packages -src/gz wifibox http://192.168.5.2/~wouter/wifibox-packages +src/gz wifibox http://doodle3d.com/updates/feed +#src/gz wifibox http://192.168.5.2/~USERNAME/wifibox/updates/feed dest root / dest ram /tmp lists_dir ext /var/opkg-lists