USM packages use executable scripts to handle different phases of package lifecycle. Scripts are defined in the execs section of MANIFEST.usm and receive specific arguments based on their purpose.
Required script that compiles source code into binaries.
Arguments: [build-directory]
build-directory: Path where build output should be placedEnvironment Variables:
USM_DESTDIR, USM_PREFIX, USM_BINDIR, etc. are setExample:
#!/bin/bash
set -e
build_dir=$1
cd ${build_dir}
meson setup ${src_dir} --prefix=${PREFIX} --libdir=${LIBDIR}
ninja
Optional script that installs built files to destination directory.
Arguments: [build-directory] [install-directory] [install-type]
build-directory: Path containing build outputinstall-directory: Path where files should be installed (DESTDIR)install-type: "fresh", "upgrade", or "downgrade"Environment Variables:
DESTDIR is overridden to install-directoryExample:
#!/bin/bash
set -e
build_dir=$1
install_dir=$2
install_type=$3
cd ${build_dir}
meson install --destdir ${install_dir}
Optional script that runs after USM installs resources to system.
Arguments: [build-directory] [install-type]
build-directory: Path containing build outputinstall-type: "fresh", "upgrade", or "downgrade"Use Case: System integration, cache generation, service registration
Example:
#!/bin/bash
set -e
build_dir=$1
install_type=$2
# Update desktop database
update-desktop-database
# Update icon cache
gtk-update-icon-cache -f -t /usr/share/icons/hicolor
Optional script that runs before USM removes package resources.
Arguments: [remove-type]
remove-type: "final", "upgrade", or "downgrade"Use Case: Cleanup, service stopping, data preservation
Example:
#!/bin/bash
set -e
remove_type=$1
# Stop service if being upgraded
if [ "$remove_type" != "final" ]; then
systemctl stop myapp || true
fi
# Remove user data only on final removal
if [ "$remove_type" = "final" ]; then
rm -rf /var/lib/myapp
fi
Optional script that downloads and extracts source code.
Arguments: None Working Directory: Package root directory
Use Case: Projects without native USM support, repository packaging
Dependencies: Listed in depends.acquire section
Example:
#!/bin/bash
set -e
ARCHIVE_URL="https://github.com/example/myapp/archive/v1.0.0.tar.gz"
ARCHIVE_NAME="source.tar.gz"
EXTRACT_DIR="."
echo "Downloading source..."
wget -O ${ARCHIVE_NAME} ${ARCHIVE_URL}
echo "Extracting archive..."
tar -xzf ${ARCHIVE_NAME} --strip-components=1
echo "Cleaning up..."
rm ${ARCHIVE_NAME}
All scripts must be executable:
chmod +x scripts/build.sh
Scripts should:
set -e to exit on errorsUSM sets these variables for all scripts:
USM_DESTDIR: Destination directoryUSM_PREFIX: Installation prefixUSM_BINDIR: Binary directoryUSM_INCLUDEDIR: Include directoryUSM_DATADIR: Data directoryUSM_INFODIR: Info directoryUSM_LIBDIR: Library directoryUSM_MANDIR: Manual directoryUSM_LIBEXECDIR: Libexec directoryUSM_LOCALEDIR: Locale directoryUSM_LOCALSTATEDIR: Local state directoryUSM_SBINDIR: System binary directoryUSM_SHAREDSTATEDIR: Shared state directoryUSM_SYSCONFIGDIR: Configuration directoryUSM_TAGSDIR: Tags directoryScripts can be placed anywhere in the package, but common conventions:
scripts/: Directory at package rootusm-scripts/: Directory at package root#!/bin/bash
set -e
src_dir=$(pwd)
build_dir=$1
cd ${build_dir}
meson setup ${src_dir} --prefix=${PREFIX} --libdir=${LIBDIR} --bindir=${BINDIR} --includedir=${INCLUDEDIR}
ninja
#!/bin/bash
set -e
src_dir=$(pwd)
build_dir=$1
cd ${build_dir}
make PREFIX=${PREFIX} LIBDIR=${LIBDIR}
#!/bin/bash
set -e
src_dir=$(pwd)
build_dir=$1
cd ${build_dir}
cmake ${src_dir} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_INSTALL_LIBDIR=${LIBDIR}
make
When using ninjaStyleProgress flag, USM parses build output for progress:
[current/total]This reference provides complete specification for USM executable scripts used throughout package lifecycle management.