DSL building tools


Forum: Apps
Topic: DSL building tools
started by: Felson

Posted by Felson on Jan. 26 2007,01:01
Ok, to start, there is very little work in these that I actualy did myself. I took cbaggers bed2dsl script, and split it into 2.

The first returns a list of files from all the deb files in the locations listed. The second builds a DSL file either from a list of file names. Either from a file passed in as a arg, or from stdin.

Then I made 2 scripts of my own. The first just makes a file in the tmp dir that has a time stamp. The second gives you a list of all files that have changed since you ran the first script.

Known bugs... If you untar something that writes it with its original dates, they will not be grabbed. I plan to write one that does an md5 on all of the file on the system to determan change instead, buttoday I was to lazy to make that. That said, this should be good for anything that is installed from source, as that makes new files. I "think" I grabbed everything that needs to be stored. If some of you can take a look, and see if I missed anything important, please let me know.

Here are the scripts.

dsl_debs
Code Sample

#!/bin/bash
#
#   dsl_debs  -  Returns a list of all files in all deb
# files in you home dir and the apt cache dir
#
# Revision: 1
# Date: 02/19/05
# Original Author: cbagger01 from the DSL forums
#
# Rev 1 - Removed leading . from dsl file listings and
#         removed .dsl from mydsl menu filename
#
# This script will grab all *.deb files located in your
# "Home" directory, IE: the /home/username  directory
# It will also grab all *.deb files located in your apt
# cache, IE: /var/cache/apt/archives
#
# Before running this script, you need to actually install
# all of your Debian packages using 'dpkg -i' or
# 'apt-get install' or a package manager like Synaptic.
# Do NOT delete your leftover *.deb files or purge your
# apt-cache until after you have finished running this
# script.
#
# Disclaimer:
# This script is just a file repackaging program that
# can be used for simple Debian packages.  It will not
# perform post-extraction configuration that is done
# by more sophisticated Debian packages.  It also cannot
# be used to upgrade packages from older versions
# that are part of the DSL livecd base installation.


# This script will not work if it is run under the 'root' effective
# user ID which is 0
if [ "$EUID" -eq "0" ]; then
echo "Do not use 'root' access to run this script. Aborting..."
exit 1
fi

# Start things out from the home directory so we won't get confused
cd $HOME

