CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Initial import for setup-helper script (imported from upstream CRUX iso.git repository
authorJose V Beneyto <sepen@crux.nu>
Thu, 1 Nov 2012 17:27:07 +0000 (17:27 +0000)
committerJose V Beneyto <sepen@crux.nu>
Thu, 1 Nov 2012 17:27:07 +0000 (17:27 +0000)
filesystem/setup-helper [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index e69de29..348fb08
@@ -0,0 +1,133 @@
+#!/bin/bash
+# post setup
+#
+# Johannes Winkelmann, jw at tks6 dot net
+
+ROOT=$1
+DB=$ROOT/var/lib/pkg/db
+
+## those values should be changed:
+TMPDB=$DB.tmp
+BACKUPDB=$DB.backup
+PKGADD="pkgadd"
+PKGRM="pkgrm"
+MV="mv"
+
+
+is_installed() {
+    printf "%s" $(pkginfo -r $ROOT -i | gawk -v r="^$1\$" '$1 ~ r {print $1}')
+}
+
+
+rename_packages() {
+    if [ -z "$1" ]; then
+       return
+    fi
+    pkg=$@
+    
+    filter="sed "
+    runfilter="no"
+    for tuple in $@; do
+       split=($(echo $tuple|sed -e 's|:| |'))
+       if [ -n "${split[1]}" ] && [ `is_installed ${split[0]}` ]; then
+           echo "Package renamed:  ${split[0]} -> ${split[1]}"
+           filter="$filter -e 's|^${split[0]}$|${split[1]}|'"
+           runfilter="yes"
+       fi
+    done
+    if [ "$runfilter" = "no" ]; then
+       return
+    fi
+
+    :> $TMPDB
+    if [ -f $DB ]; then
+       nextIsName=1
+       cat $DB|while read l; do
+           if [ $nextIsName -eq 1 ]; then
+               nextIsName=0
+               echo $l|eval $filter >> $TMPDB
+           else
+               if [ "$l" = "" ]; then
+                   nextIsName=1
+               fi
+               echo $l >> $TMPDB
+           fi
+       done
+    fi
+
+    $MV $DB $BACKUPDB
+    $MV $TMPDB $DB
+}
+
+
+remove_packages() {
+    for package in $@; do
+       if [ `is_installed $package` ]; then
+           echo "Package removed:  $package"
+            $PKGRM -r $ROOT $package
+       fi
+    done
+}
+
+inject_packages() {
+    for package in $@; do
+    pkg="`find core opt xorg \( -name \"${package}#*.pkg.tar.gz\" -o -name \"${package}#*.pkg.tar.bz2\" -o -name \"${package}#*.pkg.tar.xz\" \)&2> /dev/null`"
+       if [ -z "$pkg" ]; then
+               echo "  ERROR: package $package not found on ISO"
+       else
+               if [ -z `is_installed $package` ]; then
+                   echo "Package injected: $package"
+                       $PKGADD -r $ROOT -f $pkg
+               else
+                       echo "Package upgraded: $package"
+                       $PKGADD -r $ROOT -u -f $pkg
+               fi
+       fi
+    done
+}
+
+####################
+
+if [ -z "$1" ]; then
+    echo "Usage: $0 <root>"
+    exit -1
+fi
+
+
+##### # 2.7 -> 2.8 #####
+echo "* CRUX 2.7 -> 2.8 setup-helper"
+
+rename_packages "util-linux-ng:util-linux"
+remove_packages module-init-tools eject
+inject_packages kmod tzdata util-linux
+
+if [ `is_installed glib` ]; then
+    inject_packages libffi
+fi
+
+if [ `is_installed wpa_supplicant` ]; then
+    inject_packages libnl
+fi
+
+if [ `is_installed xorg-xcb-util` ]; then
+    inject_packages xorg-xcb-util-image xorg-xcb-util-keysyms xorg-xcb-util-renderutil xorg-xcb-util-wm
+fi
+
+if [ `is_installed xorg-xf86-input-evdev` ]; then
+    inject_packages mtdev
+fi
+
+if [ `is_installed xorg-xf86-input-synaptics` ]; then
+    inject_packages mtdev
+fi
+
+if [ `is_installed firefox` ]; then
+    inject_packages nspr nss sqlite3
+fi
+
+if [ `is_installed mesa3d` ]; then
+    inject_packages glu
+fi
+
+# force replacement of /etc/mtab with symlink
+ln -sf /proc/self/mounts $ROOT/etc/mtab