mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-02-06 01:16:34 +00:00
updated
This commit is contained in:
12
pkgadd
12
pkgadd
@@ -133,6 +133,7 @@ parse_opts $(extract_opts "$@")
|
||||
|
||||
SCRATCHPKG_DIR="var/lib/scratchpkg"
|
||||
PKGDB_DIR="$SCRATCHPKG_DIR/db"
|
||||
PKGDBPERMS_DIR="$PKGDB_DIR.perms"
|
||||
LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock"
|
||||
|
||||
ROOT_DIR="${ROOT_DIR%/}" # remove trailing slash
|
||||
@@ -216,7 +217,7 @@ TMP_PKGINSTALL="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_pkginstall"
|
||||
TMP_CONFLICT="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_conflict"
|
||||
|
||||
# check integrity of package and save list file/dirs to install in the meantime
|
||||
tar -tf $PKGNAME > $TMP_PKGADD 2>/dev/null || {
|
||||
tar -tvf $PKGNAME > $TMP_PKGADD 2>/dev/null || {
|
||||
msgerr "Package '$1' is corrupted!"
|
||||
ret 1
|
||||
}
|
||||
@@ -230,7 +231,7 @@ echo "$opr: $name-$version-$release..."
|
||||
|
||||
# check for file conflict
|
||||
if [ ! "$IGNORE_CONFLICT" ]; then
|
||||
grep -v '/$' "$TMP_PKGADD" | while read -r line; do
|
||||
grep -v '/$' "$TMP_PKGADD" | awk '{print $6}' | while read -r line; do
|
||||
if [ "$line" = "${line%.*}.spkgnew" ]; then
|
||||
line=${line%.*}
|
||||
fi
|
||||
@@ -284,6 +285,13 @@ fi
|
||||
# register package into database
|
||||
echo "$version $release" > "$ROOT_DIR/$PKGDB_DIR/$name"
|
||||
cat "$TMP_PKGINSTALL" >> "$ROOT_DIR/$PKGDB_DIR/$name"
|
||||
mkdir -p "$ROOT_DIR/$PKGDBPERMS_DIR"
|
||||
grep '/$' $TMP_PKGADD | while read -r perms own junk1 junk2 junk3 dir; do
|
||||
if [ "$perms" != drwxr-xr-x ] || [ "$own" != root/root ]; then
|
||||
echo "$perms $own $dir" >> "$ROOT_DIR/$PKGDBPERMS_DIR/$name"
|
||||
[ -s "$ROOT_DIR/$PKGDBPERMS_DIR/$name" ] || rm "$ROOT_DIR/$PKGDBPERMS_DIR/$name"
|
||||
fi
|
||||
done
|
||||
|
||||
# running ldconfig
|
||||
if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then
|
||||
|
||||
85
scratch
85
scratch
@@ -227,6 +227,48 @@ scratch_sync() {
|
||||
portsync
|
||||
}
|
||||
|
||||
cvperms() {
|
||||
# converts symbolic to numeric permissions
|
||||
# required an input (symbolic, eg: drwxr-xr-x)
|
||||
s=0; n=0; count=0
|
||||
for i in $(echo "$1" | sed -e 's/\(.\)/\1\n/g'); do
|
||||
count=$((count+1))
|
||||
case $i in
|
||||
d) ;;
|
||||
r) n=$((n+4));;
|
||||
w) n=$((n+2));;
|
||||
x) n=$((n+1));;
|
||||
s) [ $count = 4 ] && s=$((s+4)) || s=$((s+2)); n=$((n+1));;
|
||||
t) s=$((s+1));n=$((n+1));;
|
||||
S) s=$((s+2));;
|
||||
T) s=$((s+1));;
|
||||
esac
|
||||
[ "$count" = 4 ] && {
|
||||
user=$n; n=0
|
||||
}
|
||||
[ "$count" = 7 ] && {
|
||||
group=$n; n=0
|
||||
}
|
||||
[ "$count" = 10 ] && {
|
||||
other=$n; n=0
|
||||
}
|
||||
done
|
||||
echo "$s$user$group$other"
|
||||
}
|
||||
|
||||
fixperms() {
|
||||
needroot "Fix permissions"
|
||||
for i in $PKGDBPERMS_DIR/*; do
|
||||
[ -s $i ] || continue
|
||||
while read -r perms own dir; do
|
||||
chmod $(cvperms $perms) /$dir
|
||||
echo $own | while IFS=/ read -r o g; do
|
||||
chown $o:$g /$dir
|
||||
done
|
||||
done < $i
|
||||
done
|
||||
}
|
||||
|
||||
scratch_trigger() {
|
||||
needroot "Run trigger"
|
||||
if [ -z "$*" ]; then
|
||||
@@ -239,27 +281,7 @@ scratch_trigger() {
|
||||
post_triggers
|
||||
}
|
||||
|
||||
post_triggers() {
|
||||
if [ "$trig_12" = 1 ]; then
|
||||
echo "trigger: Running mkdirs..."
|
||||
for mkd in $PKGDB_DIR/*/.pkgmkdirs; do
|
||||
[ -s $mkd ] || continue
|
||||
grep -Ev '^(#|$)' $mkd | while read -r dir mode uid gid junk; do
|
||||
if [ -e "$dir" ]; then
|
||||
if [ "$uid" != '-' ]; then
|
||||
getent passwd $uid >/dev/null && chown "$uid" "$dir"
|
||||
fi
|
||||
if [ "$gid" != '-' ]; then
|
||||
getent group $gid >/dev/null && chgrp "$gid" "$dir"
|
||||
fi
|
||||
if [ "$mode" != '-' ]; then
|
||||
chmod "$mode" "$dir"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
post_triggers() {
|
||||
if [ "$trig_11" = 1 ] && [ $(command -v fc-cache) ]; then
|
||||
echo "trigger: Updating fontconfig cache..."
|
||||
fc-cache -s
|
||||
@@ -327,6 +349,9 @@ post_triggers() {
|
||||
echo "trigger: Updating the MIME type database..."
|
||||
update-mime-database /usr/share/mime
|
||||
fi
|
||||
|
||||
echo "trigger: Fix files ownership and permissions..."
|
||||
fixperms
|
||||
}
|
||||
|
||||
pre_triggers() {
|
||||
@@ -439,16 +464,6 @@ pre_triggers() {
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# makedirs
|
||||
if [ "$trig_12" != "1" ]; then
|
||||
for pkg in $@; do
|
||||
if [ -s "$PKGDB_DIR/$pkg/.pkgmkdirs" ]; then
|
||||
trig_12=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
scratch_build() {
|
||||
@@ -899,7 +914,6 @@ scratch_outdate() {
|
||||
fi
|
||||
iversion=$(get_iver $pkg)
|
||||
irelease=$(get_irelease $pkg)
|
||||
[ -f "$PKGDB_DIR/$pkg/.lock" ] && ITSLOCK="[masked]"
|
||||
if [ -f "$MASK_FILE" ] && [ $(grep -Ev '^(#|$| )' $MASK_FILE | grep $pkg) ]; then
|
||||
ITSLOCK="[masked]"
|
||||
fi
|
||||
@@ -1270,12 +1284,6 @@ scratch_missingdep() {
|
||||
done
|
||||
}
|
||||
|
||||
scratch_locked() {
|
||||
for pkg in $(allinstalled); do
|
||||
[ -f "$PKGDB_DIR/$pkg/.lock" ] && echo "$pkg"
|
||||
done
|
||||
}
|
||||
|
||||
scratch_orphan() {
|
||||
tmpallpkg="/tmp/.pkgquery_allpkg.$$"
|
||||
tmpalldep="/tmp/.pkgquery_alldep.$$"
|
||||
@@ -1430,6 +1438,7 @@ done
|
||||
|
||||
BUILD_SCRIPT="spkgbuild"
|
||||
PKGDB_DIR="$(pkgadd --print-dbdir)"
|
||||
PKGDBPERMS_DIR=${PKGDB_DIR}.perms
|
||||
REPO_FILE="${REPO_FILE:-/etc/scratchpkg.repo}"
|
||||
ALIAS_FILE="${ALIAS_FILE:-/etc/scratchpkg.alias}"
|
||||
MASK_FILE="${MASK_FILE:-/etc/scratchpkg.mask}"
|
||||
|
||||
Reference in New Issue
Block a user