forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-02-17 557c24d082b6ecb9bfe5407b77ae43fa7650a5dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh
#
# Copyright 2007 Openedhand Ltd.
#
# Author: Richard Purdie <rpurdie@openedhand.com>
#
 
# The following script will run all the scriptlets found in #SYSCONFDIR#/deb-postinsts,
# #SYSCONFDIR#/ipk-postinsts or #SYSCONFDIR#/rpm-postinsts or the package manager in
# case available.
 
# the order of this list is important, do not change!
backend_list="rpm deb ipk"
 
pm_installed=false
 
for pm in $backend_list; do
   # found the package manager, it has postinsts
   case $pm in
       "deb")
           if [ -s "#LOCALSTATEDIR#/lib/dpkg/status" ]; then
               pm_installed=true
               break
           fi
           ;;
 
       "ipk")
           if [ -s "#LOCALSTATEDIR#/lib/opkg/status" ]; then
               pm_installed=true
               break
           fi
           ;;
   esac
 
   pi_dir="#SYSCONFDIR#/$pm-postinsts"
 
   # found postinsts directory
   if [ -d $pi_dir ]; then
       break
   fi
done
 
remove_rcsd_link () {
   if [ -n "`which update-rc.d`" ]; then
       update-rc.d -f run-postinsts remove
   fi
}
 
if ! [ -d $pi_dir ] && ! $pm_installed; then
   remove_rcsd_link
   exit 0
fi
 
echo "Configuring packages on first boot...."
echo " (This may take several minutes. Please do not power off the machine.)"
 
[ -e #SYSCONFDIR#/default/postinst ] && . #SYSCONFDIR#/default/postinst
 
if [ "$POSTINST_LOGGING" = "1" ]; then
   rm -f $LOGFILE
   append_log=">>$LOGFILE 2>&1"
fi
 
exec_postinst_scriptlets() {
   for i in `ls $pi_dir`; do
       i=$pi_dir/$i
       echo "Running postinst $i..."
       [ "$POSTINST_LOGGING" = "1" ] && eval echo "Running postinst $i..." $append_log
       if [ -x $i ]; then
           (sh -c $i $append_log)
           rm $i
       else
           echo "ERROR: postinst $i failed."
           [ "$POSTINST_LOGGING" = "1" ] && eval echo "ERROR: postinst $i failed." $append_log
           remove_rcsd_link=0
       fi
   done
}
 
remove_rcsd_link=1
if $pm_installed; then
   case $pm in
       "ipk")
           eval opkg configure $append_log
           ;;
 
       "deb")
           eval dpkg --configure -a $append_log
           ;;
   esac
else
   exec_postinst_scriptlets
fi
 
# since all postinstalls executed successfully, remove the rcS.d link
if [ $remove_rcsd_link = 1 ]; then
   remove_rcsd_link
fi