aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremmett1 <emmett1.2miligrams@protonmail.com>2024-06-12 23:37:45 +0800
committeremmett1 <emmett1.2miligrams@protonmail.com>2024-06-12 23:37:45 +0800
commitdfd4934a783d991b31063171f9e454a218e431b1 (patch)
treea43138940b7efbb5a28e9797d87b0349aaf20685
parentb52a73a431aec49e791b1a03be38bb8d643751db (diff)
downloadautils-dfd4934a783d991b31063171f9e454a218e431b1.tar.gz
autils-dfd4934a783d991b31063171f9e454a218e431b1.zip
updates and added apkg-chroot and apkg-orphan
-rwxr-xr-xapkg29
-rwxr-xr-xapkg-chroot105
-rwxr-xr-xapkg-clean6
-rwxr-xr-xapkg-orphan16
-rwxr-xr-xapkg-purge2
5 files changed, 139 insertions, 19 deletions
diff --git a/apkg b/apkg
index 21b9a6d..b9abb9a 100755
--- a/apkg
+++ b/apkg
@@ -235,21 +235,21 @@ build_src() {
if [ ! "$source" ]; then
# dummy pkg
mkdir -p $PKG/usr
- elif [ -s $HERE/build ]; then
- sh -e -x $HERE/build
+ elif [ "$(command -v build)" ]; then
+ (set -e -x; build)
buildstatus build
else
- if [ -s $HERE/prebuild ]; then
- sh -e -x $HERE/prebuild
+ if [ "$(command -v prebuild)" ]; then
+ (set -e -x; prebuild)
buildstatus prebuild
fi
if [ ! "${build_type}" ]; then
detect_buildtype
fi
(set -e -x; _${build_type})
- buildstatus _${build_type}
- if [ -s $HERE/postbuild ]; then
- sh -e -x $HERE/postbuild
+ buildstatus ${build_type}
+ if [ "$(command -v postbuild)" ]; then
+ (set -e -x; postbuild)
buildstatus postbuild
fi
fi
@@ -348,7 +348,7 @@ build_src() {
exit 1
}
- if [ ! -f "$HERE"/.files ] || [ "$HERE"/info -nt "$HERE"/.files ]; then
+ if [ ! -f "$HERE"/.files ] || [ "$HERE"/abuild -nt "$HERE"/.files ]; then
pkg_updatefiles
fi
@@ -367,7 +367,7 @@ pkg_updatefiles() {
pkg_path() {
for r in $APKG_REPO; do
- [ -f $r/$1/info ] && {
+ [ -f $r/$1/abuild ] && {
echo $r/$1
break
}
@@ -434,7 +434,7 @@ pkg_depends() {
pkg_outdate() {
spm -a | while read -r n v; do
[ "$(pkg_path $n)" ] || continue
- nv="$(grep ^version= $(pkg_path $n)/info | awk -F = '{print $2}')-$(grep ^release= $(pkg_path $n)/info | awk -F = '{print $2}')"
+ nv="$(grep ^version= $(pkg_path $n)/abuild | awk -F = '{print $2}')-$(grep ^release= $(pkg_path $n)/abuild | awk -F = '{print $2}')"
[ "$nv" ] || continue
[ "$v" = "$nv" ] || echo "$n $v -> $nv"
done
@@ -478,7 +478,7 @@ pkg_search() {
exit 1
fi
[ "$1" ] && grep=grep || grep=cat
- find $APKG_REPO -type f -name info 2>/dev/null | sed 's|/info||' | rev | awk -F / '{print $1}' | rev | $grep $1
+ find $APKG_REPO -type f -name abuild 2>/dev/null | sed 's|/abuild||' | rev | awk -F / '{print $1}' | rev | $grep $1
}
pkg_depinstalll() {
@@ -642,12 +642,12 @@ main() {
exit 0
fi
- if [ ! -f ./info ]; then
- msg "'info' not found."
+ if [ ! -f ./abuild ]; then
+ msg "'abuild' not found."
exit 1
fi
- . ./info
+ . ./abuild
[ "$name" ] || die "name is empty"
[ "$version" ] || die "version is empty"
[ "$release" ] || die "release is empty"
@@ -655,7 +655,6 @@ main() {
msg "'name' should be same as package directory name (${PWD##*/})."
exit 1
}
- export name version release
packagefile=$APKG_PACKAGE_DIR/$name#$version-$release.spm
diff --git a/apkg-chroot b/apkg-chroot
new file mode 100755
index 0000000..0e44577
--- /dev/null
+++ b/apkg-chroot
@@ -0,0 +1,105 @@
+#!/bin/sh
+#
+# script to enter chroot
+
+printhelp() {
+ cat << EOF
+
+Usage:
+ $(basename $0) <chroot-dir> [command]
+
+If 'command' is unspecified, ${0##*/} will launch /bin/sh.
+
+EOF
+}
+
+msgerr() {
+ echo "ERROR: $*"
+}
+
+unmount() {
+ while [ "$(mount | awk '{print $3}' | grep -x $1)" ]; do
+ umount $1 2>/dev/null || :
+ done
+}
+
+umountall() {
+ for i in $(mount | awk '{print $3}' | grep $TARGET | tac); do
+ unmount $i
+ done
+}
+
+[ "$(id -u)" = "0" ] || {
+ msgerr "$(basename $0) need root access!"
+ printhelp
+ exit 1
+}
+
+TARGET=$1
+trap umountall 1 2 3 15
+
+[ "$1" ] || {
+ msgerr "Please set directory for chroot!"
+ printhelp
+ exit 1
+}
+
+[ -d "$TARGET" ] || {
+ msgerr "Directory '$TARGET' not exist!"
+ printhelp
+ exit 1
+}
+
+shift
+
+if [ ! "$1" ]; then
+ CMD="/bin/sh"
+else
+ CMD=$*
+fi
+
+if [ -e /sys/firmware/efi/systab ]; then
+ EFI_SYSTEM=1
+fi
+
+mount --bind /dev $TARGET/dev
+mount -t devpts devpts $TARGET/dev/pts -o gid=5,mode=620
+mount -t proc proc $TARGET/proc
+mount -t sysfs sysfs $TARGET/sys
+if [ -n "$EFI_SYSTEM" ]; then
+ mount --bind /sys/firmware/efi/efivars $TARGET/sys/firmware/efi/efivars
+fi
+mount -t tmpfs tmpfs $TARGET/run
+
+if [ -h $TARGET/dev/shm ]; then
+ mkdir -p $TARGET/$(readlink $TARGET/dev/shm)
+fi
+
+[ -f $TARGET/etc/resolv.conf ] && {
+ backupresolvconf=1
+ mv $TARGET/etc/resolv.conf $TARGET/etc/resolv.conf.tmp
+}
+cp -L /etc/resolv.conf $TARGET/etc
+
+chroot "$TARGET" /usr/bin/env -i \
+HOME=/root \
+TERM="$TERM" \
+PS1='\u:\w\$ ' \
+PATH=/bin:/usr/bin:/sbin:/usr/sbin $CMD
+
+retval=$?
+
+[ "$backupresolvconf" = 1 ] && {
+ mv $TARGET/etc/resolv.conf.tmp $TARGET/etc/resolv.conf
+}
+
+unmount $TARGET/dev/pts
+unmount $TARGET/dev
+unmount $TARGET/run
+unmount $TARGET/proc
+if [ -n "$EFI_SYSTEM" ]; then
+ unmount $TARGET/sys/firmware/efi/efivars
+fi
+unmount $TARGET/sys
+
+exit $retval
diff --git a/apkg-clean b/apkg-clean
index 06ff1c6..4a298bd 100755
--- a/apkg-clean
+++ b/apkg-clean
@@ -11,7 +11,7 @@
scan_pkgs() {
[ "$APKG_PACKAGE_DIR" ] && allpkg=$(echo $APKG_PACKAGE_DIR/*.spm 2>/dev/null)
for i in $(apkg -s); do
- . $(apkg -p $i)/info
+ . $(apkg -p $i)/abuild 2>/dev/null
if [ ! "$APKG_PACKAGE_DIR" ]; then
for p in $(apkg -p $i)/*.spm; do
[ -f $p ] || continue
@@ -28,7 +28,7 @@ scan_pkgs() {
scan_srcs() {
[ "$APKG_SOURCE_DIR" ] && allsrc=$(echo $APKG_SOURCE_DIR/* 2>/dev/null)
for i in $(apkg -s); do
- . $(apkg -p $i)/info
+ . $(apkg -p $i)/abuild 2>/dev/null
unset keep
for s in $source; do
s=${s%::noextract}
@@ -42,7 +42,7 @@ scan_srcs() {
(cd $(apkg -p $i)
for f in *; do
case $f in
- info|depends|prebuild|build|postbuild|preinstall|postinstall|*.spm) continue;;
+ abuild|depends|preinstall|postinstall|*.spm) continue;;
esac
echo $keep | tr ' ' '\n' | grep -qx $f || echo $PWD/$f
done
diff --git a/apkg-orphan b/apkg-orphan
new file mode 100755
index 0000000..e30bc5c
--- /dev/null
+++ b/apkg-orphan
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# script to print orphan package
+# (package which no its dependent installed)
+
+for i in $(apkg -a); do
+ [ "$(apkg -p $i)" ] || continue
+ orphan=1
+ for p in $(apkg -j $i); do
+ if [ "$(apkg -a ^$p$)" ]; then
+ unset orphan
+ break
+ fi
+ done
+ [ "$orphan" ] && echo $i
+done
diff --git a/apkg-purge b/apkg-purge
index 16e66ac..3ea1d37 100755
--- a/apkg-purge
+++ b/apkg-purge
@@ -25,7 +25,7 @@ purge() {
fi
done
if [ "$purgeit" ]; then
- echo ">> $1"
+ spm -r $1
fi
}