mkpk

Систем за управљање пакетима који користи mk из система Plan9
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 8491c466d1119c5ce6ae08124e170721d3976d1e
родитељ 3497c5d44e79164b42e460de4d31bc61b5b7c7cc
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Fri,  5 Aug 2022 16:43:19 +0200

Add upgrade operation

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
MTODO | 10++++++++--
Mlib/info.mk | 2+-
Mmkpk | 30++++++++++++++++++------------
Mmkpk.8 | 16++++++++++++++--
измењених датотека: 4, додавања: 41(+), брисања: 17(-)

diff --git a/TODO b/TODO @@ -8,12 +8,18 @@ Low priority - It would need dependencies db or dependencies file with the mkfiles; maybe just a variable -< > Implement explicitely passing version as a parameter - Done ---- +<x> Implement explicitly passing version as a parameter + - That would just be messy. Better to implement upgrade/downgrade. + - Downgrade is already there, just uninstall, remove new tarballs and + install again - previous tarballs will be used. + - Upgrade is achieved by fetch + build + install, though what is lacking is + uninstall before everything else. Could be wrapped into new operation. + - Added upgrade. + [x] Change defaults.mk: it should set variables to fixed defaults, and a new file, derivatives.mk, would take into account possibly changed values of variables like DESTDIR and PREFIX diff --git a/lib/info.mk b/lib/info.mk @@ -23,7 +23,7 @@ show-info:QV: })" | $BC) tarballsize=$(stat $pkg | \ sed '/^\s*Size:/s/\s*Size: \([0-9]\+\).*/\1/;t;d') - apropos=$(whatis "^$PKGBASE\\\$" || echo 'N/A') + apropos=$(whatis "^$PKGBASE\$" || echo 'N/A') printf "Package:\t\t%s\n" "$PKGBASE" printf "Apropos:\t\t%s\n" "$apropos" printf "Version:\t\t%s\n" "$ver" diff --git a/mkpk b/mkpk @@ -3,7 +3,8 @@ usage() { cat <<! >&2 -Usage: ${0##*/} [build | fetch | info | install | list | uninstall | update] [package] +Usage: ${0##*/} [operation] [package] +operations: [ build | fetch | info | install | list | uninstall | update | upgrade ] ! } @@ -18,7 +19,7 @@ error() if [ "$(id -u)" -ne 0 ]; then case "$1" in list|info|"") ;; - *) error "You must be root to run ${0##*/}";; + *) error "You must be root to $1";; esac fi case "$1" in @@ -31,22 +32,27 @@ esac command=$1 package=$2 +version=$3 mkpklib=${mkpklib:-/lib/mkpk} MK=${MK:-/plan9/bin/mk} eval $("${MK}" -f "${mkpklib}"/vars.mk mkpklib="${mkpklib}") -file=defaults +files=defaults case ${command} in - update) file=update;; - fetch) file=fetch;; - build) file=build;; - list) file=listfiles;; - info) file=info;; - install) file=install;; - uninstall) file=uninstall;; + update) files=update;; + fetch) files=fetch;; + build) files=build;; + list) files=listfiles;; + info) files=info;; + install) files=install;; + upgrade) files=uninstall fetch build install;; + uninstall) files=uninstall;; *) usage exit 1;; esac -"${MK}" -f "${mkpklib}"/${file}.mk mkpklib="${mkpklib}" \ - PKGBASE="${package}" +for file in $files +do + "${MK}" -f "${mkpklib}"/${file}.mk mkpklib="${mkpklib}" \ + PKGBASE="${package}" +done diff --git a/mkpk.8 b/mkpk.8 @@ -18,7 +18,7 @@ can be one of the following: . .Bl -tag -width ".Nm install" -offset indent .It Nm Cm build Ar package -Builds the +Builds the most recent version of a .Ar package tarball and puts it into .Ev PKGDIR . @@ -35,7 +35,8 @@ Shows information about the installed tarball of a . .It Nm Cm install Ar package Installs the files from a built tarball of a -.Ar package . +.Ar package +having the most recent version. . .It Nm Cm list Ar package Lists files from the installed tarball of a @@ -48,6 +49,17 @@ by unlinking files from the filelist of its tarball. . .It Nm Cm update Updates the mkfiles repository. +. +.It Nm Cm upgrade Ar package +Upgrades the existing +.Ar package , +as if the following was executed, in order: +.Bd -literal +$ mkpk uninstall package +$ mkpk fetch package +$ mkpk build package +$ mkpk install package +.Ed .El .Sh ENVIRONMENT You can see the full list of relevant environment variables used by