#!/bin/bash # mp-new | MatterLinux package creation script # MatterLinux 2023-2024 (https://matterlinux.xyz) # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . ############################# ## import common functions ## ############################# location="$(dirname "${0}")" location="$(realpath "${location}")" commonsh="$(echo "${location}" | sed 's/\/bin/\/lib/g')/mtsc-common.sh" source "${commonsh}" if [ "${?}" != "0" ]; then echo "Failed to import mtsc-common" exit 1 fi ################# ## main script ## ################# if [ -z "$1" ]; then error "Please specify a package" exit 1 fi pkg=$(basename "${1}") target=$(dirname "${1}") case "${1}" in *_*) name=$(echo "${pkg}" | cut -d "_" -f1) version=$(echo "${pkg}" | cut -d "_" -f2) ;; *) warn "Package version is not specified, using \"1\" as version instead" name="${pkg}" version="1" ;; esac if [ -d "${target}/${name}" ]; then error "There is already a directory for \"${target}/${name}\"" exit 1 fi info "Creating directory for \"${name}\"" mkdir "${target}/${name}" check_ret "Failed to create package directory for \"${name}\"" cd "${target}/${name}" cat > pkg.sh << EOF # general info NAME="${name}" DESC="" VERSION="${version}" # required files FILES=() HASHES=() # install and build depends DEPENDS=() BUILD=() PACKAGE(){ tar xf "\${NAME}-\${VERSION}.tar.gz" cd "\${NAME}-\${VERSION}" # build commands cd .. && rm -r "\${NAME}-\${VERSION}" } INSTALL(){ # install script # remove if not requied } EOF cat > changes.md << EOF # ${version} First version EOF cat > .gitignore << EOF .cache/ dist/ root/ EOF success "Created package directory and files for \"${name}\""