mirror of
https://codeberg.org/kiss-community/repo
synced 2024-12-21 23:00:06 -07:00
puke: Checksum support.
This commit is contained in:
parent
a69c674c0a
commit
46548440d4
96
puke
96
puke
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# shellcheck source=/dev/null
|
# shellcheck disable=2094,2103 source=/dev/null
|
||||||
#
|
#
|
||||||
# pkg - package manager for kiss linux.
|
# pkg - package manager for kiss linux.
|
||||||
|
|
||||||
@ -13,7 +13,8 @@ log() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clean() {
|
clean() {
|
||||||
rm -rf "$build_dir" "$pkg_dir"
|
cd "$old_pwd/repo/$name"
|
||||||
|
rm -rf -- "$mak_dir" "$pkg_dir" .checksums
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_info() {
|
pkg_info() {
|
||||||
@ -36,51 +37,85 @@ pkg_depends() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pkg_sources() {
|
pkg_sources() {
|
||||||
while read -r source; do
|
while read -r src; do
|
||||||
source_name=${source##*/}
|
src_name=${src##*/}
|
||||||
|
|
||||||
if [ -f "$source" ]; then
|
if [ -f "$src" ]; then
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif [ -f "$source_dir/$source_name" ]; then
|
elif [ -f "$src_dir/$src_name" ]; then
|
||||||
log "Found cached $source_name."
|
log "Found cached $src_name."
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif [ -z "${source##*://*}" ]; then
|
elif [ -z "${src##*://*}" ]; then
|
||||||
log "Downloading '$source'."
|
log "Downloading '$src'."
|
||||||
wget -P "$source_dir" "$source" || die "Failed to download $source."
|
wget -P "$src_dir" "$src" || die "Failed to download $src."
|
||||||
|
|
||||||
else
|
else
|
||||||
die "Source file '$source' not found."
|
die "Source file '$src' not found."
|
||||||
fi
|
fi
|
||||||
done < sources
|
done < sources
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pkg_checksum() {
|
||||||
|
while read -r src; do
|
||||||
|
src_name=${src##*/}
|
||||||
|
|
||||||
|
if [ -f "$src" ]; then
|
||||||
|
src_path=$src
|
||||||
|
|
||||||
|
elif [ -f "$src_dir/$src_name" ]; then
|
||||||
|
src_path=$src_dir/$src_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "${src_path%/*}"
|
||||||
|
sha256sum -- "$src_name" || die "Failed to generate checksums."
|
||||||
|
cd - >/dev/null
|
||||||
|
done < sources > "${1-checksums}"
|
||||||
|
}
|
||||||
|
|
||||||
|
pkg_verify() {
|
||||||
|
pkg_checksum .checksums
|
||||||
|
|
||||||
|
diff .checksums checksums ||
|
||||||
|
die "checksum of sources does not match checksum of package" \
|
||||||
|
"run '$0 checksum $name' to update checksums"
|
||||||
|
|
||||||
|
log "Checksums verified."
|
||||||
|
}
|
||||||
|
|
||||||
pkg_extract() {
|
pkg_extract() {
|
||||||
while read -r source; do
|
while read -r src; do
|
||||||
source_name=${source##*/}
|
src_name=${src##*/}
|
||||||
|
|
||||||
if [ -f "$source" ]; then
|
if [ -f "$src" ]; then
|
||||||
cp -f "$source" "$build_dir"
|
cp -f "$src" "$mak_dir"
|
||||||
|
|
||||||
elif [ -f "$source_dir/$source_name" ]; then
|
elif [ ! -f "$src_dir/$src_name" ]; then
|
||||||
# TODO: Handle extraction based on file type.
|
die "$src_name" not found.
|
||||||
tar xf "$source_dir/$source_name" -C "$build_dir" \
|
|
||||||
--strip-components 1 || die "couldn't extract $source_name"
|
else
|
||||||
|
case $src_dir/$src_name in
|
||||||
|
*.tar|*.tar.??|*.tar.???|*.tar.????|*.tgz)
|
||||||
|
tar xf "$src_dir/$src_name" -C "$mak_dir" \
|
||||||
|
--strip-components 1 ||
|
||||||
|
die "Couldn't extract $src_name"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
done < sources
|
done < sources
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_build() {
|
pkg_build() {
|
||||||
log "Building $pkg"
|
log "Building $pkg."
|
||||||
|
|
||||||
cd "$build_dir"
|
cd "$mak_dir"
|
||||||
set -e
|
set -e
|
||||||
. "$OLDPWD/build"
|
. "$OLDPWD/build"
|
||||||
set +e
|
set +e
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
log "Sucessfully built $pkg"
|
log "Sucessfully built $pkg."
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_manifest() {
|
pkg_manifest() {
|
||||||
@ -98,24 +133,35 @@ args() {
|
|||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
b*)
|
b*)
|
||||||
|
[ -f checksums ] || die "Checksums missing, run '$0 checksum $name'"
|
||||||
|
|
||||||
pkg_depends
|
pkg_depends
|
||||||
pkg_sources
|
pkg_sources
|
||||||
|
pkg_verify
|
||||||
pkg_extract
|
pkg_extract
|
||||||
pkg_build
|
pkg_build
|
||||||
pkg_manifest
|
pkg_manifest
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
c*)
|
||||||
|
pkg_sources
|
||||||
|
pkg_checksum
|
||||||
|
|
||||||
|
log "Generated checksums."
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
trap clean EXIT
|
trap clean EXIT INT
|
||||||
clean
|
clean
|
||||||
|
|
||||||
mkdir -p sources build pkg sys bin ||
|
mkdir -p sources build pkg sys bin ||
|
||||||
die "Couldn't create directories at '$PWD'".
|
die "Couldn't create directories at '$PWD'".
|
||||||
|
|
||||||
source_dir=$PWD/sources
|
old_pwd=$PWD
|
||||||
build_dir=$PWD/build
|
src_dir=$PWD/sources
|
||||||
|
mak_dir=$PWD/build
|
||||||
pkg_dir=$PWD/pkg
|
pkg_dir=$PWD/pkg
|
||||||
sys_dir=$PWD/sys
|
sys_dir=$PWD/sys
|
||||||
bin_dir=$PWD/bin
|
bin_dir=$PWD/bin
|
||||||
|
1
repo/zlib/checksums
Normal file
1
repo/zlib/checksums
Normal file
@ -0,0 +1 @@
|
|||||||
|
c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 zlib-1.2.11.tar.gz
|
Loading…
Reference in New Issue
Block a user