Browse Source

Add 'dummypkg' tool

master
Pekka Helenius 1 year ago
parent
commit
99f8d86b7e
3 changed files with 109 additions and 1 deletions
  1. +1
    -0
      README.md
  2. +3
    -1
      tools/PKGBUILD
  3. +105
    -0
      tools/dummypkg.sh

+ 1
- 0
README.md View File

@ -31,6 +31,7 @@ Various shell tools, bundled in a custom `archtools` package. See [PKGBUILD](too
| `bininfo` | Show information about an executable in PATH on Arch Linux |
| `buildpkg` | Build a local package on the current directory which has `PKGBUILD` on Arch Linux |
| `deltmpfiles` | Delete current temporary files from pre-defined locations |
| `dummypkg` | Create a dummy Arch Linux package |
| `extract` | Extract wide range of various archive types with native tools |
| `findinpkg` | Find text patterns & print occurences with matching lines numbers in Arch Linux package files |
| `findmatch` | Grep/List matching strings in a specific folder |


+ 3
- 1
tools/PKGBUILD View File

@ -42,6 +42,7 @@ genmac.sh
getsource.sh # TODO: More implementation needed. See the file for details
nowner.sh # TODO: More implementation needed. See the file for details
pkgdeps.sh # TODO: More implementation needed. See the file for details
dummypkg.sh
archrisks.sh
showpkg.sh
deltmpfiles.sh
@ -71,9 +72,10 @@ sha256sums=('891d763f852d3a61216a384a15ca01c57178d3a5fea8aa858de0643998e9ba58'
'c96b43cc49e6872cdd3b6e51cb490ca8ea2d990f2c3545bed106a21df86648eb'
'3bfac88603fe0f19383bc8b1ca7e2bc6795a90e851eaefd0758d515edd916100'
'3cf521359e473256a52e2a9fbcbfa3f0d39f42befa2d9a79cb7c51372f925c7b'
'8ed38b8f9020280a29999a524f1ad6fb1145d4f00827df45b256bf5eb5a450a1'
'89d421e4981e0907b9095165631791ac034c0d33a215a71c21a59acbf2c41480'
'1424ad779f5f673c01ac2845f5e3749b7c7b47dfdaa173bd45c4e866dfa4da22'
'7493ff8f2321b04fab6c4b743a15708d9aca4383ce0c934c6ed4d091f1dfd76f'
'0524c509b1378dd275c8e396bcafb6df9de48248739c528bc335f879c4b08bfc'
'6290400b493a6e498ffe4a457274c3c4da4de60f5f3043cb36d08c9ca29cce63'
'4a9693bdc1d6a10e54266bf7b3d440e926d66c61ef6d18774a2db951aa4dd478'
'8bbcb61e6283bda4988468271cbaee0d7c537342a095466b4ea309bcb782eaf2'


+ 105
- 0
tools/dummypkg.sh View File

@ -0,0 +1,105 @@
#!/bin/env sh
# dummypkg - Create a dummy Arch Linux package
#
# Copyright (C) 2023 Pekka Helenius <pekka.helenius@fjordtek.com>
#
# 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 2 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 <http://www.gnu.org/licenses/>.
. /usr/share/makepkg/util/message.sh
colorize
if [[ -z $1 ]]
then
error "Provide a package name"
exit 1
fi
PKG=$1
PKGBUILD_FILE="PKGBUILD.tmp"
PACMAN_FILE="pacman.tmp"
msg "Preparing dummy package: $PKG"
description="dummy package"
version="0.1"
release="1"
provides=($PKG)
purge() {
msg "Cleaning up..."
pkgfile_prefix="$PKG-$version-$release-any.pkg.tar"
pkgfile=$(find . -maxdepth 1 -type f -iname "${pkgfile_prefix}*" | head -1)
[[ -f ${pkgfile} ]] && rm -f ${pkgfile}
[[ -f ${PKGBUILD_FILE} ]] && rm -f ${PKGBUILD_FILE}
[[ -f ${PACMAN_FILE} ]] && rm -f ${PACMAN_FILE}
[[ -d src ]] && rm -rf src
[[ -d pkg ]] && rm -rf pkg
exit $1
}
remote_info() {
pacman_info=$(pacman -Si $PKG > $PACMAN_FILE)
if [[ $? -eq 0 ]]
then
# Description
description=$(echo $(grep -oP "^Description.*: \K.*(?=.*)" $PACMAN_FILE) "("$description")")
# Provides
provides_pkgs=($(grep -oP "^Provides.*: \K[^A-Z]*(?=[^A-Z]*)" $PACMAN_FILE))
provides=(${provides[@]} ${provides_pkgs[@]})
# Version
version_full=$(grep -oP "^Version.*: \K.*(?=.*)" $PACMAN_FILE)
version=$(echo $version_full | awk '{sub(/-.*/,"",$0); print $0}')
release=$(echo $version_full | awk '{sub(/.*-/,"",$0); print $0}')
fi
}
trap "purge 1" SIGINT SIGKILL SIGABRT SIGTERM
msg "Setting version number and provided packages information..."
remote_info
msg2 "Description: ${description}"
msg2 "Provides: ${provides[*]}"
msg2 "Version: $version"
msg2 "Release: $release"
cat <<EOF > ${PKGBUILD_FILE}
pkgname="${PKG}"
pkgver=$version
pkgrel=$release
pkgdesc="${description}"
arch=(any)
provides=(${provides[@]})
groups=(dummy)
EOF
if [[ ! -f ${PKGBUILD_FILE} ]]
then
error "No PKGBUILD found"
exit 1
fi
makepkg -Cfi -p ${PKGBUILD_FILE}
purge 0

Loading…
Cancel
Save