mkpk

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

чување 63cf7c23966879d20632d17c37db01708f7ac09a
родитељ 0845a6e4f4a1aea5c8343a9d4c2efd2023167b94
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Wed,  3 Aug 2022 20:50:51 +0200

Add update; reorganize mkpk

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

Diffstat:
MREADME | 12++++++------
MTODO | 7+++++++
Alib/build.mk | 16++++++++++++++++
Mlib/defaults.mk | 3++-
Alib/fetch.mk | 3+++
Alib/update.mk | 15+++++++++++++++
Mlib/vars.mk | 2+-
Mmkpk | 49++++++++++---------------------------------------
измењених датотека: 8, додавања: 60(+), брисања: 47(-)

diff --git a/README b/README @@ -45,12 +45,12 @@ $ doas mk package-install # installs the above to PKGDIR mkpk helper usage ----------------- -# mkpk fetch mypackage # fetches the sources to SRCBASEDIR -# mkpk build mypackage # builds the mypackage tarball and puts it - # into PKGDIR -# mkpk list mypackage # lists files in a built tarball -# mkpk install mypackage # installs the built tarball -# mkpk uninstall mypackage # uninstalls the package using tarball as +# mkpk update # Pulls the galeb-mkfiles repository +# mkpk fetch foo # fetches the sources of foo to SRCBASEDIR +# mkpk build foo [ver] # builds the foo tarball and puts it into PKGDIR +# mkpk list foo [ver] # lists files in a built tarball +# mkpk install foo [ver] # installs the built tarball +# mkpk uninstall foo [ver] # uninstalls the package using tarball as # filelist diff --git a/TODO b/TODO @@ -4,7 +4,14 @@ TODO [ ] More accurately locate packages based on name (currently, "gcc" refers also to eg. directory "gcc-mlfs" if it happens to be under /src); keep fetched packages in a separate database? + - Usage scenarios: + 1. Packages from galeb-mkfiles + 2. Custom local packages + - Version comparison? - Yes. Build only the latest package, if version is + not explicitly given [ ] mkpk fetch +[x] mkpk update + [ ] Install dependencies (it would call `mk -f $mkpklib/install.mk`) diff --git a/lib/build.mk b/lib/build.mk @@ -0,0 +1,16 @@ +<$mkpklib/defaults.mk + +build-package:V: + set -x + found=$(find ${SRCBASEDIR} -type d -name "${PKGBASE}-*" | \ + sed "/.*\/${PKGBASE}-[0-9]\+/{p;te};d;:e" | \ + sort -n -r -t- -k1,1 | sed 1q) + set +x + if [ -z "${found}" ]; then + printf "Directory %s does not exist (try fetch?)" \ + "${PKGBASE}" >&2 + exit 1 + fi + cp -R "${SRCMKFILES}/${PKGBASE}"/* "${found}/" + cd "${found}" + "${MK}" package-install diff --git a/lib/defaults.mk b/lib/defaults.mk @@ -7,9 +7,10 @@ MANDIR= $DESTDIR$PREFIX/share/man DOCDIR= /share/doc/$PKG LEGALDIR= /share/legal/$PKG +MKFILESREPO= https://git.sr.ht/~strahinja/galeb-mkfiles PKGDIR= /pkg SRCBASEDIR= /src -PKGMKFILES= $SRCBASEDIR/mkfiles +SRCMKFILES= $SRCBASEDIR/mkfiles PKGDB= $PKGDIR/pkgdb.tsv SUCKS= $DESTDIR/sucks diff --git a/lib/fetch.mk b/lib/fetch.mk @@ -0,0 +1,3 @@ +<$mkpklib/defaults.mk + +fetch-package:QV: diff --git a/lib/update.mk b/lib/update.mk @@ -0,0 +1,15 @@ +<$mkpklib/defaults.mk + +update-mkfiles:QV: + if [ ! -d "${SRCMKFILES}" ]; then + cd "${SRCBASEDIR}" + printf " GIT\t%s %s\n" clone "${SRCMKFILES}" + git clone "${MKFILESREPO}" + else + cd "${SRCMKFILES}" + printf " GIT\t%s %s\n" pull "${SRCMKFILES}" + if ! git pull >/dev/null 2>&1; then + git reset --hard >/dev/null 2>&1 + git pull >/dev/null 2>&1 + fi + fi diff --git a/lib/vars.mk b/lib/vars.mk @@ -5,4 +5,4 @@ output:QV: printf "%s=\"%s\"\n" LEGALDIR "$LEGALDIR" printf "%s=\"%s\"\n" PKGDIR "$PKGDIR" printf "%s=\"%s\"\n" SRCBASEDIR "$SRCBASEDIR" - printf "%s=\"%s\"\n" PKGMKFILES "$PKGMKFILES" + printf "%s=\"%s\"\n" SRCMKFILES "$SRCMKFILES" diff --git a/mkpk b/mkpk @@ -15,40 +15,6 @@ error() exit 1 } -fetch() -{ - echo noop -} - -build() -{ - local found=$(find ${SRCBASEDIR} -type d -name "${package}-*" | sed 1q) - if [ -z "${found}" ]; then - error "Directory %s does not exist (try fetch?)" "${package}" - fi - cp -R "${PKGMKFILES}/${package}"/* "${found}/" - cd "${found}" - "${MK}" package-install -} - -list() -{ - "${MK}" -f "${mkpklib}"/listfiles.mk mkpklib="${mkpklib}" \ - PKGBASE="${package}" -} - -install() -{ - "${MK}" -f "${mkpklib}"/install.mk mkpklib="${mkpklib}" \ - PKGBASE="${package}" -} - -uninstall() -{ - "${MK}" -f "${mkpklib}"/uninstall.mk mkpklib="${mkpklib}" \ - PKGBASE="${package}" -} - if [ "$(id -u)" -ne 0 ]; then error "You must be root to run ${0##*/}" elif [ $# -lt 2 ]; then @@ -62,12 +28,17 @@ mkpklib=${mkpklib:-/lib/mkpk} MK=${MK:-/plan9/bin/mk} eval $("${MK}" -f "${mkpklib}"/vars.mk mkpklib="${mkpklib}") +file=defaults case ${command} in - fetch) fetch;; - build) build;; - list) list;; - install) install;; - uninstall) uninstall;; + update) file=update;; + fetch) file=fetch;; + build) file=build;; + list) file=listfiles;; + install) file=install;; + uninstall) file=uninstall;; *) usage exit 1;; esac + +"${MK}" -f "${mkpklib}"/${file}.mk mkpklib="${mkpklib}" \ + PKGBASE="${package}"