WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Package splitting script  (Read 4000 times)

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Package splitting script
« on: November 04, 2009, 10:52:37 PM »
Here is what has helped me with splitting large packages that contain a whole lot of files in them, as even careful manual moving can result in lost files.  When used, scripting takes away human error.  

It is assumed that you make install into "main", and "pkg" will be your regular non-development extension directory, and dev will be for the dev files.  After "make install DESTDIR=/path/to/main", create the directories pkg and dev from the directory that "main" exists in.  You should see with the ls command pkg, dev, and main in the directory you want to run the scripts.  Here is the first script to seperate the dev files.  Standard separation moves the *.h, *.a, *.pc, and *.la files into the -dev extension.  Here is the script to be run from the main directory right above pkg, main, and dev:

First copy all the packages contents into pkg:

cp -a main/. pkg/

Then run the script

Code: [Select]
#!/bin/sh

cd pkg

 for I in $(find `ls` -name *.h); do
export DIR=`dirname "$I"`;
[ -d ../dev/"$DIR" ] || mkdir -p ../dev/"$DIR";
mv "$I" ../dev/"$DIR"/;
done

 for I in $(find `ls` -name *.a); do
export DIR=`dirname "$I"`;
[ -d ../dev/"$DIR" ] || mkdir -p ../dev/"$DIR";
mv "$I" ../dev/"$DIR"/;
done

 for I in $(find `ls` -name *.la); do
export DIR=`dirname "$I"`;
[ -d ../dev/"$DIR" ] || mkdir -p ../dev/"$DIR";
mv "$I" ../dev/"$DIR"/;
done


 for I in $(find `ls` -name *.pc); do
export DIR=`dirname "$I"`;
[ -d ../dev/"$DIR" ] || mkdir -p ../dev/"$DIR";
mv "$I" ../dev/"$DIR"/;
done


This will create the needed directories in the dev directory and move the pertinent files there.  After that, you can check to make sure that all files made it into either the pkg or dev directory by running this script which checks against the main install directory:

Code: [Select]
#!/bin/sh

cd main # (or whatever your DESTDIR directory.)


for I in $(find `ls` -not -type d); do
[ -e ../pkg/"$I" ] || [ -e ../dev/"$I" ] || echo "$I" missing;
done

find . -type d | sort -r | xargs rmdir


If a file that is supposed to be in the extension is not in either pkg or dev directories, then the file will be echoed as missing.  

This kind of thing would not be needed for most extensions, but when repackaging python with it's 2093 files this script made the job so much easier.  Of course, you can pick and choose what type of files are to be moved, python took also the .pyc and .pyo filenames.
« Last Edit: December 06, 2009, 07:59:33 PM by Jason W »

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: Package splitting script
« Reply #1 on: November 29, 2009, 12:31:02 PM »
Adding `ls ` to the busybox find command gets an error.   Works without  `ls `. 
"find `ls` -name *.h"

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Package splitting script
« Reply #2 on: November 29, 2009, 12:32:51 PM »
Because that creates an invalid find command.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Package splitting script
« Reply #3 on: November 29, 2009, 02:58:14 PM »
Ok, I will look into it tonight.  Perhaps the findutils find should be a dependency.  Or using "find . -name *.h" may do the same.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: Package splitting script
« Reply #4 on: November 30, 2009, 02:03:28 AM »
Ok, I will look into it tonight.  Perhaps the findutils find should be a dependency.  Or using "find . -name *.h" may do the same.

Yes ....script works nicely with just busybox find.  I tried this with base-dev.tcz.  In the future, would you want to split something like this into two extensions?  Also,  when do you need "tczl" (this extension includes all the libs).

BTW/ I don't see /lib/{libblkid.so  libcom_err.so  libe2p.so  libext2fs.so  libss.so  libuuid.so} in the list file.
« Last Edit: November 30, 2009, 02:16:43 AM by jpeters »

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: Package splitting script
« Reply #5 on: November 30, 2009, 12:12:07 PM »
This seems to work
Code: [Select]
#!/bin/sh

for I in $(find -name *.a  && find -name *.la && find -name .*pc); do
   export DIR=`dirname "$I"` ;
   [ -d ../dev/"$DIR" ] || mkdir -p ../dev/"$DIR";
   mv "$I" ../dev/"$DIR"/;
done