5 #/bin/_find_dirlinks.sh
8 #/run/... may be needed to add (pkg@run.cpio)
9 #_scripts/pkg.ver may be needed to add
10 #package/_pkgs.group@@@@
11 #---- -review "----" reamarked code "lines"
40 [ "$PKG" = "gcc-tgt" ] && PKG
=gcc
41 [ "$PKG" = "glibc-tgt" ] && PKG
=glibc
44 DONTINSTALL
=" skeleton toolchain toolchain-external toolchain-external-custom initscripts jpeg busybox coreutils "
45 DONTINSTALL2
=" getent jpeg toolchain-external toolchain-external-custom libgl libegl busybox mcookie libfm-extra "
47 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 "
49 echo "$DONTINSTALL2" |
grep -q " $PKG " && exit 0
51 DIRSCRIPT
=$
(cd $
(dirname "$0") && pwd -P)
56 DESTROOT
=output
/target
57 BUILDROOT
=output
/build
60 echo "###### PKG_SCRIPT $PKG $(cat $BUILDROOT/build-sysinit.log) $1 $2"
62 if [ "$1" = "start" ] && [ "$2" = "install-target" -o "$2" = "install-staging" ]; then
64 #install-staging - install-target
65 [ -e $BUILDROOT/inst_start.log
] && exit 0
66 touch $BUILDROOT/inst_start.log
68 rm -f _scripts
/$PKG.scr
72 for i
in $CREATEDIRS; do
75 ln -sf share
/doc
$DESTROOT/usr
/doc
76 ln -sf share
/man
$DESTROOT/usr
/man
77 ln -sf share
/info
$DESTROOT/usr
/info
78 ln -sf lib
$DESTROOT/usr
/lib64
79 ln -sf lib
$DESTROOT/lib64
81 [ -e _scripts
/$PKG.inst_start.sh
] && source _scripts
/$PKG.inst_start.sh
84 if [ "$1" = "end" ] && [ "$2" = "install-target" ]; then
85 source $BUILDROOT/.package_source
91 [ "$PKG" = "glibc" ] && NAME
="glibc"
92 [ "$PKG" = "gcc" ] && NAME
="gcc"
95 [ -e $BUILDROOT/.python_version
] && PYTHON_VER
=`cat $BUILDROOT/.python_version`
96 if [ ! -z "$PYTHON_VER" -a "$PYTHON_VER" = 3 ]; then
98 if echo "$PKG" |
grep -q "^python-"; then
99 NAME
=`echo "$PKG" | sed 's/^python-/python3-/'`
100 #buildroot description->
101 tar xzf _scripts
/files
/desc.
tar.gz
-C _scripts desc
/$PKG.desc@
2> /dev
/null
102 mv _scripts
/desc
/$PKG.desc@ _scripts
/desc
/desc@
103 #buildroot description<-
104 [ -e _scripts
/$PKG.desc
] && cp _scripts
/$PKG.desc _scripts
/$NAME.desc
105 [ -e _scripts
/$PKG.deps
] && cp _scripts
/$PKG.deps _scripts
/$NAME.deps
107 GRP
="development python3"
113 [ ! -e _scripts
/$PKG.
rev ] && echo 1 > _scripts
/$PKG.
rev
117 REV
=`cat _scripts/$PKG.rev`
118 [ -e _scripts
/$PKG.ver
] && VERSION
=`cat _scripts/$PKG.ver`
122 if [ -e $DESTROOT/var
/lock
]; then
123 mkdir
-p $DESTROOT/run
/lock
124 LSFILE
=`find $DESTROOT/var/lock -mindepth 1 -maxdepth 1 -print -quit 2> /dev/null`
125 #mv doesn't move hidden files (.*|the dot char started filenames)
126 [ ! -z "$LSFILE" ] && mv $DESTROOT/var
/lock
/* $DESTROOT/run
/lock
127 rmdir $DESTROOT/var
/lock
131 if [ -e $DESTROOT/run
]; then
132 mkdir
-p $DESTROOT/var
/run
133 LSFILE
=`find $DESTROOT/run -mindepth 1 -maxdepth 1 -print -quit 2> /dev/null`
134 #mv doesn't move hidden files (.*|the dot char started filenames)
135 [ ! -z "$LSFILE" ] && mv $DESTROOT/run
/* $DESTROOT/var
/run
140 if [ -e $DESTROOT/var
/run
]; then
141 echo "###### PKG_SCRIPT $PKG /var/run"
142 if ! rmdir $DESTROOT/var
/run
2> /dev
/null
; then
143 (ODIR
=`pwd`; cd $DESTROOT/var
/run
&& _mkcpio
$ODIR/_scripts
/$PKG@run.
cpio)
144 rm -rf $DESTROOT/var
/run
2> /dev
/null
145 if [ ! -e _scripts
/$PKG.inst_end.sh
]; then
146 echo 'rm -rf $DESTROOT/var/run 2> /dev/null' > _scripts
/$PKG.inst_end.sh
148 sh
/bin
/_add_linefeed.sh _scripts
/$PKG.inst_end.sh
149 ! grep -qFx 'rm -rf $DESTROOT/var/run 2> /dev/null' _scripts
/$PKG.inst_end.sh
&& \
150 echo 'rm -rf $DESTROOT/var/run 2> /dev/null' >> _scripts
/$PKG.inst_end.sh
156 #remove created links (symbolic links to put some files into other directory)
157 rm -f $DESTROOT/usr
/share
/info
/dir
158 rm -f $DESTROOT/tools
/share
/info
/dir
162 rm $DESTROOT/usr
/info
163 rm $DESTROOT/usr
/lib64
165 for i
in $CREATEDIRS; do
166 rmdir $DESTROOT/$i 2> /dev
/null
170 #call package update script
171 [ -e _scripts
/$PKG.inst_end.sh
] && source _scripts
/$PKG.inst_end.sh
174 #update some special packages
175 if [ -e $DESTROOT/usr
/lib
/perl5
]; then
176 if [ -e _scripts
/perl.ver
]; then
177 PERL
=`cat _scripts/perl.ver`
178 rm -f $DESTROOT/usr
/lib
/perl
5/$PERL/x86_64-linux
/perllocal.pod
179 find $DESTROOT/usr
/lib
/perl
5/site_perl
/$PERL/x86_64-linux
/auto
-name ".packlist" -type f | \
180 xargs sed -i -n '/^\/usr\//p'
187 [ -e _scripts
/$PKG.inc
] && cp _scripts
/$PKG.inc _scripts
/$PKG.scr
190 #create update scripts for packages which may be replaced with busybox
191 if echo "$BUSYBOX_CHK" |
grep -q " $PKG "; then
192 #----run _lsexecs.sh earlyer
193 EXEC_FILES
=`sh /bin/_lsexecs.sh -l $DESTROOT | sort`
196 for i
in $EXEC_FILES; do
198 [ -z "$EXEC_VAR" ] && EXEC_VAR
="'$i'" || EXEC_VAR
="$EXEC_VAR '$i'"
201 echo "#INC#busybox-update" >> _scripts
/$PKG.scr
202 echo "#VAR#cmdlist=($EXEC_VAR)" >> _scripts
/$PKG.scr
206 #create mime-info's (raw) script
207 if [ -e "$DESTROOT/usr/share/mime" ]; then
208 echo "#INC#shared-mime-info" >> _scripts
/$PKG.scr
212 #create texinfo's (raw) script
213 TEXINFO
=`find $DESTROOT/usr/share/info -name "*.info*" -print -quit 2> /dev/null`
214 if [ -n "$TEXINFO" ]; then
216 cd $DESTROOT/usr
/share
/info
217 TI_FILES
=`ls *.info*`
220 for i
in $TI_FILES; do
221 [ -z "$TI_VAR" ] && TI_VAR
="'$i'" || TI_VAR
="$TI_VAR '$i'"
225 echo "#INC#texinfo" >> _scripts
/$PKG.scr
226 echo "#VAR#filelist=($TI_VAR)" >> _scripts
/$PKG.scr
230 #create package user related files
231 F_PASSWD
="$BUILDROOT/tmp_passwd"
232 F_GROUP
="$BUILDROOT/tmp_group"
234 if [ -e _scripts
/$PKG.users
]; then
235 cat _scripts
/$PKG.users | \
236 while read username uid group gid passwd home shell groups comment
; do
237 if [ "$group" != "-" ]; then
238 GRPID
=`grep "^${group}:" "$F_GROUP" | cut -d : -f 3`
239 if [ -z "$GRPID" ]; then
240 echo "**Group not found: ${group}**"
242 if ! echo "$processed" |
grep -q "^${group}$"; then
243 if ! echo "$SKIPGROUP" |
grep -q " $group "; then
244 echo "#PRI#addgroup -g $GRPID $group 2> /dev/null" >> _scripts
/$PKG.scr
245 echo "#POR#delgroup $group 2> /dev/null" >> _scripts
/$PKG.scr
247 [ -z "$processed" ] && processed
="$group" || processed
=`echo -ne "$processed\n$group"`
251 if [ "$groups" != "-" ]; then
255 GRPID
=`grep "^${i}:" "$F_GROUP" | cut -d : -f 3`
256 if [ -z "$GRPID" ]; then
257 echo "**Group not found: ${i}**"
259 if ! echo "$processed" |
grep -q "^${i}$"; then
260 if ! echo "$SKIPGROUP" |
grep -q " $i "; then
261 echo "#PRI#addgroup -g $GRPID $i 2> /dev/null" >> _scripts
/$PKG.scr
262 echo "#POR#delgroup $i 2> /dev/null" >> _scripts
/$PKG.scr
264 [ -z "$processed" ] && processed
="$i" || processed
=`echo -ne "$processed\n$i"`
271 cat _scripts
/$PKG.users | \
272 while read username uid group gid passwd home shell groups comment
; do
273 [ "$shell" != "-" ] && SHELL
="-s $shell" || SHELL
=
274 [ "$home" != "-" ] && HHOME
="-h $home" || HHOME
=
275 [ "$group" != "-" ] && GROUP
="-G $group" || GROUP
=
276 [ "$comment" != "-" -a ! -z "$comment" ] && COMMENT
="-g '$comment'" || COMMENT
=
277 if [ "$username" != "-" ]; then
278 USRID
=`grep "^${username}:" "$F_PASSWD" | cut -d : -f 3`
279 if [ -z "$USRID" ]; then
280 echo "**User not found: ${username}**"
282 echo "#PRI#adduser $HHOME $COMMENT $GROUP $SHELL -D -H -u $USRID $username 2> /dev/null" >> _scripts
/$PKG.scr
283 echo "#POR#deluser $username 2> /dev/null" >> _scripts
/$PKG.scr
284 if [ "$groups" != "-" ]; then
288 echo "#PRI#adduser $username $i 2> /dev/null" >> _scripts
/$PKG.scr
289 echo "#POR#delgroup $username $i 2> /dev/null" >> _scripts
/$PKG.scr
299 #create install files
300 if [ -e _scripts
/$PKG.scr
]; then
301 echo -n > _scripts
/$PKG.
install
302 if INC
=$
(grep "^#INC#" _scripts
/$PKG.scr
); then
306 INCVAL
=`echo "$i" | sed 's/^#INC#//'`
307 if [ -e _scripts
/scripts
/$INCVAL.scr
]; then
308 [ -z "$INCSCR" ] && INCSCR
="$INCVAL" || INCSCR
=`echo -ne "$INCSCR\n$INCVAL"`
314 grep "^#VAR#" _scripts
/scripts
/$i.scr |
sed 's/^#VAR#//' >> _scripts
/$PKG.
install
317 grep "^#VAR#" _scripts
/$PKG.scr |
sed 's/^#VAR#//' >> _scripts
/$PKG.
install
320 grep "^#PCD#" _scripts
/scripts
/$i.scr |
sed 's/^#PCD#//' >> _scripts
/$PKG.
install
323 echo "post_install() {" >> _scripts
/$PKG.
install
325 grep "^#POI#" _scripts
/scripts
/$i.scr |
sed 's/^#POI#//' >> _scripts
/$PKG.
install
327 grep "^#POI#" _scripts
/$PKG.scr |
sed 's/^#POI#//' >> _scripts
/$PKG.
install
328 echo "}" >> _scripts
/$PKG.
install
330 echo "post_upgrade() {" >> _scripts
/$PKG.
install
332 grep "^#POU#" _scripts
/scripts
/$i.scr |
sed 's/^#POU#//' >> _scripts
/$PKG.
install
334 grep "^#POU#" _scripts
/$PKG.scr |
sed 's/^#POU#//' >> _scripts
/$PKG.
install
335 echo "}" >> _scripts
/$PKG.
install
337 echo "post_remove() {" >> _scripts
/$PKG.
install
339 grep "^#POR#" _scripts
/scripts
/$i.scr |
sed 's/^#POR#//' >> _scripts
/$PKG.
install
341 grep "^#POR#" _scripts
/$PKG.scr |
sed 's/^#POR#//' >> _scripts
/$PKG.
install
342 echo "}" >> _scripts
/$PKG.
install
344 echo "pre_install() {" >> _scripts
/$PKG.
install
346 grep "^#PRI#" _scripts
/scripts
/$i.scr |
sed 's/^#PRI#//' >> _scripts
/$PKG.
install
348 grep "^#PRI#" _scripts
/$PKG.scr |
sed 's/^#PRI#//' >> _scripts
/$PKG.
install
349 echo "}" >> _scripts
/$PKG.
install
351 echo "pre_upgrade() {" >> _scripts
/$PKG.
install
353 grep "^#PRU#" _scripts
/scripts
/$i.scr |
sed 's/^#PRU#//' >> _scripts
/$PKG.
install
355 grep "^#PRU#" _scripts
/$PKG.scr |
sed 's/^#PRU#//' >> _scripts
/$PKG.
install
356 echo "}" >> _scripts
/$PKG.
install
358 echo "pre_remove() {" >> _scripts
/$PKG.
install
360 grep "^#PRR#" _scripts
/scripts
/$i.scr |
sed 's/^#PRR#//' >> _scripts
/$PKG.
install
362 grep "^#PRR#" _scripts
/$PKG.scr |
sed 's/^#PRR#//' >> _scripts
/$PKG.
install
363 echo "}" >> _scripts
/$PKG.
install
367 grep "^#VAR#" _scripts
/$PKG.scr |
sed 's/^#VAR#//' >> _scripts
/$PKG.
install
369 echo "post_install() {" >> _scripts
/$PKG.
install
370 grep "^#POI#" _scripts
/$PKG.scr |
sed 's/^#POI#//' >> _scripts
/$PKG.
install
371 echo "}" >> _scripts
/$PKG.
install
373 echo "post_upgrade() {" >> _scripts
/$PKG.
install
374 grep "^#POU#" _scripts
/$PKG.scr |
sed 's/^#POU#//' >> _scripts
/$PKG.
install
375 echo "}" >> _scripts
/$PKG.
install
377 echo "post_remove() {" >> _scripts
/$PKG.
install
378 grep "^#POR#" _scripts
/$PKG.scr |
sed 's/^#POR#//' |
tac >> _scripts
/$PKG.
install
379 echo "}" >> _scripts
/$PKG.
install
381 echo "pre_install() {" >> _scripts
/$PKG.
install
382 grep "^#PRI#" _scripts
/$PKG.scr |
sed 's/^#PRI#//' >> _scripts
/$PKG.
install
383 echo "}" >> _scripts
/$PKG.
install
385 echo "pre_upgrade() {" >> _scripts
/$PKG.
install
386 grep "^#PRU#" _scripts
/$PKG.scr |
sed 's/^#PRU#//' >> _scripts
/$PKG.
install
387 echo "}" >> _scripts
/$PKG.
install
389 echo "pre_remove() {" >> _scripts
/$PKG.
install
390 grep "^#PRR#" _scripts
/$PKG.scr |
sed 's/^#PRR#//' |
tac >> _scripts
/$PKG.
install
391 echo "}" >> _scripts
/$PKG.
install
394 grep -A 1 -n "() {$" _scripts
/$PKG.
install |
grep "^[0-9]\+-}$" |
sed "s/-}$//" | \
396 sed -i "$(expr $num - $anum)d" _scripts
/$PKG.
install
397 sed -i "$(expr $num - 1 - $anum)d" _scripts
/$PKG.
install
398 anum
=$
(expr $anum + 2)
403 #copy in (auto)generated cpio
404 if [ -e _scripts
/${PKG}@run.
cpio ]; then
405 mkdir
-p $DESTROOT/etc
/rundir
406 cp -Rdp _scripts
/${PKG}@run.
cpio $DESTROOT/etc
/rundir
408 #buildroot's sysvinit scripts()()
409 if [ -e $DESTROOT/etc
/init.d
]; then
410 [ "$PKG" != "openrc" ] && mv $DESTROOT/etc
/init.d
$DESTROOT/etc
/sysvinit.d
411 ####rm sysvinit runscript if there is
412 [ -e $DESTROOT/etc
/sysvinit.d
/rcS
] && rm $DESTROOT/etc
/sysvinit.d
/rcS
413 [ -e $DESTROOT/etc
/sysvinit.d
/rcK
] && rm $DESTROOT/etc
/sysvinit.d
/rcK
415 #execute permissions in /etc/profile.d
416 if [ -e $DESTROOT/etc
/profile.d
]; then
417 LSFILE
=`find $DESTROOT/etc/profile.d -mindepth 1 -maxdepth 1 -print -quit 2> /dev/null`
418 [ ! -z "$LSFILE" ] && chmod 755 $DESTROOT/etc
/profile.d
/*
422 #copy raw package files
423 #cp ... -p -> cp ... --preserve=mode,ownership (new timestamp)
424 [ -d _scripts
/files
/$PKG/etc
] && cp -Rdp _scripts
/files
/$PKG/etc
$DESTROOT
425 [ -d _scripts
/files
/$PKG/@
file ] && cp -Rdp _scripts
/files
/$PKG/@file
/* $DESTROOT
432 #make package info files
433 mkdir
-p $DESTROOT/var
/lib
/instpkg
/local
434 mkdir
-p $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV
435 mkdir
-p $DESTROOT/var
/lib
/instpkg
/local
/.
local
436 ln -sf ..
/$PKG-$VERSION-$REV $DESTROOT/var
/lib
/instpkg
/local
/.local
/$PKG
437 #----move diskusage to the end of the script
438 SIZE
=`du -sk $DESTROOT | grep -o "^[0-9]\+"`
440 if [ -e _scripts
/$PKG.desc
]; then
441 SHORT_DESC
=`cat _scripts/$PKG.desc`
444 echo -ne "NAME=$NAME\nVERSION=$VERSION\nREV=$REV\nDESC=\"$SHORT_DESC\"\nSIZE=$SIZE\n" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/info
445 #buildroot descriptions
446 #-description from python to python3
447 [ -e _scripts
/desc
/desc@
] && mv _scripts
/desc
/desc@
$DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc@
&& rm -rf _scripts
/desc
449 tar xzf _scripts
/files
/desc.
tar.gz
-C $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV desc
/$PKG.desc@
2> /dev
/null
450 [ -e $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc
/$PKG.desc@
] && \
451 mv $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc
/$PKG.desc@
$DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc@
452 rm -rf $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc
455 [ ! -e _scripts
/$PKG.deps
] && touch _scripts
/$PKG.deps
459 if [ -e _scripts
/$PKG.distdeps
]; then
460 sh
/bin
/_add_linefeed.sh _scripts
/$PKG.distdeps
461 cp _scripts
/$PKG.distdeps
$DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/distdeps
462 cat _scripts
/$PKG.distdeps
>> _scripts
/$PKG.deps
466 sort -u _scripts
/$PKG.deps
> $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/depends
467 cat $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/depends |
tr '\n' ' ' | \
468 sed 's% $%%' > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/depend@
469 [ -z "$GRP" ] && GRP
=`grep "package.*/$PKG/Config.in" package/_pkgs.group@@@@ | cut -d " " -f 1-2`
472 [ "$PKG" = "busybox" ] && GRP
="base system"
473 [ "$PKG" = "glibc" ] && GRP
="base development"
474 [ "$PKG" = "gcc" ] && GRP
="base development"
475 [ "$PKG" = "grub-dist" ] && GRP
="base system"
476 [ "$PKG" = "busybox-init" ] && GRP
="base system"
477 [ "$PKG" = "busybox-pwdutils" ] && GRP
="base system"
478 [ "$PKG" = "busybox-utils" ] && GRP
="base system"
479 [ "$PKG" = "busybox-dist" ] && GRP
="base system"
481 [ -z "$GRP" ] && GRP
="unknown other"
484 echo "$GRP" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/groups
486 [ -e _scripts
/$PKG.
install ] && cp -dp _scripts
/$PKG.
install $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/install
488 [ -e _scripts
/$PKG.keepdirs
] && cp -dp _scripts
/$PKG.keepdirs
$DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/keepdirs
490 LS_EXECS
=`sh /bin/_lsexecs.sh $DESTROOT | sort`
491 [ ! -z "$LS_EXECS" ] && echo "$LS_EXECS" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/execs
493 LS_DIRLINKS
=`sh /bin/_find_dirlinks.sh $DESTROOT | sort`
494 [ ! -z "$LS_DIRLINKS" ] && echo "$LS_DIRLINKS" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/dirlinks
498 (cd $DESTROOT; tar czf
$PKGDEST/$PKG-$VERSION-$REV.
tar.gz
*)
501 echo "$DONTINSTALL" |
grep -q " $PKG " ||
tar xzf
$PKGDEST/$PKG-$VERSION-$REV.
tar.gz
-C /
505 rm -f $BUILDROOT/inst_start.log