puke: Added post_install script support.

This commit is contained in:
Dylan Araps 2019-05-10 21:41:20 +03:00
parent c01adf77a7
commit f97839793f
2 changed files with 22 additions and 14 deletions

View File

@ -16,6 +16,9 @@ zlib/ # Package name.
├─ manifest # The built package's files and directories. ├─ manifest # The built package's files and directories.
├─ checksums # The checksums for the source files. ├─ checksums # The checksums for the source files.
# Optional files.
├─ post_install # Script to run after package installation.
``` ```
When a built package is installed, this entire directory tree is copied to `/var/db/puke` where it becomes a database entry. Listing the dependencies for a package is a simple as printing the contents of the `depends` file. Searching for which package owns a file is as simple as checking each `manifest` file. When a built package is installed, this entire directory tree is copied to `/var/db/puke` where it becomes a database entry. Listing the dependencies for a package is a simple as printing the contents of the `depends` file. Searching for which package owns a file is as simple as checking each `manifest` file.

33
puke
View File

@ -16,7 +16,7 @@ clean() {
rm -rf -- "$mak_dir" "$pkg_dir" rm -rf -- "$mak_dir" "$pkg_dir"
[ -n "$name" ] && [ -n "$name" ] &&
rm "$old_pwd/repo/$name/.checksums" 2>/dev/null rm "$rep_dir/$name/.checksums" 2>/dev/null
} }
pkg_info() { pkg_info() {
@ -122,9 +122,9 @@ pkg_build() {
set -e set -e
. "$OLDPWD/build" . "$OLDPWD/build"
set +e set +e
cd "$old_pwd/repo/$name" cd "$rep_dir/$name"
cp -R "$old_pwd/repo/$name" "$old_pwd/pkg/var/db/puke" cp -R "$rep_dir/$name" "$pkg_dir/$dbs_dir"
log "Sucessfully built $pkg." log "Sucessfully built $pkg."
} }
@ -152,6 +152,10 @@ pkg_install() {
pkg_remove "$name" pkg_remove "$name"
tar pxvf "$bin_dir/$pkg.tar.gz" -k -C "$sys_dir/" 2>/dev/null tar pxvf "$bin_dir/$pkg.tar.gz" -k -C "$sys_dir/" 2>/dev/null
[ -f "$sys_dir/$dbs_dir/$name/post-install" ] &&
. "$sys_dir/$dbs_dir/$name/post-install"
log "Installed $pkg" log "Installed $pkg"
} }
@ -170,18 +174,18 @@ pkg_remove() {
fi fi
[ "$?" = 0 ] && log "Removed $file" [ "$?" = 0 ] && log "Removed $file"
done < "$sys_dir/var/db/puke/$name/manifest" done < "$sys_dir/$dbs_dir/$name/manifest"
return 0 return 0
} }
pkg_updates() { pkg_updates() {
git pull git pull
cd "$sys_dir/var/db/puke" cd "$sys_dir/$dbs_dir"
for pkg in *; do for pkg in *; do
read -r db_version db_release < "$pkg/version" read -r db_version db_release < "$pkg/version"
read -r re_version re_release < "$old_pwd/repo/$pkg/version" read -r re_version re_release < "$rep_dir/$pkg/version"
[ "$db_version-$db_release" != "$re_version-$re_release" ] && [ "$db_version-$db_release" != "$re_version-$re_release" ] &&
log "NEW $pkg $re_version-$re_release" log "NEW $pkg $re_version-$re_release"
@ -190,10 +194,10 @@ pkg_updates() {
pkg_list() { pkg_list() {
[ "$1" ] && { [ "$1" ] && {
[ -d "$sys_dir/var/db/puke/$1" ] || return 1 && return 0 [ -d "$sys_dir/$dbs_dir/$1" ] || return 1 && return 0
} }
for pkg in "$sys_dir/var/db/puke/"*; do for pkg in "$sys_dir/$dbs_dir/"*; do
[ -d "$pkg" ] || continue [ -d "$pkg" ] || continue
read -r version release < "$pkg/version" read -r version release < "$pkg/version"
log "${pkg##*/} $version-$release" log "${pkg##*/} $version-$release"
@ -242,12 +246,13 @@ main() {
trap clean EXIT INT trap clean EXIT INT
clean clean
old_pwd=$PWD src_dir=$PWD/sources
src_dir=$PWD/sources # Contains the downloaded sources. mak_dir=$PWD/build
mak_dir=$PWD/build # Contains the current build. pkg_dir=$PWD/pkg
pkg_dir=$PWD/pkg # Contains the built package's files. sys_dir=$PWD/sys
sys_dir=$PWD/sys # Fake root (testing, temporary). bin_dir=$PWD/bin
bin_dir=$PWD/bin # Contains the final tarballed packages. rep_dir=$PWD/repo
dbs_dir=var/db/puke
args "$@" args "$@"
} }