5 #/bin/_find_dirlinks.sh
8 #/run/... may be needed to add (pkg@run.cpio)
9 #_scripts/pkg.ver may be needed to add (git versions: 'N.N.N.{g}.[x].GITCOMMIT')
10 #_scripts/pkg.inc - package script added
11 #_scripts/pkg.keepdirs - directories not to remove
12 #_scripts/pkg.reqver - required version of other packages (if any)
13 #_scripts/pkg.distdeps - addon dependencies
14 #package/_pkgs.group@@@@
15 #---- -review "----" reamarked code "lines"
44 [ "$PKG" = "gcc-tgt" ] && PKG
=gcc
45 [ "$PKG" = "glibc-tgt" ] && PKG
=glibc
48 DONTINSTALL
=" skeleton toolchain toolchain-external toolchain-external-custom initscripts jpeg busybox coreutils "
49 DONTINSTALL2
=" getent jpeg toolchain-external toolchain-external-custom libgl libegl busybox mcookie libfm-extra "
51 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 "
53 echo "$DONTINSTALL2" |
grep -q " $PKG " && exit 0
55 DIRSCRIPT
=$
(cd $
(dirname "$0") && pwd -P)
60 DESTROOT
=output
/target
61 BUILDROOT
=output
/build
64 echo "###### PKG_SCRIPT $PKG $(cat $BUILDROOT/build-sysinit.log) $1 $2"
66 if [ "$1" = "start" ] && [ "$2" = "install-target" -o "$2" = "install-staging" ]; then
68 #install-staging - install-target
69 [ -e $BUILDROOT/inst_start.log
] && exit 0
70 touch $BUILDROOT/inst_start.log
72 rm -f _scripts
/$PKG.scr
76 for i
in $CREATEDIRS; do
79 ln -sf share
/doc
$DESTROOT/usr
/doc
80 ln -sf share
/man
$DESTROOT/usr
/man
81 ln -sf share
/info
$DESTROOT/usr
/info
82 ln -sf lib
$DESTROOT/usr
/lib64
83 ln -sf lib
$DESTROOT/lib64
85 [ -e _scripts
/$PKG.inst_start.sh
] && source _scripts
/$PKG.inst_start.sh
88 if [ "$1" = "end" ] && [ "$2" = "install-target" ]; then
89 source $BUILDROOT/.package_source
95 [ "$PKG" = "glibc" ] && NAME
="glibc"
96 [ "$PKG" = "gcc" ] && NAME
="gcc"
99 [ -e $BUILDROOT/.python_version
] && PYTHON_VER
=`cat $BUILDROOT/.python_version`
100 if [ ! -z "$PYTHON_VER" -a "$PYTHON_VER" = 3 ]; then
102 if echo "$PKG" |
grep -q "^python-"; then
103 NAME
=`echo "$PKG" | sed 's/^python-/python3-/'`
104 #buildroot description->
105 tar xzf _scripts
/files
/desc.
tar.gz
-C _scripts desc
/$PKG.desc@
2> /dev
/null
106 mv _scripts
/desc
/$PKG.desc@ _scripts
/desc
/desc@
107 #buildroot description<-
108 [ -e _scripts
/$PKG.desc
] && cp _scripts
/$PKG.desc _scripts
/$NAME.desc
109 [ -e _scripts
/$PKG.deps
] && cp _scripts
/$PKG.deps _scripts
/$NAME.deps
111 GRP
="development python3"
117 [ ! -e _scripts
/$PKG.
rev ] && echo 1 > _scripts
/$PKG.
rev
121 REV
=`cat _scripts/$PKG.rev`
122 [ -e _scripts
/$PKG.ver
] && VERSION
=`cat _scripts/$PKG.ver`
126 if [ -e $DESTROOT/var
/lock
]; then
127 mkdir
-p $DESTROOT/run
/lock
128 LSFILE
=`find $DESTROOT/var/lock -mindepth 1 -maxdepth 1 -print -quit 2> /dev/null`
129 #mv doesn't move hidden files (.*|the dot char started filenames)
130 [ ! -z "$LSFILE" ] && mv $DESTROOT/var
/lock
/* $DESTROOT/run
/lock
131 rmdir $DESTROOT/var
/lock
135 if [ -e $DESTROOT/run
]; then
136 mkdir
-p $DESTROOT/var
/run
137 LSFILE
=`find $DESTROOT/run -mindepth 1 -maxdepth 1 -print -quit 2> /dev/null`
138 #mv doesn't move hidden files (.*|the dot char started filenames)
139 [ ! -z "$LSFILE" ] && mv $DESTROOT/run
/* $DESTROOT/var
/run
144 if [ -e $DESTROOT/var
/run
]; then
145 echo "###### PKG_SCRIPT $PKG /var/run"
146 if ! rmdir $DESTROOT/var
/run
2> /dev
/null
; then
147 (ODIR
=`pwd`; cd $DESTROOT/var
/run
&& _mkcpio
$ODIR/_scripts
/$PKG@run.
cpio)
148 rm -rf $DESTROOT/var
/run
2> /dev
/null
149 if [ ! -e _scripts
/$PKG.inst_end.sh
]; then
150 echo 'rm -rf $DESTROOT/var/run 2> /dev/null' > _scripts
/$PKG.inst_end.sh
152 sh
/bin
/_add_linefeed.sh _scripts
/$PKG.inst_end.sh
153 ! grep -qFx 'rm -rf $DESTROOT/var/run 2> /dev/null' _scripts
/$PKG.inst_end.sh
&& \
154 echo 'rm -rf $DESTROOT/var/run 2> /dev/null' >> _scripts
/$PKG.inst_end.sh
160 #remove created links (symbolic links to put some files into other directory)
161 rm -f $DESTROOT/usr
/share
/info
/dir
162 rm -f $DESTROOT/tools
/share
/info
/dir
166 rm $DESTROOT/usr
/info
167 rm $DESTROOT/usr
/lib64
169 for i
in $CREATEDIRS; do
170 rmdir $DESTROOT/$i 2> /dev
/null
174 #call package update script
175 [ -e _scripts
/$PKG.inst_end.sh
] && source _scripts
/$PKG.inst_end.sh
178 #update some special packages
179 if [ -e $DESTROOT/usr
/lib
/perl5
]; then
180 if [ -e _scripts
/perl.ver
]; then
181 PERL
=`cat _scripts/perl.ver`
182 rm -f $DESTROOT/usr
/lib
/perl
5/$PERL/x86_64-linux
/perllocal.pod
183 find $DESTROOT/usr
/lib
/perl
5/site_perl
/$PERL/x86_64-linux
/auto
-name ".packlist" -type f | \
184 xargs sed -i -n '/^\/usr\//p'
191 [ -e _scripts
/$PKG.inc
] && cp _scripts
/$PKG.inc _scripts
/$PKG.scr
194 #create update scripts for packages which may be replaced with busybox
195 if echo "$BUSYBOX_CHK" |
grep -q " $PKG "; then
196 #----run _lsexecs.sh earlyer
197 EXEC_FILES
=`sh /bin/_lsexecs.sh -l $DESTROOT | sort`
200 for i
in $EXEC_FILES; do
202 [ -z "$EXEC_VAR" ] && EXEC_VAR
="'$i'" || EXEC_VAR
="$EXEC_VAR '$i'"
205 echo "#INC#busybox-update" >> _scripts
/$PKG.scr
206 echo "#VAR#cmdlist=($EXEC_VAR)" >> _scripts
/$PKG.scr
210 #create mime-info's (raw) script
211 if [ -e "$DESTROOT/usr/share/mime" ]; then
212 echo "#INC#shared-mime-info" >> _scripts
/$PKG.scr
216 #create texinfo's (raw) script
217 TEXINFO
=`find $DESTROOT/usr/share/info -name "*.info*" -print -quit 2> /dev/null`
218 if [ -n "$TEXINFO" ]; then
220 cd $DESTROOT/usr
/share
/info
221 TI_FILES
=`ls *.info*`
224 for i
in $TI_FILES; do
225 [ -z "$TI_VAR" ] && TI_VAR
="'$i'" || TI_VAR
="$TI_VAR '$i'"
229 echo "#INC#texinfo" >> _scripts
/$PKG.scr
230 echo "#VAR#filelist=($TI_VAR)" >> _scripts
/$PKG.scr
234 #create package user related files
235 F_PASSWD
="$BUILDROOT/tmp_passwd"
236 F_GROUP
="$BUILDROOT/tmp_group"
238 if [ -e _scripts
/$PKG.users
]; then
239 cat _scripts
/$PKG.users | \
240 while read username uid group gid passwd home shell groups comment
; do
241 if [ "$group" != "-" ]; then
242 GRPID
=`grep "^${group}:" "$F_GROUP" | cut -d : -f 3`
243 if [ -z "$GRPID" ]; then
244 echo "**Group not found: ${group}**"
246 if ! echo "$processed" |
grep -q "^${group}$"; then
247 if ! echo "$SKIPGROUP" |
grep -q " $group "; then
248 echo "#PRI#addgroup -g $GRPID $group 2> /dev/null" >> _scripts
/$PKG.scr
249 echo "#POR#delgroup $group 2> /dev/null" >> _scripts
/$PKG.scr
251 [ -z "$processed" ] && processed
="$group" || processed
=`echo -ne "$processed\n$group"`
255 if [ "$groups" != "-" ]; then
259 GRPID
=`grep "^${i}:" "$F_GROUP" | cut -d : -f 3`
260 if [ -z "$GRPID" ]; then
261 echo "**Group not found: ${i}**"
263 if ! echo "$processed" |
grep -q "^${i}$"; then
264 if ! echo "$SKIPGROUP" |
grep -q " $i "; then
265 echo "#PRI#addgroup -g $GRPID $i 2> /dev/null" >> _scripts
/$PKG.scr
266 echo "#POR#delgroup $i 2> /dev/null" >> _scripts
/$PKG.scr
268 [ -z "$processed" ] && processed
="$i" || processed
=`echo -ne "$processed\n$i"`
275 cat _scripts
/$PKG.users | \
276 while read username uid group gid passwd home shell groups comment
; do
277 [ "$shell" != "-" ] && SHELL
="-s $shell" || SHELL
=
278 [ "$home" != "-" ] && HHOME
="-h $home" || HHOME
=
279 [ "$group" != "-" ] && GROUP
="-G $group" || GROUP
=
280 [ "$comment" != "-" -a ! -z "$comment" ] && COMMENT
="-g '$comment'" || COMMENT
=
281 if [ "$username" != "-" ]; then
282 USRID
=`grep "^${username}:" "$F_PASSWD" | cut -d : -f 3`
283 if [ -z "$USRID" ]; then
284 echo "**User not found: ${username}**"
286 echo "#PRI#adduser $HHOME $COMMENT $GROUP $SHELL -D -H -u $USRID $username 2> /dev/null" >> _scripts
/$PKG.scr
287 echo "#POR#deluser $username 2> /dev/null" >> _scripts
/$PKG.scr
288 if [ "$groups" != "-" ]; then
292 echo "#PRI#adduser $username $i 2> /dev/null" >> _scripts
/$PKG.scr
293 echo "#POR#delgroup $username $i 2> /dev/null" >> _scripts
/$PKG.scr
303 #create install files
304 if [ -e _scripts
/$PKG.scr
]; then
305 echo -n > _scripts
/$PKG.
install
306 if INC
=$
(grep "^#INC#" _scripts
/$PKG.scr
); then
310 INCVAL
=`echo "$i" | sed 's/^#INC#//'`
311 if [ -e _scripts
/scripts
/$INCVAL.scr
]; then
312 [ -z "$INCSCR" ] && INCSCR
="$INCVAL" || INCSCR
=`echo -ne "$INCSCR\n$INCVAL"`
318 grep "^#VAR#" _scripts
/scripts
/$i.scr |
sed 's/^#VAR#//' >> _scripts
/$PKG.
install
321 grep "^#VAR#" _scripts
/$PKG.scr |
sed 's/^#VAR#//' >> _scripts
/$PKG.
install
324 grep "^#PCD#" _scripts
/scripts
/$i.scr |
sed 's/^#PCD#//' >> _scripts
/$PKG.
install
327 echo "post_install() {" >> _scripts
/$PKG.
install
329 grep "^#POI#" _scripts
/scripts
/$i.scr |
sed 's/^#POI#//' >> _scripts
/$PKG.
install
331 grep "^#POI#" _scripts
/$PKG.scr |
sed 's/^#POI#//' >> _scripts
/$PKG.
install
332 echo "}" >> _scripts
/$PKG.
install
334 echo "post_upgrade() {" >> _scripts
/$PKG.
install
336 grep "^#POU#" _scripts
/scripts
/$i.scr |
sed 's/^#POU#//' >> _scripts
/$PKG.
install
338 grep "^#POU#" _scripts
/$PKG.scr |
sed 's/^#POU#//' >> _scripts
/$PKG.
install
339 echo "}" >> _scripts
/$PKG.
install
341 echo "post_remove() {" >> _scripts
/$PKG.
install
343 grep "^#POR#" _scripts
/scripts
/$i.scr |
sed 's/^#POR#//' >> _scripts
/$PKG.
install
345 grep "^#POR#" _scripts
/$PKG.scr |
sed 's/^#POR#//' >> _scripts
/$PKG.
install
346 echo "}" >> _scripts
/$PKG.
install
348 echo "pre_install() {" >> _scripts
/$PKG.
install
350 grep "^#PRI#" _scripts
/scripts
/$i.scr |
sed 's/^#PRI#//' >> _scripts
/$PKG.
install
352 grep "^#PRI#" _scripts
/$PKG.scr |
sed 's/^#PRI#//' >> _scripts
/$PKG.
install
353 echo "}" >> _scripts
/$PKG.
install
355 echo "pre_upgrade() {" >> _scripts
/$PKG.
install
357 grep "^#PRU#" _scripts
/scripts
/$i.scr |
sed 's/^#PRU#//' >> _scripts
/$PKG.
install
359 grep "^#PRU#" _scripts
/$PKG.scr |
sed 's/^#PRU#//' >> _scripts
/$PKG.
install
360 echo "}" >> _scripts
/$PKG.
install
362 echo "pre_remove() {" >> _scripts
/$PKG.
install
364 grep "^#PRR#" _scripts
/scripts
/$i.scr |
sed 's/^#PRR#//' >> _scripts
/$PKG.
install
366 grep "^#PRR#" _scripts
/$PKG.scr |
sed 's/^#PRR#//' >> _scripts
/$PKG.
install
367 echo "}" >> _scripts
/$PKG.
install
371 grep "^#VAR#" _scripts
/$PKG.scr |
sed 's/^#VAR#//' >> _scripts
/$PKG.
install
373 echo "post_install() {" >> _scripts
/$PKG.
install
374 grep "^#POI#" _scripts
/$PKG.scr |
sed 's/^#POI#//' >> _scripts
/$PKG.
install
375 echo "}" >> _scripts
/$PKG.
install
377 echo "post_upgrade() {" >> _scripts
/$PKG.
install
378 grep "^#POU#" _scripts
/$PKG.scr |
sed 's/^#POU#//' >> _scripts
/$PKG.
install
379 echo "}" >> _scripts
/$PKG.
install
381 echo "post_remove() {" >> _scripts
/$PKG.
install
382 grep "^#POR#" _scripts
/$PKG.scr |
sed 's/^#POR#//' |
tac >> _scripts
/$PKG.
install
383 echo "}" >> _scripts
/$PKG.
install
385 echo "pre_install() {" >> _scripts
/$PKG.
install
386 grep "^#PRI#" _scripts
/$PKG.scr |
sed 's/^#PRI#//' >> _scripts
/$PKG.
install
387 echo "}" >> _scripts
/$PKG.
install
389 echo "pre_upgrade() {" >> _scripts
/$PKG.
install
390 grep "^#PRU#" _scripts
/$PKG.scr |
sed 's/^#PRU#//' >> _scripts
/$PKG.
install
391 echo "}" >> _scripts
/$PKG.
install
393 echo "pre_remove() {" >> _scripts
/$PKG.
install
394 grep "^#PRR#" _scripts
/$PKG.scr |
sed 's/^#PRR#//' |
tac >> _scripts
/$PKG.
install
395 echo "}" >> _scripts
/$PKG.
install
398 grep -A 1 -n "() {$" _scripts
/$PKG.
install |
grep "^[0-9]\+-}$" |
sed "s/-}$//" | \
400 sed -i "$(expr $num - $anum)d" _scripts
/$PKG.
install
401 sed -i "$(expr $num - 1 - $anum)d" _scripts
/$PKG.
install
402 anum
=$
(expr $anum + 2)
407 #copy in (auto)generated cpio
408 if [ -e _scripts
/${PKG}@run.
cpio ]; then
409 mkdir
-p $DESTROOT/etc
/rundir
410 cp -Rdp _scripts
/${PKG}@run.
cpio $DESTROOT/etc
/rundir
412 #buildroot's sysvinit scripts()()
413 if [ -e $DESTROOT/etc
/init.d
]; then
414 [ "$PKG" != "openrc" ] && mv $DESTROOT/etc
/init.d
$DESTROOT/etc
/sysvinit.d
415 ####rm sysvinit runscript if there is
416 [ -e $DESTROOT/etc
/sysvinit.d
/rcS
] && rm $DESTROOT/etc
/sysvinit.d
/rcS
417 [ -e $DESTROOT/etc
/sysvinit.d
/rcK
] && rm $DESTROOT/etc
/sysvinit.d
/rcK
419 #execute permissions in /etc/profile.d
420 if [ -e $DESTROOT/etc
/profile.d
]; then
421 LSFILE
=`find $DESTROOT/etc/profile.d -mindepth 1 -maxdepth 1 -print -quit 2> /dev/null`
422 [ ! -z "$LSFILE" ] && chmod 755 $DESTROOT/etc
/profile.d
/*
426 #copy raw package files
427 #cp ... -p -> cp ... --preserve=mode,ownership (new timestamp)
428 [ -d _scripts
/files
/$PKG/etc
] && cp -Rdp _scripts
/files
/$PKG/etc
$DESTROOT
429 [ -d _scripts
/files
/$PKG/@
file ] && cp -Rdp _scripts
/files
/$PKG/@file
/* $DESTROOT
436 #make package info files
437 mkdir
-p $DESTROOT/var
/lib
/instpkg
/local
438 mkdir
-p $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV
439 mkdir
-p $DESTROOT/var
/lib
/instpkg
/local
/.
local
440 ln -sf ..
/$PKG-$VERSION-$REV $DESTROOT/var
/lib
/instpkg
/local
/.local
/$PKG
441 #----move diskusage to the end of the script
442 SIZE
=`du -sk $DESTROOT | grep -o "^[0-9]\+"`
444 if [ -e _scripts
/$PKG.desc
]; then
445 SHORT_DESC
=`cat _scripts/$PKG.desc`
448 echo -ne "NAME=$NAME\nVERSION=$VERSION\nREV=$REV\nDESC=\"$SHORT_DESC\"\nSIZE=$SIZE\n" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/info
449 #buildroot descriptions
450 #-description from python to python3
451 [ -e _scripts
/desc
/desc@
] && mv _scripts
/desc
/desc@
$DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc@
&& rm -rf _scripts
/desc
453 tar xzf _scripts
/files
/desc.
tar.gz
-C $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV desc
/$PKG.desc@
2> /dev
/null
454 [ -e $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc
/$PKG.desc@
] && \
455 mv $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc
/$PKG.desc@
$DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc@
456 rm -rf $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/desc
459 [ ! -e _scripts
/$PKG.deps
] && touch _scripts
/$PKG.deps
463 if [ -e _scripts
/$PKG.distdeps
]; then
464 sh
/bin
/_add_linefeed.sh _scripts
/$PKG.distdeps
465 cp _scripts
/$PKG.distdeps
$DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/distdeps
466 cat _scripts
/$PKG.distdeps
>> _scripts
/$PKG.deps
470 sort -u _scripts
/$PKG.deps
> $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/depends
471 cat $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/depends |
tr '\n' ' ' | \
472 sed 's% $%%' > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/depend@
473 [ -z "$GRP" ] && GRP
=`grep "package.*/$PKG/Config.in" package/_pkgs.group@@@@ | cut -d " " -f 1-2`
476 [ "$PKG" = "busybox" ] && GRP
="base system"
477 [ "$PKG" = "glibc" ] && GRP
="base development"
478 [ "$PKG" = "gcc" ] && GRP
="base development"
479 [ "$PKG" = "grub-dist" ] && GRP
="base system"
480 [ "$PKG" = "busybox-init" ] && GRP
="base system"
481 [ "$PKG" = "busybox-pwdutils" ] && GRP
="base system"
482 [ "$PKG" = "busybox-utils" ] && GRP
="base system"
483 [ "$PKG" = "busybox-dist" ] && GRP
="base system"
485 [ -z "$GRP" ] && GRP
="unknown other"
488 echo "$GRP" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/groups
490 [ -e _scripts
/$PKG.
install ] && cp -dp _scripts
/$PKG.
install $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/install
492 [ -e _scripts
/$PKG.keepdirs
] && cp -dp _scripts
/$PKG.keepdirs
$DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/keepdirs
494 LS_EXECS
=`sh /bin/_lsexecs.sh $DESTROOT | sort`
495 [ ! -z "$LS_EXECS" ] && echo "$LS_EXECS" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/execs
497 LS_DIRLINKS
=`sh /bin/_find_dirlinks.sh $DESTROOT | sort`
498 [ ! -z "$LS_DIRLINKS" ] && echo "$LS_DIRLINKS" > $DESTROOT/var
/lib
/instpkg
/local
/$PKG-$VERSION-$REV/dirlinks
502 (cd $DESTROOT; tar czf
$PKGDEST/$PKG-$VERSION-$REV.
tar.gz
*)
505 echo "$DONTINSTALL" |
grep -q " $PKG " ||
tar xzf
$PKGDEST/$PKG-$VERSION-$REV.
tar.gz
-C /
509 rm -f $BUILDROOT/inst_start.log