Blame docker-builder-data/build/script/packet/papagayong-master.files/build-win.sh

e92ef7
#!/bin/bash
e92ef7
e92ef7
# QUICK HACK:
e92ef7
e92ef7
set -e
e92ef7
699c61
PK_DIRNAME="papagayo-ng"
699c61
e92ef7
PREBUILT_URL="https://github.com/morevnaproject/papagayo-ng/releases/download/v1.4.0/papagayo-ng-1.4.0-win.zip"
e92ef7
PREBUILT_ZIP="papagayo-ng-1.4.0-win.zip"
e92ef7
PREBUILT_DIR="papagayo-ng-1.4.0-win"
e92ef7
699c61
VERSION=$(grep "export VERSION=" "$UNPACK_PACKET_DIR/$PK_DIRNAME/util/package-linux.sh" | cut -d\' -f 2)
e92ef7
TARGET_DIR="papagayo-ng-$VERSION-win"
e92ef7
723f4f
foreachfile() {
723f4f
    local FILE=$1
723f4f
    local COMMAND=$2
723f4f
    if [ ! -e "$FILE" ]; then
723f4f
        return 1
723f4f
    fi
723f4f
    if [ -d "$FILE" ]; then    
723f4f
        ls -A1 "$FILE" | while read SUBFILE; do
723f4f
            if ! $COMMAND "$FILE/$SUBFILE" ${@:3}; then
723f4f
                return 1
723f4f
            fi
723f4f
        done
723f4f
    fi
723f4f
}
723f4f
723f4f
nsis_register_file() {
723f4f
    local FILE=$1
723f4f
    local WIN_FILE=$(echo "$FILE" | sed "s|\/|\\\\|g")
723f4f
723f4f
    if [ "${FILE:0:2}" = "./" ]; then
723f4f
        if [ -d "$FILE" ]; then
723f4f
            foreachfile "$FILE" nsis_register_file
723f4f
            echo "RMDir \"\$INSTDIR\\${WIN_FILE:2}\""               >> "files-uninstall.nsh" 
723f4f
        else
723f4f
            echo "Delete \"\$INSTDIR\\${WIN_FILE:2}\""              >> "files-uninstall.nsh" 
723f4f
        fi
723f4f
    else
723f4f
        foreachfile $FILE nsis_register_file
723f4f
    fi
723f4f
}
723f4f
699c61
if [ ! -f "$BUILD_PACKET_DIR/papagayo-ng-$VERSION-win-installer.exe" ] \
699c61
|| [ "$BUILD_PACKET_DIR/papagayo-ng-$VERSION-win-installer.exe" -ot "$CURRENT_PACKET_DIR/unpack.done" ]; then
699c61
	mkdir -p "$BUILD_PACKET_DIR/prebuilt"
e92ef7
	
699c61
	cd "$BUILD_PACKET_DIR/prebuilt"
e92ef7
	wget -c "$PREBUILT_URL"
e92ef7
	rm -rf "$TARGET_DIR"
e92ef7
	unzip "$PREBUILT_ZIP"
e92ef7
	
699c61
	cd "$BUILD_PACKET_DIR"
e92ef7
	rm -f "$TARGET_DIR.zip"
e92ef7
	rm -rf "$TARGET_DIR"
e92ef7
	mv "prebuilt/$PREBUILT_DIR" "$TARGET_DIR"
e92ef7
	
699c61
	cd "$BUILD_PACKET_DIR/$TARGET_DIR"
e92ef7
	rm -rf papagayo-ng
699c61
	ln -s "$UNPACK_PACKET_DIR/$PK_DIRNAME" papagayo-ng
699c61
	cp "$FILES_PACKET_DIR/papagayo-ng.nsi" .
699c61
	cp "$FILES_PACKET_DIR/papagayo-ng.bat" .
723f4f
	touch "files-uninstall.nsh"
723f4f
	nsis_register_file .
699c61
	makensis papagayo-ng.nsi
e92ef7
	
699c61
	cd "$BUILD_PACKET_DIR"
e92ef7
	zip -r "$TARGET_DIR.zip" "$TARGET_DIR"
e92ef7
	rm -rf "$TARGET_DIR"
e92ef7
	mv "papagayo-ng-installer.exe" "papagayo-ng-$VERSION-win-installer.exe"
e92ef7
fi
e92ef7