7 #/run/... may be needed to add (pkg@run.cpio)
8 #_scripts/pkg.ver may be needed to add
9 #package/_pkgs.group@@@@
10 #---- -review "----" reamarked code "lines"
39 [ "$PKG" = "gcc-tgt" ] && PKG
=gcc
40 [ "$PKG" = "glibc-tgt" ] && PKG
=glibc
43 DONTINSTALL
=" skeleton toolchain toolchain-external toolchain-external-custom initscripts jpeg busybox coreutils "
44 DONTINSTALL2
=" getent jpeg toolchain-external toolchain-external-custom libgl libegl busybox mcookie libfm-extra "
46 BUSYBOX_CHK
=" acpid inetutils net-tools util-linux grep sed gawk findutils gzip bzip2 coreutils cpio tar psmisc procps-ng dos2unix eject fbset e2fsprogs hdparm kmod kbd cups pciutils usbutils xz man-db dosfstools reiserfsprogs ntp patch diffutils debianutils sendmail bash ash zip unzip vim wget which "
48 echo "$DONTINSTALL2" |
grep -q " $PKG " && exit 0
50 DIRSCRIPT
=$
(cd $
(dirname "$0") && pwd -P)
55 DESTROOT
=output
/target
56 BUILDROOT
=output
/build
59 echo "###### PKG_SCRIPT $PKG $(cat $BUILDROOT/build-sysinit.log) $1 $2"
61 if [ "$1" = "start" ] && [ "$2" = "install-target" -o "$2" = "install-staging" ]; then
63 [ -e $BUILDROOT/inst_start.log
] && exit 0
64 touch $BUILDROOT/inst_start.log
66 rm -f _scripts
/$PKG.scr
70 for i
in $CREATEDIRS; do
73 ln -sf share
/doc
$DESTROOT/usr
/doc
74 ln -sf share
/man
$DESTROOT/usr
/man
75 ln -sf share
/info
$DESTROOT/usr
/info
76 ln -sf lib
$DESTROOT/usr
/lib64
77 ln -sf lib
$DESTROOT/lib64
79 [ -e _scripts
/$PKG.inst_start.sh
] && source _scripts
/$PKG.inst_start.sh
82 if [ "$1" = "end" ] && [ "$2" = "install-target" ]; then
83 source $BUILDROOT/.package_source
89 [ "$PKG" = "glibc" ] && NAME
="glibc"
90 [ "$PKG" = "gcc" ] && NAME
="gcc"
93 [ -e $BUILDROOT/.python_version
] && PYTHON_VER
=`cat $BUILDROOT/.python_version`
94 if [ ! -z "$PYTHON_VER" -a "$PYTHON_VER" = 3 ]; then
96 echo "$PKG" |
grep -q "^python-" && NAME
=`echo "$PKG" | sed 's/^python-/python3-/'` && PKG
="$NAME" && GRP
="development python3"
101 [ ! -e _scripts
/$PKG.
rev ] && echo 1 > _scripts
/$PKG.
rev
105 REV
=`cat _scripts/$PKG.rev`
106 [ -e _scripts
/$PKG.ver
] && VERSION
=`cat _scripts/$PKG.ver`
110 if [ -e $DESTROOT/var
/lock
]; then
111 mkdir
-p $DESTROOT/run
/lock
112 LSFILE
=`find $DESTROOT/var/lock -mindepth 1 -maxdepth 1 -print -quit 2> /dev/null`
113 #mv doesn't move hidden files (.*|the dot char started filenames)
114 [ ! -z "$LSFILE" ] && mv $DESTROOT/var
/lock
/* $DESTROOT/run
/lock
115 rmdir $DESTROOT/var
/lock
119 if [ -e $DESTROOT/run
]; then
120 mkdir
-p $DESTROOT/var
/run
121 LSFILE
=`find $DESTROOT/run -mindepth 1 -maxdepth 1 -print -quit 2> /dev/null`
122 #mv doesn't move hidden files (.*|the dot char started filenames)
123 [ ! -z "$LSFILE" ] && mv $DESTROOT/run
/* $DESTROOT/var
/run
128 if [ -e $DESTROOT/var
/run
]; then
129 echo "###### PKG_SCRIPT $PKG /var/run"
130 if ! rmdir $DESTROOT/var
/run
2> /dev
/null
; then
131 (ODIR
=`pwd`; cd $DESTROOT/var
/run
&& _mkcpio
$ODIR/_scripts
/$PKG@run.
cpio)
132 rm -rf $DESTROOT/var
/run
2> /dev
/null
133 if [ ! -e _scripts
/$PKG.inst_end.sh
]; then
134 echo 'rm -rf $DESTROOT/var/run 2> /dev/null' > _scripts
/$PKG.inst_end.sh
136 sh
/bin
/_add_linefeed.sh _scripts
/$PKG.inst_end.sh
137 ! grep -qFx 'rm -rf $DESTROOT/var/run 2> /dev/null' _scripts
/$PKG.inst_end.sh
&& \
138 echo 'rm -rf $DESTROOT/var/run 2> /dev/null' >> _scripts
/$PKG.inst_end.sh
144 #remove created links (symbolic links to put some files into other directory)
145 rm -f $DESTROOT/usr
/share
/info
/dir
146 rm -f $DESTROOT/tools
/share
/info
/dir
150 rm $DESTROOT/usr
/info
151 rm $DESTROOT/usr
/lib64
153 for i
in $CREATEDIRS; do
154 rmdir $DESTROOT/$i 2> /dev
/null
158 #call package update script
159 [ -e _scripts
/$PKG.inst_end.sh
] && source _scripts
/$PKG.inst_end.sh
162 #update some special packages
163 if [ -e $DESTROOT/usr
/lib
/perl5
]; then
164 if [ -e _scripts
/perl.ver
]; then
165 PERL
=`cat _scripts/perl.ver`
166 rm -f $DESTROOT/usr
/lib
/perl
5/$PERL/x86_64-linux
/perllocal.pod
167 find $DESTROOT/usr
/lib
/perl
5/site_perl
/$PERL/x86_64-linux
/auto
-name ".packlist" -type f | \
168 xargs sed -i -n '/^\/usr\//p'
175 [ -e _scripts
/$PKG.inc
] && cp _scripts
/$PKG.inc _scripts
/$PKG.scr
178 #create update scripts for packages which may be replaced with busybox
179 if echo "$BUSYBOX_CHK" |
grep -q " $PKG "; then
180 #----run _lsexecs.sh earlyer
181 EXEC_FILES
=`sh /bin/_lsexecs.sh -l $DESTROOT | sort`
184 for i
in $EXEC_FILES; do
186 [ -z "$EXEC_VAR" ] && EXEC_VAR
="'$i'" || EXEC_VAR
="$EXEC_VAR '$i'"
189 echo "#INC#busybox-update" >> _scripts
/$PKG.scr
190 echo "#VAR#cmdlist=($EXEC_VAR)" >> _scripts
/$PKG.scr
194 #create mime-info's (raw) script
195 if [ -e "$DESTROOT/usr/share/mime" ]; then
196 echo "#INC#shared-mime-info" >> _scripts
/$PKG.scr
200 #create texinfo's (raw) script
201 TEXINFO
=`find $DESTROOT/usr/share/info -name "*.info*" -print -quit 2> /dev/null`
202 if [ -n "$TEXINFO" ]; then
204 cd $DESTROOT/usr
/share
/info
205 TI_FILES
=`ls *.info*`
208 for i
in $TI_FILES; do
209 [ -z "$TI_VAR" ] && TI_VAR
="'$i'" || TI_VAR
="$TI_VAR '$i'"
213 echo "#INC#texinfo" >> _scripts
/$PKG.scr
214 echo "#VAR#filelist=($TI_VAR)" >> _scripts
/$PKG.scr
218 #create package user related files
219 F_PASSWD
="$BUILDROOT/tmp_passwd"
220 F_GROUP
="$BUILDROOT/tmp_group"
222 if [ -e _scripts
/$PKG.users
]; then
223 cat _scripts
/$PKG.users | \
224 while read username uid group gid passwd home shell groups comment
; do
225 if [ "$group" != "-" ]; then
226 GRPID
=`grep "^${group}:" "$F_GROUP" | cut -d : -f 3`
227 if [ -z "$GRPID" ]; then
228 echo "**Group not found: ${group}**"
230 if ! echo "$processed" |
grep -q "^${group}$"; then
231 if ! echo "$SKIPGROUP" |
grep -q " $group "; then
232 echo "#PRI#addgroup -g $GRPID $group 2> /dev/null" >> _scripts
/$PKG.scr
233 echo "#POR#delgroup $group 2> /dev/null" >> _scripts
/$PKG.scr
235 [ -z "$processed" ] && processed
="$group" || processed
=`echo -ne "$processed\n$group"`
239 if [ "$groups" != "-" ]; then
243 GRPID
=`grep "^${i}:" "$F_GROUP" | cut -d : -f 3`
244 if [ -z "$GRPID" ]; then
245 echo "**Group not found: ${i}**"
247 if ! echo "$processed" |
grep -q "^${i}$"; then
248 if ! echo "$SKIPGROUP" |
grep -q " $i "; then
249 echo "#PRI#addgroup -g $GRPID $i 2> /dev/null" >> _scripts
/$PKG.scr
250 echo "#POR#delgroup $i 2> /dev/null" >> _scripts
/$PKG.scr
252 [ -z "$processed" ] && processed
="$i" || processed
=`echo -ne "$processed\n$i"`
259 cat _scripts
/$PKG.users | \
260 while read username uid group gid passwd home shell groups comment
; do
261 [ "$shell" != "-" ] && SHELL
="-s $shell" || SHELL
=
262 [ "$home" != "-" ] && HHOME
="-h $home" || HHOME
=
263 [ "$group" != "-" ] && GROUP
="-G $group" || GROUP
=
264 [ "$comment" != "-" -a ! -z "$comment" ] && COMMENT
="-g '$comment'" || COMMENT
=
265 if [ "$username" != "-" ]; then
266 USRID
=`grep "^${username}:" "$F_PASSWD" | cut -d : -f 3`
267 if [ -z "$USRID" ]; then
268 echo "**User not found: ${username}**"
270 echo "#PRI#adduser $HHOME $COMMENT $GROUP $SHELL -D -H -u $USRID $username 2> /dev/null" >> _scripts
/$PKG.scr
271 echo "#POR#deluser $username 2> /dev/null" >> _scripts
/$PKG.scr
272 if [ "$groups" != "-" ]; then
276 echo "#PRI#adduser $username $i 2> /dev/null" >> _scripts
/$PKG.scr
277 echo "#POR#delgroup $username $i 2> /dev/null" >> _scripts
/$PKG.scr
287 #create install files
288 if [ -e _scripts
/$PKG.scr
]; then
289 echo -n > _scripts
/$PKG.
install
290 if INC
=$
(grep "^#INC#" _scripts
/$PKG.scr
); then
294 INCVAL
=`echo "$i" | sed 's/^#INC#//'`
295 if [ -e _scripts
/scripts
/$INCVAL.scr
]; then
296 [ -z "$INCSCR" ] && INCSCR
="$INCVAL" || INCSCR
=`echo -ne "$INCSCR\n$INCVAL"`
302 grep "^#VAR#" _scripts
/scripts
/$i.scr |
sed 's/^#VAR#//' >> _scripts
/$PKG.
install
305 grep "^#VAR#" _scripts
/$PKG.scr |
sed 's/^#VAR#//' >> _scripts
/$PKG.
install
308 grep "^#PCD#" _scripts
/scripts
/$i.scr |
sed 's/^#PCD#//' >> _scripts
/$PKG.
install
311 echo "post_install() {" >> _scripts
/$PKG.
install
313 grep "^#POI#" _scripts
/scripts
/$i.scr |
sed 's/^#POI#//' >> _scripts
/$PKG.
install
315 grep "^#POI#" _scripts
/$PKG.scr |
sed 's/^#POI#//' >> _scripts
/$PKG.
install
316 echo "}" >> _scripts
/$PKG.
install
318 echo "post_upgrade() {" >> _scripts
/$PKG.
install
320 grep "^#POU#" _scripts
/scripts
/$i.scr |
sed 's/^#POU#//' >> _scripts
/$PKG.
install
322 grep "^#POU#" _scripts
/$PKG.scr |
sed 's/^#POU#//' >> _scripts
/$PKG.
install
323 echo "}" >> _scripts
/$PKG.
install
325 echo "post_remove() {" >> _scripts
/$PKG.
install
327 grep "^#POR#" _scripts
/scripts
/$i.scr |
sed 's/^#POR#//' >> _scripts
/$PKG.
install
329 grep "^#POR#" _scripts
/$PKG.scr |
sed 's/^#POR#//' >> _scripts
/$PKG.
install
330 echo "}" >> _scripts
/$PKG.
install
332 echo "pre_install() {" >> _scripts
/$PKG.
install
334 grep "^#PRI#" _scripts
/scripts
/$i.scr |
sed 's/^#PRI#//' >> _scripts
/$PKG.
install
336 grep "^#PRI#" _scripts
/$PKG.scr |
sed 's/^#PRI#//' >> _scripts
/$PKG.
install
337 echo "}" >> _scripts
/$PKG.
install
339 echo "pre_upgrade() {" >> _scripts
/$PKG.
install
341 grep "^#PRU#" _scripts
/scripts
/$i.scr |
sed 's/^#PRU#//' >> _scripts
/$PKG.
install
343 grep "^#PRU#" _scripts
/$PKG.scr |
sed 's/^#PRU#//' >> _scripts
/$PKG.
install
344 echo "}" >> _scripts
/$PKG.
install
346 echo "pre_remove() {" >> _scripts
/$PKG.
install
348 grep "^#PRR#" _scripts
/scripts
/$i.scr |
sed 's/^#PRR#//' >> _scripts
/$PKG.
install
350 grep "^#PRR#" _scripts
/$PKG.scr |
sed 's/^#PRR#//' >> _scripts
/$PKG.
install
351 echo "}" >> _scripts
/$PKG.
install
355 grep "^#VAR#" _scripts
/$PKG.scr |
sed 's/^#VAR#//' >> _scripts
/$PKG.
install
357 echo "post_install() {" >> _scripts
/$PKG.
install
358 grep "^#POI#" _scripts
/$PKG.scr |
sed 's/^#POI#//' >> _scripts
/$PKG.
install
359 echo "}" >> _scripts
/$PKG.
install
361 echo "post_upgrade() {" >> _scripts
/$PKG.
install
362 grep "^#POU#" _scripts
/$PKG.scr |
sed 's/^#POU#//' >> _scripts
/$PKG.
install
363 echo "}" >> _scripts
/$PKG.
install
365 echo "post_remove() {" >> _scripts
/$PKG.
install
366 grep "^#POR#" _scripts
/$PKG.scr |
sed 's/^#POR#//' |
tac >> _scripts
/$PKG.
install
367 echo "}" >> _scripts
/$PKG.
install
369 echo "pre_install() {" >> _scripts
/$PKG.
install
370 grep "^#PRI#" _scripts
/$PKG.scr |
sed 's/^#PRI#//' >> _scripts
/$PKG.
install
371 echo "}" >> _scripts
/$PKG.
install
373 echo "pre_upgrade() {" >> _scripts
/$PKG.
install
374 grep "^#PRU#" _scripts
/$PKG.scr |
sed 's/^#PRU#//' >> _scripts
/$PKG.
install
375 echo "}" >> _scripts
/$PKG.
install
377 echo "pre_remove() {" >> _scripts
/$PKG.
install
378 grep "^#PRR#" _scripts
/$PKG.scr |
sed 's/^#PRR#//' |
tac >> _scripts
/$PKG.
install
379 echo "}" >> _scripts
/$PKG.
install
382 grep -A 1 -n "() {$" _scripts
/$PKG.
install |
grep "^[0-9]\+-}$" |
sed "s/-}$//" | \
384 sed -i "$(expr $num - $anum)d" _scripts
/$PKG.
install
385 sed -i "$(expr $num - 1 - $anum)d" _scripts
/$PKG.
install
386 anum
=$
(expr $anum + 2)
391 #copy in (auto)generated cpio
392 if [ -e _scripts
/${PKG}@run.
cpio ]; then
393 mkdir
-p $DESTROOT/etc
/rundir
394 cp -Rdp _scripts
/${PKG}@run.
cpio $DESTROOT/etc
/rundir
396 #buildroot's sysvinit scripts()()
397 if [ -e $DESTROOT/etc
/init.d
]; then
398 [ "$PKG" != "openrc" ] && mv $DESTROOT/etc
/init.d
$DESTROOT/etc
/sysvinit.d
399 ####rm sysvinit runscript if there is
400 [ -e $DESTROOT/etc
/sysvinit.d
/rcS
] && rm $DESTROOT/etc
/sysvinit.d
/rcS
401 [ -e $DESTROOT/etc
/sysvinit.d
/rcK
] && rm $DESTROOT/etc
/sysvinit.d
/rcK
403 #execute permissions in /etc/profile.d
404 if [ -e $DESTROOT/etc
/profile.d
]; then
405 LSFILE
=`find $DESTROOT/etc/profile.d -mindepth 1 -maxdepth 1 -print -quit 2> /dev/null`
406 [ ! -z "$LSFILE" ] && chmod 755 $DESTROOT/etc
/profile.d
/*
410 #copy raw package files
411 #cp ... -p -> cp ... --preserve=mode,ownership (new timestamp)
412 [ -d _scripts
/files
/$PKG/etc
] && cp -Rdp _scripts
/files
/$PKG/etc
$DESTROOT
413 [ -d _scripts
/files
/$PKG/@
file ] && cp -Rdp _scripts
/files
/$PKG/@file
/* $DESTROOT
420 #make package info files
421 mkdir
-p $DESTROOT/var
/lib
/instpkg
/local
422 mkdir
-p $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV
423 mkdir
-p $DESTROOT/var
/lib
/instpkg
/local
/.
local
424 ln -sf ..
/$PKG-$VERSION-$REV $DESTROOT/var
/lib
/instpkg
/local
/.local
/$PKG
425 #----move diskusage to the end of the script
426 SIZE
=`du -sk $DESTROOT | grep -o "^[0-9]\+"`
428 if [ -e _scripts
/$PKG.desc
]; then
429 SHORT_DESC
=`cat _scripts/$PKG.desc`
432 echo -ne "NAME=$NAME\nVERSION=$VERSION\nREV=$REV\nDESC=\"$SHORT_DESC\"\nSIZE=$SIZE\n" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/info
433 #buildroot descriptions
434 tar xzf _scripts
/files
/desc.
tar.gz
-C $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV desc
/$PKG.desc@
2> /dev
/null
435 [ -e $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc
/$PKG.desc@
] && \
436 mv $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc
/$PKG.desc@
$DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc@
437 rm -rf $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc
440 [ ! -e _scripts
/$PKG.deps
] && touch _scripts
/$PKG.deps
443 sort -u _scripts
/$PKG.deps
> $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/depends
444 cat $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/depends |
tr '\n' ' ' | \
445 sed 's% $%%' > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/depend@
446 GRP
=`grep "package.*/$PKG/Config.in" package/_pkgs.group@@@@ | cut -d " " -f 1-2`
449 [ "$PKG" = "busybox" ] && GRP
="base system"
450 [ "$PKG" = "glibc" ] && GRP
="base development"
451 [ "$PKG" = "gcc" ] && GRP
="base development"
452 [ "$PKG" = "grub-dist" ] && GRP
="base system"
453 [ "$PKG" = "busybox-init" ] && GRP
="base system"
454 [ "$PKG" = "busybox-pwdutils" ] && GRP
="base system"
455 [ "$PKG" = "busybox-utils" ] && GRP
="base system"
456 [ "$PKG" = "busybox-dist" ] && GRP
="base system"
458 [ -z "$GRP" ] && GRP
="unknown other"
461 echo "$GRP" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/groups
463 [ -e _scripts
/$PKG.
install ] && cp -dp _scripts
/$PKG.
install $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/install
465 [ -e _scripts
/$PKG.keepdirs
] && cp -dp _scripts
/$PKG.keepdirs
$DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/keepdirs
467 LS_EXECS
=`sh /bin/_lsexecs.sh $DESTROOT | sort`
468 [ ! -z "$LS_EXECS" ] && echo "$LS_EXECS" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/execs
470 LS_DIRLINKS
=`sh /bin/_find_dirlinks.sh $DESTROOT | sort`
471 [ ! -z "$LS_DIRLINKS" ] && echo "$LS_DIRLINKS" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/dirlinks
475 (cd $DESTROOT; tar czf
$PKGDEST/$PKG-$VERSION-$REV.
tar.gz
*)
478 echo "$DONTINSTALL" |
grep -q " $PKG " ||
tar xzf
$PKGDEST/$PKG-$VERSION-$REV.
tar.gz
-C /
482 rm -f $BUILDROOT/inst_start.log