<commit_before>#!/bin/sh
#
# DMG building script adopted from:
#   http://el-tramo.be/git/fancy-dmg/plain/Makefile
#

WC_DMG=wc.dmg
WC_DIR=wc
TEMPLATE_DMG=template.dmg
OUTPUT_DMG=Duplicati.dmg
OUTPUT_PKG=Duplicati.pkg
UNWANTED_FILES="AlphaVSS.Common.dll AlphaFS.dll AlphaFS.dll.config AlphaVSS.Common.dll.config appindicator-sharp.dll SQLite win-tools alphavss control_dir Duplicati.sqlite Duplicati-server.sqlite run-script-example.bat lvm-scripts Duplicati.debug.log SVGIcons"

# These are set via the macos-gatekeeper file
CODESIGN_IDENTITY=
NOTARIZE_USERNAME=
NOTARIZE_PASSWORD=
GATEKEEPER_SETTINGS_FILE="${HOME}/.config/signkeys/Duplicati/macos-gatekeeper"

if [ -f "${GATEKEEPER_SETTINGS_FILE}" ]; then
    source "${GATEKEEPER_SETTINGS_FILE}"
fi


TEMPLATE_DMG_BZ2=$(echo "$TEMPLATE_DMG.bz2")
DELETE_DMG=0

if [ -f "$TEMPLATE_DMG_BZ2" ]; then
    if [ -f "$TEMPLATE_DMG" ]; then
        rm -rf "$TEMPLATE_DMG"
    fi
    
    bzip2 --decompress --keep --quiet "$TEMPLATE_DMG_BZ2"
    DELETE_DMG=1
fi

if [ ! -f "$TEMPLATE_DMG" ]; then
    echo "Template file $TEMPLATE_DMG not found"
    exit
fi

if [ ! -f "$1" ]; then
    echo "Please supply a packaged zip file as the first input argument"
    exit
fi

ZIPNAME=$(basename "$1")
VERSION_NUMBER=$(echo "$ZIPNAME" | awk -F- '{print $2}' | awk -F_ '{print $1}')

VERSION_NAME="Duplicati"
if [ -e "${OUTPUT_DMG}" ]; then
    rm -rf "${OUTPUT_DMG}"
fi

if [ -e "${OUTPUT_PKG}" ]; then
    rm -rf "${OUTPUT_PKG}"
fi

# Remove any existing work copy
if [ -e "Duplicati.app" ]; then
    sudo rm -rf "Duplicati.app"
fi

# Create folder structure
mkdir "Duplicati.app"
mkdir "Duplicati.app/Contents"
mkdir "Duplicati.app/Contents/MacOS"
mkdir "Duplicati.app/Contents/Resources"

# Extract the zip into the Resouces folder
unzip -q "$1" -d "Duplicati.app/Contents/Resources"

