Blame env-builder-data/build/script/packet/synfigstudio-nsis.sh

f0ec65
DEPS="synfigstudio-master"
18e95a
DEPS_NATIVE="nsis-2.50"
a8518c
21fb9b
PK_PYTHON_DIRNAME="python"
72e1c5
PK_PYTHON_ARCHIVE="python-3.6.4.zip"
72e1c5
PK_PYTHON_URL="https://www.synfig.org/files/$PK_PYTHON_ARCHIVE"
72e1c5
PK_PYTHON_LXML_ARCHIVE="python-3.6.4-lxml.zip"
72e1c5
PK_PYTHON_LXML_URL="https://www.synfig.org/files/$PK_PYTHON_LXML_ARCHIVE"
1709dc
PK_LICENSE_FILE="license-synfigstudio-master"
21fb9b
a8518c
pkfunc_register_file() {
a8518c
    local FILE=$1
a8518c
    local WIN_FILE=$(echo "$FILE" | sed "s|\/|\\\\|g")
a8518c
    ! [ -L "$FILE" ] || return 0
a8518c
a8518c
    if [[ "$FILE" != ./* ]]; then
a8518c
        foreachfile $FILE pkfunc_register_file
a8518c
    elif [ "${FILE:0:8}" = "./files-" ]; then
a8518c
        true # skip
a8518c
    else
a8518c
        local TARGET_INSTALL="files-install.nsh"
a8518c
        local TARGET_UNINSTALL="files-uninstall.nsh"
a8518c
        if [ "$FILE" = "./bin/ffmpeg.exe" ]; then
a8518c
            TARGET_INSTALL="files-ffmpeg-install.nsh"
a8518c
        elif [[ "$FILE" = "./examples/"* ]]; then
a8518c
            TARGET_INSTALL="files-examples-install.nsh"
a8518c
        fi
a8518c
a8518c
        if [ -d "$FILE" ]; then
a8518c
            echo "CreateDirectory \"\$INSTDIR\\${WIN_FILE:2}\""     >> "$TARGET_INSTALL"
a8518c
            foreachfile "$FILE" pkfunc_register_file
a8518c
            echo "RMDir \"\$INSTDIR\\${WIN_FILE:2}\""               >> "$TARGET_UNINSTALL" 
a8518c
        else
a8518c
            echo "File \"/oname=${WIN_FILE:2}\" \"${WIN_FILE:2}\""  >> "$TARGET_INSTALL"
a8518c
            echo "Delete \"\$INSTDIR\\${WIN_FILE:2}\""              >> "$TARGET_UNINSTALL" 
a8518c
        fi
a8518c
    fi
a8518c
}
a8518c
21fb9b
# download portable python and pass downloaded files through all build phases
21fb9b
pkdownload() {
bcd29a
    wget -c "$PK_PYTHON_URL" -O "$PK_PYTHON_ARCHIVE" || return 1
bcd29a
    wget -c "$PK_PYTHON_LXML_URL" -O "$PK_PYTHON_LXML_ARCHIVE" || return 1
21fb9b
}
21fb9b
21fb9b
pkunpack() {
21fb9b
    unzip "$DOWNLOAD_PACKET_DIR/$PK_PYTHON_ARCHIVE" || return 1
72e1c5
    unzip "$DOWNLOAD_PACKET_DIR/$PK_PYTHON_LXML_ARCHIVE" || return 1
21fb9b
}
21fb9b
21fb9b
pkinstall() {
21fb9b
    copy "$BUILD_PACKET_DIR" "$INSTALL_PACKET_DIR" || return 1
21fb9b
}
21fb9b
a8518c
pkinstall_release() {
a8518c
    local LOCAL_INSTALLER_DIR="$INSTALL_RELEASE_PACKET_DIR/installer"
a8518c
    local LOCAL_CACHE_DIR="$INSTALL_RELEASE_PACKET_DIR/cache"
a8518c
        
a8518c
    # create temporary dir
a8518c
    rm -rf "$LOCAL_INSTALLER_DIR"
a8518c
    mkdir -p "$LOCAL_INSTALLER_DIR"
a8518c
    cd "$LOCAL_INSTALLER_DIR" || return 1
a8518c
a8518c
    # copy files
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/bin/lib/" "./bin/lib/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/bin/share/" "./bin/share/" || return 1
1119bc
    cp -rf "$ENVDEPS_RELEASE_PACKET_DIR/bin/"*.dll "./bin/" || return 1
0f9da6
    for FILE in \
90d752
            ffmpeg.exe \
90d752
            ffprobe.exe \
90d752
            gdk-pixbuf-csource.exe \
90d752
            gdk-pixbuf-pixdata.exe \
90d752
            gdk-pixbuf-query-loaders.exe \
90d752
            gio-querymodules.exe \
89acaa
            gspawn-win*-helper-* \
90d752
            melt.exe \
90d752
            sox.exe \
90d752
            synfig.exe \
90d752
            synfigstudio.exe; do
b05db5
        cp -rf "$ENVDEPS_RELEASE_PACKET_DIR/bin/"${FILE} "./bin/" || return 1
1119bc
    done
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/etc/" "./etc/" || return 1
1119bc
    [ -d "./lib/gdk-pixbuf-2.0/2.10.0/loaders" ] || mkdir -p "./lib/gdk-pixbuf-2.0/2.10.0/loaders"
1119bc
    cp -rf "$ENVDEPS_RELEASE_PACKET_DIR/lib/gdk-pixbuf-2.0/2.10.0/loaders/"*.dll "./lib/gdk-pixbuf-2.0/2.10.0/loaders" || return 1
09a11a
    cp -rf "$ENVDEPS_RELEASE_PACKET_DIR/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" "./lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" || return 1
1119bc
    [ -d "./lib/gtk-3.0/3.0.0/immodules" ] || mkdir -p "./lib/gtk-3.0/3.0.0/immodules"
1119bc
    cp -rf "$ENVDEPS_RELEASE_PACKET_DIR/lib/gtk-3.0/3.0.0/immodules/"*.dll "./lib/gtk-3.0/3.0.0/immodules" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/lib/ImageMagick-6.8.7/" "./lib/ImageMagick-6.8.7/" || return 1
1119bc
    [ -d "./lib/synfig/modules" ] || mkdir -p "./lib/synfig/modules"
1119bc
    cp -rf "$ENVDEPS_RELEASE_PACKET_DIR/lib/synfig/modules/"*.dll "./lib/synfig/modules" || return 1
1119bc
    cp -rf "$ENVDEPS_RELEASE_PACKET_DIR/lib/"*.dll "./lib" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/license/" "./license/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/fontconfig/" "./share/fontconfig/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/glib-2.0/schemas/" "./share/glib-2.0/schemas/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/gtk-3.0/" "./share/gtk-3.0/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/icons/" "./share/icons/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/ImageMagick-6/" "./share/ImageMagick-6/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/locale/" "./share/locale/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/mime/" "./share/mime/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/mime-info/" "./share/mime-info/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/pixmaps/" "./share/pixmaps/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/synfig/" "./share/synfig/" || return 1
1119bc
    copy "$ENVDEPS_RELEASE_PACKET_DIR/share/themes/" "./share/xml/" || return 1
a8518c
a8518c
    # move examples
21fb9b
    mv "./share/synfig/examples" "./" || return 1
21fb9b
21fb9b
    # add portable python
21fb9b
    copy "$INSTALL_PACKET_DIR/$PK_PYTHON_DIRNAME" "$LOCAL_INSTALLER_DIR/python" || return 1
72e1c5
    copy "$INSTALL_PACKET_DIR/lxml" "$LOCAL_INSTALLER_DIR/python/Lib/site-packages/lxml" || return 1
72e1c5
    copy "$INSTALL_PACKET_DIR/lxml-4.4.2.dist-info" "$LOCAL_INSTALLER_DIR/python/Lib/site-packages/lxml-4.4.2.dist-info" || return 1
72e1c5
a8518c
    cd "$LOCAL_INSTALLER_DIR" || return 1
a8518c
a8518c
    # get version
a8518c
    local LOCAL_VERSION_FULL=$(cat $ENVDEPS_RELEASE_PACKET_DIR/version-synfigstudio-*)
a8518c
    local LOCAL_VERSION=$(echo "$LOCAL_VERSION_FULL" | cut -d - -f 1)
a8518c
    local LOCAL_VERSION2=$(echo "$LOCAL_VERSION" | cut -d . -f -2)
a8518c
    local LOCAL_COMMIT=$(echo "$LOCAL_VERSION_FULL" | cut -d - -f 2)
4026eb
    
4026eb
    # QuickHack: convert symlinks to regular files
4026eb
    [ ! -f "${LOCAL_INSTALLER_DIR}/../tmp.zip" ] || rm -rf "${LOCAL_INSTALLER_DIR}/../tmp.zip"
4026eb
    zip -r "${LOCAL_INSTALLER_DIR}/../tmp.zip" ./ || return 1
4026eb
    cd "${LOCAL_INSTALLER_DIR}/.." || return 1
4026eb
    rm -rf "${LOCAL_INSTALLER_DIR}" || return 1
4026eb
    mkdir "${LOCAL_INSTALLER_DIR}" || return 1
4026eb
    cd "${LOCAL_INSTALLER_DIR}"  || return 1
4026eb
    unzip "${LOCAL_INSTALLER_DIR}/../tmp.zip" || return 1
4026eb
    rm -rf "${LOCAL_INSTALLER_DIR}/../tmp.zip" || return 1
a8518c
a8518c
    # create file lists
a8518c
    echo "create file lists"
a8518c
    touch files-install.nsh
a8518c
    touch files-ffmpeg-install.nsh
a8518c
    touch files-examples-install.nsh
a8518c
    touch files-uninstall.nsh
a8518c
    pkfunc_register_file .
a8518c
    echo "created"
a8518c
a8518c
    # copy NSIS configuration
a8518c
    cp "$FILES_PACKET_DIR/synfigstudio.nsi" "./" || return 1
1f2234
a8518c
    # create config.nsh (see opentoons.nsi)
a8518c
    cat > config.nsh << EOF
21fb9b
!define PK_NAME          "synfigstudio" 
aefcfb
!define PK_DIR_NAME      "Synfig"
aefcfb
!define PK_NAME_FULL     "Synfig Studio (${ARCH}bit)"
1f2234
!define PK_ARCH          "${ARCH}"
21fb9b
!define PK_VERSION       "${LOCAL_VERSION2}"
21fb9b
!define PK_VERSION_FULL  "${LOCAL_VERSION}-${LOCAL_COMMIT:0:5}"
21fb9b
!define PK_EXECUTABLE    "bin\\synfigstudio.exe"
21fb9b
!define PK_ICON          "share\\pixmaps\\synfig_icon.ico"
21fb9b
!define PK_DOCUMENT_ICON "share\\pixmaps\\sif_icon.ico"
1709dc
!define PK_LICENSE       ".\\license\\${PK_LICENSE_FILE}"
a8518c
EOF
a8518c
a8518c
    # let's go
a8518c
    makensis synfigstudio.nsi || return 1
a8518c
a8518c
    # remove temporary dir
a8518c
    cd "$INSTALL_RELEASE_PACKET_DIR" || return 1
a8518c
    mv "$LOCAL_INSTALLER_DIR"/*.exe ./ || return 1
a8518c
    rm -rf "$LOCAL_INSTALLER_DIR"
a8518c
}