# Find all Debian packages in your home directory and grab the list of
# files that are contained inside each package.  Make sure that directory
# names are not grabbed.  Only file names will be added to the list.
# Remove leading . character from the filename list.
for i in $( ls $HOME/*.deb ); do
 dpkg -c  $i | awk '{ print substr($6,2) }' \
 | grep -v "\/$"
done

# Find all Debian packages in your apt cache directory and grab the list
# of files that are contained inside each package.  Make sure that
# directory names are not grabbed.  Only file names will be added to the
# list.
# Remove leading . character from the filename list.
for i in $( ls /var/cache/apt/archives/*.deb ); do
 dpkg -c  $i | awk '{ print substr($6,2) }' \
 | grep -v "\/$"
done

exit 0

Posted by Felson on Jan. 26 2007,01:03
dsl_make
Code Sample

#!/bin/bash
#
# dsl_from_list - given a list of files
#
# Revision: 1
# Date: 2007-01-25
# Original Author: cbagger01 from the DSL forums
#

# This script will not work if it is run under the 'root' effective
# user ID which is 0
if [ "$EUID" -eq "0" ]; then
echo "Do not use 'root' access to run this script. Aborting..."
exit 1
fi

# Clean up any leftover temp files if needed
rm -rf /tmp/dsl_prompt.tmp
rm /tmp/dsl_files.tmp

InFile=$1

#see if we passed a file name
if [ -z "$InFile" ]
then
 #if there is no file, try stdin
 while read i
   do
     echo $i >> /tmp/dsl_files.tmp
   done
else
 #if there is a file, use it.
 cat $InFile > /tmp/dsl_files.tmp
fi

# Start things out from the home directory so we won't get confused
cd $HOME
package_name=
whiptail --clear --nocancel \
--inputbox "Enter the full name for your DSL package Example: rox.dsl " \
20 74 2> /tmp/dsl_prompt.tmp
package_name=`cat /tmp/dsl_prompt.tmp`
rm -rf /tmp/dsl_prompt.tmp

menu_name=
whiptail --clear --nocancel \
--inputbox "Enter the myDSL menu name for your program Example: Rox Filer " \
20 74 2> /tmp/dsl_prompt.tmp
menu_name=`cat /tmp/dsl_prompt.tmp`
rm -rf /tmp/dsl_prompt.tmp

program_path=
whiptail --clear --nocancel \
--inputbox "Enter the executable name for your program Example: /usr/bin/rox " \
20 74 2> /tmp/dsl_prompt.tmp
program_path=`cat /tmp/dsl_prompt.tmp`
rm -rf /tmp/dsl_prompt.tmp

# Create the mydsl menu directory
mkdir /tmp/mydsl.menu

# Strip the .dsl characters from the end of the mydsl menu filename
menu_filename=`echo $package_name | sed "s/\.dsl//g"`

echo "Menu File Name: $menu_filename"

# Create the new mydsl menu item file
echo "[exec] ("$menu_name") {"$program_path"}" > /tmp/mydsl.menu/$menu_filename

# Add the mydsl menu file to the list of files that will be
# included into the new new dsl package
echo "/tmp/mydsl.menu/"$menu_filename >> /tmp/dsl_files.tmp

# Create the new DSL package
tar -zcvf $package_name -T /tmp/dsl_files.tmp -C /
rm /tmp/dsl_files.tmp
rm /tmp/mydsl.menu/$menu_filename
rm -r /tmp/mydsl.menu
exit 0



dsl_mark
Code Sample

#!/bin/bash

touch /tmp/dsl_start_mark


dsl_changes
Code Sample

#!/bin/bash
#
# dsl_source_build - Build a dsl file out of the differences
# to your system from when you ran 'dsl_mark_start'
#
# Revision: 1
# Date: 2007-01-25
# Original Author: Felson from the DSL forums
#
# Fist get anything you DO NOT want in your dsl file onto the
# system. Then run 'dsl_mark_start'. Install what you want into
# the system, test, and remove any junk that was made that you
# don't want in the dsl. Then run this script.

# Need to move to the root directory
cd /

# Build a list of all files
find /bin/ /dev/ /etc/ /lib/ /opt/ /sbin/ /sys/ /usr/ /var/ -print -newer /tmp/dsl_start_mark -type f 2> /dev/null
find /bin/ /dev/ /etc/ /lib/ /opt/ /sbin/ /sys/ /usr/ /var/ -print -newer /tmp/dsl_start_mark -type l 2> /dev/null
find /bin/ /dev/ /etc/ /lib/ /opt/ /sbin/ /sys/ /usr/ /var/ -print -newer /tmp/dsl_start_mark -type s 2> /dev/null
find /bin/ /dev/ /etc/ /lib/ /opt/ /sbin/ /sys/ /usr/ /var/ -print -newer /tmp/dsl_start_mark -type p 2> /dev/null

exit 0

Posted by Felson on Jan. 30 2007,23:34
Not that it looks like anyone is even intested in this code, But I finaly made the md5 check replacement for the 2 scripts I made.
For directories, they will only be listed if they are new.
For Symlinks they will be listed if they are new, datechanged or the file thy are linked to changed
For all other files they will be listed if they are new, there date has changed, or there MD5 hash changed.
Yes, if they are changed, the MD5 should have changed to. I added the date here because I like to "touch" files that I want included sometimes in the case of a script.
so, here are the 2 scripts:

dsl_mark
Code Sample

#!/bin/bash

> /tmp/dsl_start_mark
for i in $( find /bin/ /etc/ /lib/ /opt/ /sbin/ /sys/ /usr/ /var/ -print | sort | sed 's/ /\[sPaCe\]/g' ); do
# echo $i
File=`echo "$i" | sed 's/\[sPaCe\]/ /g'`
 if [ -d "$File" ]; then
   echo $File >> /tmp/dsl_start_mark
 elif [ -L "$File" ]; then
   LINK=`ls -l "$File" | awk '{print $11}'`
   DATE=`ls -l "$File" | awk '{print $6 " " $7 " " $8}'`
   echo $File "|$DATE|$LINK" >> /tmp/dsl_start_mark
 else
   MD5=`md5sum "$File" | awk '{print $1}'`
   DATE=`ls -l "$File" | awk '{print $6 " " $7 " " $8}'`
   echo $File "|$DATE|$MD5" >> /tmp/dsl_start_mark
 fi
done

exit 0


dsl_change
Code Sample

#!/bin/bash

> /tmp/dsl_end_mark
for i in $( find /bin/ /etc/ /lib/ /opt/ /sbin/ /sys/ /usr/ /var/ -print | sort | sed 's/ /\[sPaCe\]/g' ); do
# echo $i
 File=`echo "$i" | sed 's/\[sPaCe\]/ /g'`
 if [ -d "$File" ]; then
   echo $File >> /tmp/dsl_end_mark
 elif [ -L "$File" ]; then
   LINK=`ls -l "$File" | awk '{print $11}'`
   DATE=`ls -l "$File" | awk '{print $6 " " $7 " " $8}'`
   echo $File "|$DATE|$LINK" >> /tmp/dsl_end_mark
 else
   MD5=`md5sum "$File" | awk '{print $1}'`
   DATE=`ls -l "$File" | awk '{print $6 " " $7 " " $8}'`
   echo $File "|$DATE|$MD5" >> /tmp/dsl_end_mark
 fi
done

diff /tmp/dsl_end_mark /tmp/dsl_start_mark | grep "<" | awk '{print $2}' | awk -F\| '{print $1}'

exit 0

Posted by ^thehatsrule^ on Jan. 31 2007,02:32
Don't worry about lack of replies, there are a lot who just download and use code.
Even though I haven't read deeper into the code itself yet, I would suggest that you package these scripts for myDSL testing so that it would have more exposure.

Posted by roberts on Jan. 31 2007,03:30
I would rather see the effort go towards deb2unc than an alternative deb2dsl. Your touch file marker and find is the very approach I use when manually constructing many of the uncs.

Traditional hard drive installations already have the debian installation method leaving the liveCD and frugal. The .dsl is too ram and or inode intensive for many lower memory systems.

Posted by Felson on Jan. 31 2007,17:24
I agree with you on the UNC thing. I haven't yet spent the time to understand how they really work yet. I have just been useing the dsl2unc script. The one nice thing about .dsl files, is I can just use tar if I want to look inside it. But then, I admit to not having a clue how UNCs work just yet... :)
Posted by roberts on Jan. 31 2007,21:41
If you have down the concept of a file list and tar command, then just using the -C option to lay down the files other than /
say -C /home/mynewunc/  ... then using the mkisofs instead of tarring up the directory will produce the cloop of base system files and directories. The complexity of using unionfs is taken care of by the infratstructure within DSL. Not much different than constructing a .dsl. Of course the user.tar.gz is a mini tarball for optional menu and/or icon. The user.tar.gz is the same concept as I setup for uci extension.

Posted by Jason W on Mar. 11 2007,05:11
One thing I find that may prevent a quick and dirty way for me to change debs to unc is the lack of the functionality of the dpkg -x command in DSL.  That command seems to fail.  There are more mature ways of handling it I am sure, but not for simple minds like mine at the moment.

EDIT 3-18-07:  dpkg -x works fine, just not with wildcards.  I was used to using wildcards with the command.  But in DSL it works ok for single .debs.  Dpkg in Knoppix 3.7 is the same way.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.