# Install the Info.plist and icon, patch the plist file as well
PLIST=$(cat "Info.plist")
PLIST=${PLIST//!LONG_VERSION!/${VERSION_NUMBER}}
echo ${PLIST} > "Duplicati.app/Contents/Info.plist"
cp "Duplicati.icns" "Duplicati.app/Contents/Resources"

for n in "../oem" "../../oem" "../../../oem"
do
    if [ -d $n ]; then
        echo "Installing OEM files"
        cp -R $n Duplicati.app/Contents/Resources/webroot/
    fi
done

for n in "oem-app-name.txt" "oem-update-url.txt" "oem-update-key.txt" "oem-update-readme.txt" "oem-update-installid.txt"
do
    for p in "../$n" "../../$n" "../../../$n"
    do
        if [ -f $p ]; then
            echo "Installing OEM override file"
            cp $p Duplicati.app/Contents/Resources
        fi
    done
done


# Install the LauncAgent if anyone needs it
cp -R "daemon" "Duplicati.app/Contents/Resources"

# Build launchers
cd "launchers"
bash "compile.sh"
cd ..

# Install launchers
mv "launchers/bin/duplicati" "Duplicati.app/Contents/MacOS/duplicati"
mv "launchers/bin/duplicati-cli" "Duplicati.app/Contents/MacOS/duplicati-cli"
mv "launchers/bin/duplicati-server" "Duplicati.app/Contents/MacOS/duplicati-server"
cp "uninstall.sh" "Duplicati.app/Contents/MacOS/"

chmod +x "Duplicati.app/Contents/MacOS/duplicati"
chmod +x "Duplicati.app/Contents/MacOS/duplicati-cli"
chmod +x "Duplicati.app/Contents/MacOS/duplicati-server"
chmod +x "Duplicati.app/Contents/MacOS/uninstall.sh"

# Remove some of the files that we do not like
for FILE in $UNWANTED_FILES
do
    if [ -e "Duplicati.app/Contents/Resources/${FILE}" ]
    then
        rm -rf "Duplicati.app/Contents/Resources/${FILE}"
    fi
done

# Codesign the app bundle
if [ "x${CODESIGN_IDENTITY}" != "x" ]; then
    echo "Codesigning application bundle"

    #Do a poke to get sudo prompt up before the long-running sign-process
    UNUSED=$(sudo ls)

    # Codesign all resources in bundle (i.e. the actual code)
    # Not required, but nice-to-have
    find "Duplicati.app/Contents/Resources" -type f -print0 | xargs -0 codesign -s "${CODESIGN_IDENTITY}"

    # These files have dependencies, so we need to sign them in the correct order
    for file in "duplicati-cli" "duplicati-server" "run-with-mono.sh" "uninstall.sh"; do
        codesign -s "${CODESIGN_IDENTITY}" "Duplicati.app/Contents/MacOS/${file}"
    done

    # Then sign the whole package
    codesign -s "${CODESIGN_IDENTITY}" "Duplicati.app"
else
    echo "No codesign identity supplied, skipping bundle signing"
fi

# Set permissions
sudo chown -R root:admin "Duplicati.app"
sudo chown -R root:wheel "daemon/com.duplicati.app.launchagent.plist"
sudo chmod -R 644 "daemon/com.duplicati.app.launchagent.plist"
sudo chmod +x daemon-scripts/postinstall
sudo chmod +x daemon-scripts/preinstall
sudo chmod +x app-scripts/postinstall
sudo chmod +x app-scripts/preinstall

<commit_msg>Removed the deleted `run-with-mono.sh` script from the signing list<commit_after>#!/bin/sh
#
# DMG building script adopted from:
#   http://el-tramo.be/git/fancy-dmg/plain/Makefile
#

WC_DMG=wc.dmg
WC_DIR=wc
TEMPLATE_DMG=template.dmg
OUTPUT_DMG=Duplicati.dmg
OUTPUT_PKG=Duplicati.pkg
UNWANTED_FILES="AlphaVSS.Common.dll AlphaFS.dll AlphaFS.dll.config AlphaVSS.Common.dll.config appindicator-sharp.dll SQLite win-tools alphavss control_dir Duplicati.sqlite Duplicati-server.sqlite run-script-example.bat lvm-scripts Duplicati.debug.log SVGIcons"

# These are set via the macos-gatekeeper file
CODESIGN_IDENTITY=
NOTARIZE_USERNAME=
NOTARIZE_PASSWORD=
GATEKEEPER_SETTINGS_FILE="${HOME}/.config/signkeys/Duplicati/macos-gatekeeper"

if [ -f "${GATEKEEPER_SETTINGS_FILE}" ]; then
    source "${GATEKEEPER_SETTINGS_FILE}"
fi


TEMPLATE_DMG_BZ2=$(echo "$TEMPLATE_DMG.bz2")
DELETE_DMG=0

if [ -f "$TEMPLATE_DMG_BZ2" ]; then
    if [ -f "$TEMPLATE_DMG" ]; then
        rm -rf "$TEMPLATE_DMG"
    fi
    
    bzip2 --decompress --keep --quiet "$TEMPLATE_DMG_BZ2"
    DELETE_DMG=1
fi

if [ ! -f "$TEMPLATE_DMG" ]; then
    echo "Template file $TEMPLATE_DMG not found"
    exit
fi

if [ ! -f "$1" ]; then
    echo "Please supply a packaged zip file as the first input argument"
    exit
fi

ZIPNAME=$(basename "$1")
VERSION_NUMBER=$(echo "$ZIPNAME" | awk -F- '{print $2}' | awk -F_ '{print $1}')

VERSION_NAME="Duplicati"
if [ -e "${OUTPUT_DMG}" ]; then
    rm -rf "${OUTPUT_DMG}"
fi

if [ -e "${OUTPUT_PKG}" ]; then
    rm -rf "${OUTPUT_PKG}"
fi

# Remove any existing work copy
if [ -e "Duplicati.app" ]; then
    sudo rm -rf "Duplicati.app"
fi

# Create folder structure
mkdir "Duplicati.app"
mkdir "Duplicati.app/Contents"
mkdir "Duplicati.app/Contents/MacOS"
mkdir "Duplicati.app/Contents/Resources"

# Extract the zip into the Resouces folder
unzip -q "$1" -d "Duplicati.app/Contents/Resources"

# Install the Info.plist and icon, patch the plist file as well
PLIST=$(cat "Info.plist")
PLIST=${PLIST//!LONG_VERSION!/${VERSION_NUMBER}}
echo ${PLIST} > "Duplicati.app/Contents/Info.plist"
cp "Duplicati.icns" "Duplicati.app/Contents/Resources"

for n in "../oem" "../../oem" "../../../oem"
do
    if [ -d $n ]; then
        echo "Installing OEM files"
        cp -R $n Duplicati.app/Contents/Resources/webroot/
    fi
done

for n in "oem-app-name.txt" "oem-update-url.txt" "oem-update-key.txt" "oem-update-readme.txt" "oem-update-installid.txt"
do
    for p in "../$n" "../../$n" "../../../$n"
    do
        if [ -f $p ]; then
            echo "Installing OEM override file"
            cp $p Duplicati.app/Contents/Resources
        fi
    done
done


# Install the LauncAgent if anyone needs it
cp -R "daemon" "Duplicati.app/Contents/Resources"

# Build launchers
cd "launchers"
bash "compile.sh"
cd ..

# Install launchers
mv "launchers/bin/duplicati" "Duplicati.app/Contents/MacOS/duplicati"
mv "launchers/bin/duplicati-cli" "Duplicati.app/Contents/MacOS/duplicati-cli"
mv "launchers/bin/duplicati-server" "Duplicati.app/Contents/MacOS/duplicati-server"
cp "uninstall.sh" "Duplicati.app/Contents/MacOS/"

chmod +x "Duplicati.app/Contents/MacOS/duplicati"
chmod +x "Duplicati.app/Contents/MacOS/duplicati-cli"
chmod +x "Duplicati.app/Contents/MacOS/duplicati-server"
chmod +x "Duplicati.app/Contents/MacOS/uninstall.sh"

# Remove some of the files that we do not like
for FILE in $UNWANTED_FILES
do
    if [ -e "Duplicati.app/Contents/Resources/${FILE}" ]
    then
        rm -rf "Duplicati.app/Contents/Resources/${FILE}"
    fi
done

# Codesign the app bundle
if [ "x${CODESIGN_IDENTITY}" != "x" ]; then
    echo "Codesigning application bundle"

    #Do a poke to get sudo prompt up before the long-running sign-process
    UNUSED=$(sudo ls)

    # Codesign all resources in bundle (i.e. the actual code)
    # Not required, but nice-to-have
    find "Duplicati.app/Contents/Resources" -type f -print0 | xargs -0 codesign -s "${CODESIGN_IDENTITY}"

    # These files have dependencies, so we need to sign them in the correct order
    for file in "duplicati-cli" "duplicati-server" "uninstall.sh"; do
        codesign -s "${CODESIGN_IDENTITY}" "Duplicati.app/Contents/MacOS/${file}"
    done

    # Then sign the whole package
    codesign -s "${CODESIGN_IDENTITY}" "Duplicati.app"
else
    echo "No codesign identity supplied, skipping bundle signing"
fi

# Set permissions
sudo chown -R root:admin "Duplicati.app"
sudo chown -R root:wheel "daemon/com.duplicati.app.launchagent.plist"
sudo chmod -R 644 "daemon/com.duplicati.app.launchagent.plist"
sudo chmod +x daemon-scripts/postinstall
sudo chmod +x daemon-scripts/preinstall
sudo chmod +x app-scripts/postinstall
sudo chmod +x app-scripts/preinstall


{'fraction_non_alphanumeric': 0.13418666666666668, 'fraction_numerical': 0.0036266666666666665, 'mean_word_length': 3.702106318956871, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6781952', 'n_tokens_mistral': 3531, 'n_tokens_neox': 3475, 'n_words': 869}