2
0
mirror of https://codeberg.org/kiss-community/repo synced 2024-07-02 22:12:27 +00:00

docs: update

This commit is contained in:
Dylan Araps 2019-06-13 17:51:08 +03:00
parent 5e6a63b9cc
commit 304df9f926
5 changed files with 2 additions and 331 deletions

View File

@ -4,5 +4,4 @@ os:
- linux
script:
- shellcheck -e 2015 puke
- shellcheck -e 2034 repo/*/build repo/*/post-install

View File

@ -2,6 +2,8 @@
This is an alternative package system I am experimenting with. Instead of the usual `PKGBUILD`, `APKBUILD`, `xbps-template` and `Pkgfile` format, this repository explores a more unixy approach.
**NOTE**: The package manager can be found here: [kiss](https://github.com/kissx/kiss)
Each Package is split into multiple files.
```sh

View File

@ -1,52 +0,0 @@
#!/bin/sh -e
#
# Setup an alpine chroot.
chroot_dir=~/alpine-chroot
mirror=http://dl-cdn.alpinelinux.org/alpine/
file=apk-tools-static-2.10.3-r1.apk
clean() {
umount "$chroot_dir/dev" ||:
umount "$chroot_dir/proc" ||:
umount "$chroot_dir/sys" ||:
rm -rf "$chroot_dir" "/tmp/${file:-null}"
}
main() {
[ "$(id -u)" != 0 ] && {
echo "Run this script with sudo." >&2
exit 1
}
clean
mkdir -p "/tmp/$file"
cd "/tmp/$file"
wget "$mirror/latest-stable/main/x86_64/$file"
tar xzf "$file"
./sbin/apk.static \
-X "$mirror/latest-stable/main" \
-U \
--allow-untrusted \
--root "$chroot_dir" \
--initdb add alpine-base alpine-sdk ||:
cp -f /etc/resolv.conf "$chroot_dir/etc"
mkdir -p "$chroot_dir/etc/apk"
echo "$mirror/edge/main" > "$chroot_dir/etc/apk/repositories"
mount -o bind /dev "$chroot_dir/dev"
mount -t proc proc "$chroot_dir/proc"
mount -t sysfs sys "$chroot_dir/sys"
trap clean EXIT INT
chroot "$chroot_dir" /bin/sh
}
main

210
kiss
View File

@ -1,210 +0,0 @@
#!/bin/sh
#
# kiss - package manager for kiss linux.
die() {
printf '\033[31mERROR>\033[m %s\n' "$@" >&2
exit 1
}
log() {
printf '\033[32m=>\033[m %s\n' "$@"
}
source_type() {
[ -f "$1" ] && return 2
[ -f "$src_dir/${1##*/}" ] && return 3
[ -z "${1##git:*}" ] && return 4
[ -z "${1##*://*}" ] && return 5
}
pkg_setup() {
cd "$rep_dir/$1" || die "Package '$1' not in repository."
[ -f sources ] || die "Sources file not found."
[ -x build ] || die "Build file not found or not executable."
read -r ver rel < version || die "Version file not found."
pkg=${name:=$1}\#$ver-$rel.tar.gz
}
pkg_depends() {
while read -r dep; do
pkg_list "$dep" || missing="$missing $dep"
done 2>/dev/null < depends
[ -n "$missing" ] && die "Missing dependencies:$missing"
}
pkg_sources() {
while read -r src _; do
case $(source_type "$src"; echo $?) in
4) git clone "${src##git:}" "$mak_dir" ;;
5) wget -P "$src_dir" "$src" || die "Failed to download $src." ;;
0|1) die "Source file '$src' not found." ;;
esac
done < sources
}
pkg_checksum() {
while read -r src _; do
case $(source_type "$src"; echo $?) in
2) src_path=$src ;;
3) src_path=$src_dir/${src##*/} ;;
4) continue
esac
(cd "${src_path%/*}" >/dev/null; sha256sum "${src##*/}") ||
die "Failed to generate checksums."
done < sources > "${1-checksums}"
}
pkg_verify() {
pkg_checksum /dev/stdout | diff checksums - ||
die "Checksum mismatch, run '$0 checksum $name' to update checksums."
}
pkg_extract() {
while read -r src dest; do
[ "$dest" ] && mkdir -p "$mak_dir/$dest"
case $(source_type "$src"; echo $?)-$src in
2-*) cp -f "$src" "$mak_dir/$dest" ;;
3-*.tar*)
tar xf "$src_dir/${src##*/}" -C "$mak_dir/$dest" \
--strip-components 1 || die "Couldn't extract ${src##*/}" ;;
[01]-*) die "${src##*/} not found."
esac
done < sources
}
pkg_build() {
(cd "$mak_dir"; "$OLDPWD/build" "$pkg_dir") || die "Build failed."
cp -Rf "$rep_dir/$name" "$pkg_db"
log "Sucessfully built $pkg." 2> "$pkg_db/$name/manifest"
}
pkg_strip() {
log "Stripping unneeded symbols from binaries and libraries."
find "$pkg_dir" -type f | while read -r binary; do
case $(file -bi "$binary") in
application/x-sharedlib*|application/x-pie-executable*)
strip_opts=--strip-unneeded
;;
application/x-archive*) strip_opts=--strip-debug ;;
application/x-executable*) strip_opts=--strip-all ;;
*) continue ;;
esac
strip "$strip_opts" "$binary"
echo "${binary##*/}: $(stat -c %f "$binary"): $strip_opts: $(file -bi "$binary")"
sleep 1
done
}
pkg_manifest() {
(cd "$pkg_dir" && find ./*) | sed ss.ss | tac |
tee manifest > "$pkg_db/$name/manifest"
}
pkg_tar() {
tar zpcf "$bin_dir/$pkg" -C "$pkg_dir" . || die "Failed to create package."
log "Use '$0 install $name' to install the package."
}
pkg_install() {
[ -f "$bin_dir/$pkg" ] || args b "$name"
pkg_remove "$name"
tar pxvf "$bin_dir/$pkg" -k -C "$sys_dir/" 2>/dev/null
"$sys_db/$name/post-install" 2>/dev/null
log "Installed ${pkg%.tar.gz}"
}
pkg_remove() {
pkg_list "$name" || return 1
while read -r file; do
[ "${file%/*}" = "/etc" ] && continue
if [ -d "$sys_dir$file" ]; then
rmdir "$sys_dir$file" 2>/dev/null || continue
else
rm -f -- "$sys_dir$file" || log "Failed to remove $file."
fi && log "Removed $file"
done < "$sys_db/$name/manifest"
}
pkg_updates() {
for item in "$sys_db/"*; do
read -r db_ver db_rel < "$item/version"
read -r re_ver re_rel < "$rep_dir/${item##*/}/version"
[ "$db_ver-$db_rel" != "$re_ver-$re_rel" ] &&
printf '%s\n' "${item##*/} $re_ver-$re_rel"
done
}
pkg_list() {
[ "$1" ] && { [ -d "$sys_db/$1" ]; return "$?"; }
for item in "$sys_db/"*; do
read -r version release 2>/dev/null < "$item/version" &&
printf '%s\n' "${item##*/} $version-$release"
done
}
args() {
case $1 in b*|c*|i*|r*) pkg_setup "${2-null}"; esac
case $1 in
b*) [ -f checksums ] || die "Checksums missing, run '$0 checksum $name'"
pkg_depends
pkg_sources
pkg_verify
pkg_extract
pkg_build
[ -f nostrip ] || pkg_strip
pkg_manifest
pkg_tar ;;
c*) pkg_sources
pkg_checksum
log "Generated checksums." ;;
i*) pkg_install ;;
l*) pkg_list "$2" ;;
r*) pkg_remove || die "Package '$name' not installed" ;;
u*) pkg_updates ;;
*) log "$0 [b|c|i|l|r|u] [pkg]" \
"build: Build a package." \
"checksum: Generate checksums." \
"install: Install a package (Runs build when needed)." \
"list: List packages." \
"remove: Remove a package." \
"update: Check for updates."
esac
}
main() {
trap 'rm -rf -- "$mak_dir" "$pkg_dir"' EXIT INT
mkdir -p "${src_dir:=$PWD/sources}" \
"${mak_dir:=$PWD/build}" \
"${pkg_db:=${pkg_dir:=$PWD/pkg}/var/db/$0}" \
"${sys_db:=${sys_dir:=$KISS_ROOT}/var/db/$0}" \
"${bin_dir:=$PWD/bin}" \
"${rep_dir:=$PWD/repo}" ||
die "Couldn't create directories at $PWD."
args "$@"
}
main "$@"

View File

@ -1,68 +0,0 @@
#!/bin/sh
# shellcheck source=/dev/null disable=2154,2016
#
# Convert a crux pkgfile to puke's format.
die() {
printf '\033[31mERROR>\033[m %s\n' "$@" >&2
exit 1
}
repo_setup() {
cd repo >/dev/null || die "Not in kiss repository."
mkdir "$name" || die "$name already exists."
cd "$name" >/dev/null || die "Can't cd to $name"
}
pkgfile_read() {
[ -n "$1" ] || die "Need a pkgfile as input."
[ -f "$1" ] || die "File not found '$1'"
. "$1" || die "Syntax error in pkgfile."
[ -n "$name" ] || die "Field 'name' missing from pkgfile."
[ -n "$version" ] || die "Field 'version' missing from pkgfile."
[ -n "$release" ] || die "Field 'release' missing from pkgfile."
[ -n "$source" ] || die "Field 'source' missing from pkgfile."
}
pkgfile_version() {
printf '%s\n' "$version $release" > version
}
pkgfile_source() {
printf '%s\n' "$source" | sed 's/ /\n/g' > sources
}
pkgfile_depends() {
[ "$depends" ] || return
printf '%s\n' "$depends" | sed 's/ /\n/g' > depends
}
pkgfile_build() {
sed 's/$\(BUILD\|PKG\)/$1/g' "$1" | while read -r line; do
[ "$line" = "}" ] && code=
[ "$code" ] && printf '%s\n' "$line"
[ "$line" = "build() {" ] && {
printf '%s\n\n' "#!/bin/sh -e"
code=1
}
done > build
chmod +x build
}
main() {
pkgfile_read "$1"
repo_setup
pkgfile_version
pkgfile_source
pkgfile_depends
pkgfile_build "$1"
}
main "$@"