Skip to content

Commit 14271ec

Browse files
authored
Merge pull request #29 from venomlinux/new-world-option
added scratch world option
2 parents 70fa8b3 + 1161d00 commit 14271ec

File tree

1 file changed

+56
-8
lines changed

1 file changed

+56
-8
lines changed

scratch

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ scratch_install() {
552552
break
553553
}
554554
done_pkg="$done_pkg $ii"
555+
world_add $ii
555556
cd - >/dev/null
556557
fi
557558
done
@@ -599,6 +600,9 @@ scratch_install() {
599600
count=$(( count - 1 ))
600601
break
601602
}
603+
if [ $(echo $IPKG | tr ' ' '\n' | grep -x $int) ]; then
604+
world_add $int
605+
fi
602606
run_postinstallsh
603607
done_pkg="$done_pkg $int"
604608
cd - >/dev/null
@@ -654,10 +658,12 @@ scratch_remove() {
654658
count=$(( count + 1 ))
655659
pre_triggers $pkg
656660
settermtitle "[ $count/$pkgcount ] Removing $pkg..."
661+
echo "remove: $pkg-$(get_iver $pkg)-$(get_irelease $pkg)..."
657662
pkgdel $pkg $OPTS || {
658663
error=1
659664
break
660665
}
666+
world_del $pkg
661667
done
662668
settermtitle "Triggering remove hook..."
663669
post_triggers
@@ -1286,15 +1292,15 @@ scratch_missingdep() {
12861292
}
12871293

12881294
scratch_orphan() {
1289-
tmpallpkg="/tmp/.pkgquery_allpkg.$$"
1290-
tmpalldep="/tmp/.pkgquery_alldep.$$"
1291-
for pkg in $(allinstalled); do
1292-
echo $pkg >> $tmpallpkg
1293-
dep="$dep $(get_depends $pkg)"
1295+
tmpdeplistworld="/tmp/.deplistworld.$$"
1296+
tmpallinstalled="/tmp/.allinstalled.$$"
1297+
for i in $(cat $WORLD_FILE); do
1298+
deplist $i
12941299
done
1295-
echo $dep | tr ' ' '\n' | sort | uniq > "$tmpalldep"
1296-
grep -xvF -f "$tmpalldep" "$tmpallpkg"
1297-
rm "$tmpalldep" "$tmpallpkg"
1300+
echo $DEP | tr ' ' '\n' > $tmpdeplistworld
1301+
allinstalled > $tmpallinstalled
1302+
grep -xvF -f $tmpdeplistworld $tmpallinstalled
1303+
rm $tmpallinstalled $tmpdeplistworld
12981304
}
12991305

13001306
scratch_path() {
@@ -1361,6 +1367,46 @@ scratch_files() {
13611367
fi
13621368
}
13631369

1370+
world_add() {
1371+
grep -qx $1 "$WORLD_FILE" && return
1372+
scratch_isinstalled $1 || {
1373+
echo "'$1' not installed"
1374+
return 1
1375+
}
1376+
echo "$1" >> "$WORLD_FILE"
1377+
echo "world: '$1' added to world"
1378+
sort "$WORLD_FILE" -o "$WORLD_FILE" # sort world
1379+
sed '/^$/d' -i "$WORLD_FILE" # delete empty lines
1380+
}
1381+
1382+
world_del() {
1383+
grep -qx $1 "$WORLD_FILE" || return
1384+
sed "/^$1$/d" -i "$WORLD_FILE"
1385+
echo "world: '$1' deleted from world"
1386+
sed '/^$/d' -i "$WORLD_FILE" # delete empty lines
1387+
}
1388+
1389+
scratch_world() {
1390+
if [ "$1" ]; then
1391+
needroot
1392+
touch "$WORLD_FILE"
1393+
while [ "$1" ]; do
1394+
if [ ! $(grep -x $1 "$WORLD_FILE") ] ; then
1395+
world_add $1
1396+
else
1397+
world_del $1
1398+
fi
1399+
shift
1400+
done
1401+
else
1402+
[ -s "$WORLD_FILE" ] && {
1403+
cat "$WORLD_FILE"
1404+
} || {
1405+
echo "world is empty"
1406+
}
1407+
fi
1408+
}
1409+
13641410
scratch_help() {
13651411
cat << EOF
13661412
Usage:
@@ -1417,6 +1463,7 @@ Options:
14171463
missingdep print missing dependencies
14181464
orphan print orphan installed ports
14191465
foreign print foreign ports
1466+
world [ports] print/add/remove world list
14201467
printconfig <opts> print scratchpkg configs
14211468
help print this help msg
14221469
@@ -1481,6 +1528,7 @@ REPO_FILE="${REPO_FILE:-/etc/scratchpkg.repo}"
14811528
ALIAS_FILE="${ALIAS_FILE:-/etc/scratchpkg.alias}"
14821529
MASK_FILE="${MASK_FILE:-/etc/scratchpkg.mask}"
14831530
CONFIG_FILE="${CONFIG_FILE:-/etc/scratchpkg.conf}"
1531+
WORLD_FILE="$(dirname $PKGDB_DIR)/world"
14841532

14851533
# default value from pkgbuild
14861534
SOURCE_DIR="/var/cache/scratchpkg/sources"

0 commit comments

Comments
 (0)