woof-CE patch generator!

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

woof-CE patch generator!

#1 Post by mavrothal »

This is primarily for woof-CE puppy and puplet builders, but could also help anyone with some basic understanding and willing to contribute to woof-CE

Quite often changes are making it into woof-CE-build puppies that are "manual". ie changed into the final ISO root but not in the woof-CE repo. They are often "forgotten" and hard to trace at a latter point and do the corresponding changes in woof-CE, for the puppies to come. :wink:
So I made a script that will detect any changes in the testing branch of the woof-CE rootfs-skeleton code against a running puppy or the unmodified puppy SFS (when run with the "sfs" argument) and will create individual patches for each changed woof-CE file. These patches can be directly applied to the woof-CE git.

If you decide to do so please check the individual patches to make sure that are not kernel- or binary-compatibility-distro-specific.
Submit pull requests to woof-CE with individual or closely related patches. ie patches related "pup_event" is OK to go in one pull request. Patches to the (/usr, /lib, etc, folder of) "my_Super_puppy-007.iso" ( :twisted: ), is not.

So without further ado, here is the script

Code: Select all

#!/bin/bash
# A script to generate woof-CE patches against a running puppy (run without
# any arguments)  or the puppy.sfs (run with the 'sfs' argument).

Version=0.7

. /etc/DISTRO_SPECS
. /etc/rc.d/PUPSTATE

# Check if we are good to run
if [ "$(which git)" = "" ]; then
 Xdialog --title "Error" --msgbox \
 "Please install the devx sfs or just git from the repo." 0 0
 exit 1
fi
WDIR=$(pwd) # Should be just above your freshly cloned woof-CE git
if [ ! -d $WDIR/woof-CE ]; then
 Xdialog --title "Error" --msgbox \
 "This script should be in the same folder as the woof-CE git folder" 0 0
 exit 1
fi
GIT_BRANCH=$(cut -f3 -d'/' $WDIR/woof-CE/.git/HEAD)
if [ ! "$GIT_BRANCH" ]; then
 Xdialog --title "Error" --msgbox \
 "The woof-CE folder is not a git repo. Please clone the woof-CE git" 0 0
 exit 1
fi
if [ "$GIT_BRANCH" != "testing" ]; then
 Xdialog --title "Error" --msgbox \
 "Your woof-CE repo is not in the testing branch. Please run 'git checkout testing'" 0 0
 exit 1
fi
GIT_HEAD=$(cut -c 1-6 $WDIR/woof-CE/.git/refs/heads/testing)
REMOTE_HEAD=$(git ls-remote https://github.com/puppylinux-woof-CE/woof-CE.git |
 grep 'refs/heads/testing' | cut -c 1-6)
if [ "$REMOTE_HEAD" != "$GIT_HEAD" ]; then
 Xdialog --title "Error" --msgbox \
 "Your local repo is not in sysnc with the remote. Please run 'git pull --all'" 0 0
 exit 1
fi

if [ "$1" = "sfs" -a "$PUPMODE" = "2" ]; then
 Xdialog --title "Error" --msgbox \
 "There is no pup.sfs in full installs. Please run without the 'sfs' argument" 0 0
 exit 1
fi
# Make the patches
[ "$BUILD_FROM_WOOF" ] && FROMWOOF=_$(echo $BUILD_FROM_WOOF | cut -f 2 -d ';' | cut -c 1-6)
case "$1" in
 sfs) COMP_DIR=/initrd/pup_ro2
      PATCHES=woof_"$GIT_BRANCH""$GIT_HEAD"_patches_to_"$DISTRO_FILE_PREFIX"-"$DISTRO_VERSION"_sfs"$FROMWOOF"
 ;;
 *) COMP_DIR=
    PATCHES=woof_"$GIT_BRANCH""$GIT_HEAD"_patches_to_"$DISTRO_FILE_PREFIX"-"$DISTRO_VERSION""$FROMWOOF"
 ;;
esac
mkdir -p $WDIR/$PATCHES
rm -rf $WDIR/$PATCHES/*
DIRS=rootfs-skeleton
for i in $(ls woof-CE/woof-code/rootfs-packages/)
do
 DIRS="$DIRS rootfs-packages/$i"
done
for D in $DIRS
do
 FOLDER=woof-CE/woof-code/$D
 cd $WDIR/$FOLDER
 for f in $(find ./ -type f)
 do
 [ -f $COMP_DIR/$f ] && [ "$(diff -u -N $f $COMP_DIR/$f)" != "" ] \
  && diff -u -N $f $COMP_DIR/$f > $WDIR/$PATCHES/$(basename $f).patch
 done
 #exit 0 #Uncomment to check if compared correctly
 cd $WDIR/$PATCHES
 DS="$(echo $D | sed 's/\//\\\//')"
 sed -i "s/\-\-\-\ \.\//\-\-\-\ a\/woof\-code\/$DS\//" *
 if [ "$1" = "sfs" ]; then
  sed -i "s/\+\+\+\ \/initrd\/pup_ro2\/\.\//\+\+\+\ b\/woof\-code\/$DS\//" *
 else
  sed -i "s/\+\+\+\ \/\.\//\+\+\+\ b\/woof\-code\/$DS\//" *
 fi
done
# check init
INITPATH=$(echo "$PUPSFS" | cut -f 2 -d '/' | grep -v sfs)
mkdir -p /tmp/initfs
cd /tmp/initfs
gunzip -c /mnt/home/$INITPATH/initrd.gz | cpio -i
cd $WDIR/woof-CE/woof-code
HUGEINIT=$(ls /mnt/home/$INITPATH/*.sfs | grep -s zdrv)
if [ "$HUGEINIT" != "" ]; then
 diff -u huge_extras/init /tmp/initfs/init > $WDIR/$PATCHES/init.patch
 sed -i "s/\-\-\-\ /\-\-\-\ a\/\woof\-code\//" $WDIR/$PATCHES/init.patch
 sed -i "s/\+\+\+\ \/tmp\/initfs/\+\+\+\ b\/woof\-code\/huge_extras/" $WDIR/$PATCHES/init.patch
else
 diff -u boot/initrd-tree/init /tmp/initfs/init > $WDIR/$PATCHES/init.patch
 sed -i "s/\-\-\-\ /\-\-\-\ \woof\-code\//" $WDIR/$PATCHES/init.patch
 sed -i "s/\+\+\+\ \/tmp\/initfs/\+\+\+\ b\/woof\-code\/boot\/initrd\-tree0/" $WDIR/$PATCHES/init.patch
fi
rm -rf /tmp/initfs
# Move some patches to folders for easy reviewing
cd $WDIR/$PATCHES
mkdir binary_files SVGs defaults docs running desktop
for f in $( grep ^Binary * | cut -f 1 -d':')
do
  mv $f binary_files/
done
mv *.svg.patch SVGs/
mv default*.patch defaults/
mv *.rules.patch running/
mv {PUPSTATE,BOOTCONFIG,clock,current_month,issue,hosts,hostname,ld.so.conf,resolv.conf,profile}.patch running/
mv *.{htm,html,css,txt}.patch docs/
mv *.html.*.patch docs/
mv *.desktop.patch desktop/
rm -f messages.patch
cd $WDIR

# exit 0 #Uncomment to review if patches are OK FOR woof-CE
rm -f $WDIR/$PATCHES.tar.gz
tar cvzf $PATCHES.tar.gz $PATCHES/
exit 0
Copy it to a file, make it executable, place it in the directory that also contains your woof-CE git, and run it with or without the sfs argument.
If everything goes to plan should generate a folder with the patches and a tarball of this folder. The name should be indicative of your git state and your puppy name.
Attachments
make_woofCE_patches.sh.gz
version 0.7
(1.59 KiB) Downloaded 365 times
Last edited by mavrothal on Sun 18 Oct 2015, 05:42, edited 17 times in total.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#2 Post by mavrothal »

Image
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#3 Post by 01micko »

Sticky this one please Flash or it may get lost in the wash.
Puppy Linux Blog - contact me for access

User avatar
ASRI éducation
Posts: 3197
Joined: Sat 09 May 2009, 12:10
Location: France
Contact:

#4 Post by ASRI éducation »

This utility is a real good idea!
Projet ASRI éducation => [url=http://asri-education.org/]Association[/url] | [url=http://forum.asri-education.org/]Forum[/url] | [url=http://dl01.asri-education.org/]Dépôt[/url] | [url=http://kids.asri-education.org/]Espace kids[/url]

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#5 Post by mavrothal »

I revised the initial script a bit to version 0.2.
Add some more checks and organize some patches into folders for easier reviewing.

One "conceptual" problem I have if I should make it more automatic. ie instead of providing warning to actually get/fix whatever is needed. Also instead of a flat text file, supply it as a pet.
This may make it simple for anyone to use but at the same time is likely to generate a lot of irrelevant info instead of useful patches (running it against my local Tahr version it generates over 300 patches :shock:).
Any thoughts on this?
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#6 Post by bigpup »

If this really works and the developers will really support it.
Great idea.
running it against my local Tahr version it generates over 300 patches Shocked).
Any thoughts on this?
There has been a lot of bug fixes in Tahrpup 6.0 CE since it was first released.

Any of what you are seeing got to do with any of these?

05/04/2015 added radkys fbbox to quickpet
04/04/2015 fix for shutdownconfig ...rerwin & mavrothal
04/04/2015 fix for rc.shutdown ...gyro
30/03/2015 fix for Keyboard layout variant reseting after reboot ....dustedwax & bigpup
30/03/2015 fixed missing icons in file choosers ...ninaholic
30/03/2015 added findnrun ...SFR
30/03/2015 updated getflash ...ASRI éducation
22/03/2015 updated pupclockset, urxvtcontrol & pupsysinfo ...radky
21/03/2015 updated openssl & libssl
21/03/2015 google music manager in quickpet needed libqtwebkit ...aleoleilani & sonny
18/03/2015 added sticky-jwm in destop menu ....recobayu
18/03/2015 added puppylinux search plugin to palemoon (find in menu in search bar)....Geoffrey
14/03/2025 updated PPM to 2 ...mavrothal
11/03/2015 add clear search field button in PPM ...mavrothal
07/03/2015 updated PPM to 2.0 ...mavrothal
05/03/2015 getflash broken as adobe changed url ...barry k
02/03/2015 updated PPM to 1.9.7 ...mavrothal
02/03/2015 changed pidgin package in quickpet as previous one would not connect to google
01/03/2015 added evince-previewer symlink for gnumeric....charlie6
01/03/2015 updated PPM to 1.9.6 ...mavrothal
23/02/2015 updated 7z & rar wrappers for xarchive that give warning when trying to extract encrypted files (problem in 6.0 only) ...dustedwax & SFR
20/02/2015 updated video_upgrade_wizard
20/02/2015 added graphic drivers for tahrpup6.0.2
19/02/2015 fix /usr/share/icons/hicolcor spelling mistake ....Hesse James
19/02/2015 updated pidgin in quickpet ... vicmz
19/02/2015 added pgprs ... rerwin
19/02/2015 hacks-postinstall.sh google-chrome, added 'chmod 755 /initrd/pup_rw' as google-chrome messes with permissions, this fixes the cups problem but there may still be other issues
15/02/2015 added missing samba tng menu entry
13/02/2015 fix for radio4 in pup radio
13/02/2015 updated to latest PPM 1.9.5 ...mavrothal & zigbert
11/02/2015 added fixes for chrome, iron & kde to hacks-postinstall (note that google chrome messes up file folder permissions!)
11/02/2015 updated to latest PPM ...mavrothal & zigbert

the following are in servicepack 6.0 - 6.0.2

11/02/2015 added webchemy browser art
11/02/2015 added droid font
11/02/2015 added urxvt control ..radky
11/02/2015 updated pfind ...zigbert
11/02/2015 updated PPM ....thanks mavrothal & zigbert
11/02/2015 added update-mime-database for kde apps
11/02/2015 now a single update button in quickpet
11/02/2015 added wmctrl
11/02/2015 added p7zip full
11/02/2015 updated uxtract and packit ...sfr
20/01/2015 sfsget, new scrollable and resizable gui ...'keyboard' http://murga-linux.com/puppy/viewtopic. ... 501#822501
20/01/2015 openssl & libssl updated to latest patched versions
17/01/2015 add srpos plugin for vlc to remember playback position
17/01/2015 added ca-certificates
16/01/2015 removed defunct unrar right click option ...dancytron
12/01/2015 sfs_load failed to grab urls ...Geoffrey
11/01/2015 alsamixer was exiting when pressing funtion keys, added script .... charlie6
08/01/2015 added vlc tunein radio plugin (hundreds of radio stations for vlc open vlc, click on 'view' then 'playlist' , scroll down to the internet section on the left and select TuneIn Radio. )
08/01/2015 xlock internationalized ...barry k & bigpup
07/01/2015 added https handler for xdg-open (needed by some apps)
07/01/2015 fixed spelling mistake in keyboard wizard ....Lefty Mills
26/12/2014 updated yassm .....augras
21/12/2014 fix for sfsget ..... packages got with sfsget weren't loading
18/12/2014 udev error messages ..edited rules and added libgphoto utopic ...wyzguy
17/12/2014 added right click set wallpaper
17/12/2014 added new tahrpup backgrounds ....futwerk
17/12/2014 added new gtk & jwm themes ...vicmz & CMB27
17/12/2014 drive_all improvements ...jlst
17/12/2014 update for quickpet
17/12/2014 added packit and UExtract ...SFR (these were meant to be in the iso)
17/12/2014 fix to remember screen brightness setting
17/12/2014 updated rox-filer, fixes quiet copy bug and proc bug
14/12/2014 input wizard fix. couldn't switch back to right handed mouse ...MochiMoppel & bigpup
14/12/2014 drive_all fix improve vcd detection ...jlst
26/11/2014 updated planner ...Cadejo
26/11/2014 fixed video upgrade wizard ...bigpup
26/11/2014 brightened up network tray icon ...rek769
21/11/2014 changed to rarings syslinux as installed one causing problems ...gjuhasz & rcrsn51
21/11/2014 drive_all fix improve dvd disc detection ...jlst
21/11/2014 sound card sometimes not initialised on slow computers, added script in /root/Startup/alsa ...jlst
21/11/2014 PPM said libqtwebkit was installed when not
21/11/2014 palemoon updater
16/11/2014 partview, top, startup-control and menumanager had nodisplay=true set in their .desktop files
16/11/2014 default audio player set to /opt/deadbeef/deadbeef instead of /usr/bin/deadbeef
14/11/2014 burniso2cd was missing menu entry ...Len E
13/11/2014 defaults-chooser spelling mistake in script line 204 ...bigpup
13/11/2014 deadbeef not working from terminal, made launcher script ...augras
13/11/2014 cups-pdf updated, older buggy one accidently in tahr ...rcrsn51
13/11/2014 icon switcher wrong url to forum ...bigpup
13/11/2014 jwm theme maker updated ...trio
13/11/2014 wakeupbug, fixes usb devices not working after suspend to ram...wyzguy
13/11/2014 perl errors in terminal, added a few lines to /root/.Xdefaults, this stops the tabs though
13/11/2014 libblas & liblapack symlinks, they needed symlinking /usr/lib as that's were they are looked for
01/11/2014 updated wget ... security issue
30/10/2014 legacy grub was missing ...ghead & rcrsn51
30/10/2014 added gnumeric help ...bigpup & peebee
30/10/2014 added sylpheed help ...peebee
30/10/2014 added mtpaint help ...bigpup
28/10/2014 added missing dir2targz right click
28/10/2014 going back to older pburn as newest missing dependencies ..bigpup & zigbert
27/10/2014 remasterpup2 fix for remastering with save to folder ...mavrothal
27/10/2014 pcur.desktop wasn't showing in menu ..bigpup & geoffrey
27/10/2014 getnvidia link in quickpet ..bigpup
27/10/2014 grub4dos menu entry ..bigpup
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#7 Post by mavrothal »

bigpup wrote:If this really works and the developers will really support it.
Great idea.
running it against my local Tahr version it generates over 300 patches Shocked).
Any thoughts on this?
There has been a lot of bug fixes in Tahrpup 6.0 CE since it was first released.

Any of what you are seeing got to do with any of these?
Why don't you run the script and let us know :wink:

BTW it can also work the other way around. To update your build with the latest in woof-CE. You must certainly backup your savefile/folder, before you try such a thing and be sure you understand what the patches do as many regard setting that are changed at build or runtime!
It should be useful for a puppy builder/developer or an "advanced" user, but certainly not for most.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#8 Post by zigbert »

thumbs up

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#9 Post by mavrothal »

Version 0.3 of the script also looks and compares with "rootfs-packages" files.
Currently this folder has just a couple of packages but hopefully many of the "noarch" scripts that are populating almost every puppy could be moved and maintained there :wink:
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
keyboard
Posts: 148
Joined: Sun 30 Nov 2014, 15:33

Great utility

#10 Post by keyboard »

I was looking for something exactly like this :D great utility :)

User avatar
keyboard
Posts: 148
Joined: Sun 30 Nov 2014, 15:33

Where is 'if'??

#11 Post by keyboard »

where is 'if' and 'fi' in the script ?? :shock:

version 0.4 ?? lol

Code: Select all

#!/bin/sh 
# A script to generate woof-CE patches against a running puppy. 

Version=0.4 

. /etc/DISTRO_SPECS 
# Check if we are good to run 

if [ "$(which git)" != "" ];then 
	Xdialog --title "Error" --msgbox "Please install the devx sfs or just git from the repo." exit 1
fi

WDIR=$(pwd)

if [ ! -d $WDIR/woof-CE ]; then 
	Xdialog --title "Error" --msgbox "This script should be in the same folder as the woof-CE git folder" exit 1 
fi

GIT_BRANCH=$(cut -f3 -d'/' $WDIR/woof-CE/.git/HEAD) 

if [ ! "$GIT_BRANCH" ]; then 
	Xdialog --title "Error" --msgbox  "The woof-CE folder is not a git repo. Please clone the woof-CE git" 0 exit 1 
fi

GIT_HEAD=$(cut -c 1-6 $WDIR/woof-CE/.git/refs/heads/testing) 

REMOTE_HEAD=$(git ls-remote https://github.com/puppylinux-woof-CE/woof-CE.git |  grep 'refs/heads/testing' | cut -c 1-6) 

if [ "$REMOTE_HEAD" != "$GIT_HEAD" ]; then 
	Xdialog --title "Error" --msgbox "Your local repo is not in sysnc with the remote. Please 'git pull --all'" exit 1 
fi

# Make the patches 
[ "$BUILD_FROM_WOOF" ] && FROMWOOF=_$(echo $BUILD_FROM_WOOF | cut -f 2 -d ';' | cut -c 1-6) 
PATCHES=woof_${GIT_BRANCH}${GIT_HEAD}_patches_to_$DISTRO_FILE_PREFIX-$DISTRO_VERSION$FROMWOOF 
COMP_DIR= #You could compare to any dir but the sed commands below need adjustment 
mkdir -p $WDIR/$PATCHES 
rm -rf $WDIR/$PATCHES/* 
DIRS=rootfs-skeleton 
for i in $(ls woof-CE/woof-code/rootfs-packages/) 
do 
 DIRS="$DIRS rootfs-packages/$i" 
done 
for D in $DIRS 
do 
 FOLDER=woof-CE/woof-code/$D 
 cd $WDIR/$FOLDER 
 for f in $(find ./ -type f) 
 do 
 [ "$(diff -u -N $f $COMP_DIR/$f)" != "" ] \ 
  && diff -u -N $f $COMP_DIR/$f > $WDIR/$PATCHES/$(basename $f).patch 
 done 
# exit 0 #Uncomment to check if compared correctly 
 cd $WDIR/$PATCHES 
 DS="$(echo $D | sed 's/\//\\\//')" 
 sed -i "s/\-\-\-\ \.\//\-\-\-\ a\/woof\-code\/$DS\//" * 
 sed -i "s/\+\+\+\ \/\.\//\+\+\+\ b\/woof\-code\/$DS\//" * 
done 
# Move some patches to folders for easy reviewing 
mkdir binary_files SVGs defaults docs running desktop 
for f in $( grep ^Binary * | cut -f 1 -d':') 
do 
  mv $f binary_files/ 
done 
mv *.svg.patch SVGs/ 
mv default*.patch defaults/ 
mv *.rules.patch running/ 
mv {PUPSTATE,BOOTCONFIG,clock,current_month,issue,hosts,hostname,ld.so.conf}.patch running/ 
mv *.{htm,html,css,txt}.patch docs/ 
mv *.html.*.patch docs/ 
mv *.desktop.patch desktop/ 
rm -f messages.patch 
cd $WDIR 

# exit 0 #Uncomment to review if patches are OK FOR woof-CE 
rm -f $WDIR/$PATCHES.tar.gz 
tar cvzf $PATCHES.tar.gz $PATCHES/ 
exit 0 

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

Re: Where is 'if'??

#12 Post by mavrothal »

keyboard wrote:where is 'if' and 'fi' in the script ?? :shock:

Version=0.4
"[ condition ] &&" is acceptable I believe and shorter :wink:
Any other changes to justify version bump?
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
keyboard
Posts: 148
Joined: Sun 30 Nov 2014, 15:33

#13 Post by keyboard »

lol , no it was causing problems for me:

look :-

Code: Select all

 
root# ./patch_check.sh
./patch_check.sh: line 9: Please install the devx sfs or just git from the repo.: command not found
./patch_check.sh: line 10: syntax error near unexpected token `&&'
./patch_check.sh: line 10: ` && exit 1 '
after using if - fi .. the output is in the image...

although there might be something else missing here too ...hmmm...
Attachments
capture21826.png
(101.94 KiB) Downloaded 545 times

User avatar
keyboard
Posts: 148
Joined: Sun 30 Nov 2014, 15:33

#14 Post by keyboard »

oh yes.. I had to edit line too...

Code: Select all

if [ "$(which git)" != "" ];then 
to

Code: Select all

if [ "$(which git)" == "" ];then 
hence the script:

Code: Select all

#!/bin/sh 
# A script to generate woof-CE patches against a running puppy. 

Version=0.4 #maybe ??

. /etc/DISTRO_SPECS 
# Check if we are good to run 

if [ "$(which git)" == "" ];then 
	Xdialog --title "Error" --msgbox "Please install the devx sfs or just git from the repo." exit 1
fi

WDIR=$(pwd)

if [ ! -d $WDIR/woof-CE ]; then 
	Xdialog --title "Error" --msgbox "This script should be in the same folder as the woof-CE git folder" exit 1 
fi

GIT_BRANCH=$(cut -f3 -d'/' $WDIR/woof-CE/.git/HEAD) 

if [ ! "$GIT_BRANCH" ]; then 
	Xdialog --title "Error" --msgbox  "The woof-CE folder is not a git repo. Please clone the woof-CE git" 0 exit 1 
fi

GIT_HEAD=$(cut -c 1-6 $WDIR/woof-CE/.git/refs/heads/testing) 

REMOTE_HEAD=$(git ls-remote https://github.com/puppylinux-woof-CE/woof-CE.git |  grep 'refs/heads/testing' | cut -c 1-6) 

if [ "$REMOTE_HEAD" != "$GIT_HEAD" ]; then 
	Xdialog --title "Error" --msgbox "Your local repo is not in sysnc with the remote. Please 'git pull --all'" exit 1 
fi

# Make the patches 
[ "$BUILD_FROM_WOOF" ] && FROMWOOF=_$(echo $BUILD_FROM_WOOF | cut -f 2 -d ';' | cut -c 1-6) 
PATCHES=woof_${GIT_BRANCH}${GIT_HEAD}_patches_to_$DISTRO_FILE_PREFIX-$DISTRO_VERSION$FROMWOOF 
COMP_DIR= #You could compare to any dir but the sed commands below need adjustment 
mkdir -p $WDIR/$PATCHES 
rm -rf $WDIR/$PATCHES/* 
DIRS=rootfs-skeleton 
for i in $(ls woof-CE/woof-code/rootfs-packages/) 
do 
 DIRS="$DIRS rootfs-packages/$i" 
done 
for D in $DIRS 
do 
 FOLDER=woof-CE/woof-code/$D 
 cd $WDIR/$FOLDER 
 for f in $(find ./ -type f) 
 do 
 [ "$(diff -u -N $f $COMP_DIR/$f)" != "" ] \ 
  && diff -u -N $f $COMP_DIR/$f > $WDIR/$PATCHES/$(basename $f).patch 
 done 
 exit 0 #Uncomment to check if compared correctly 
 cd $WDIR/$PATCHES 
 DS="$(echo $D | sed 's/\//\\\//')" 
 sed -i "s/\-\-\-\ \.\//\-\-\-\ a\/woof\-code\/$DS\//" * 
 sed -i "s/\+\+\+\ \/\.\//\+\+\+\ b\/woof\-code\/$DS\//" * 
done 
# Move some patches to folders for easy reviewing 
mkdir binary_files SVGs defaults docs running desktop 
for f in $( grep ^Binary * | cut -f 1 -d':') 
do 
  mv $f binary_files/ 
done 
mv *.svg.patch SVGs/ 
mv default*.patch defaults/ 
mv *.rules.patch running/ 
mv {PUPSTATE,BOOTCONFIG,clock,current_month,issue,hosts,hostname,ld.so.conf}.patch running/ 
mv *.{htm,html,css,txt}.patch docs/ 
mv *.html.*.patch docs/ 
mv *.desktop.patch desktop/ 
rm -f messages.patch 
cd $WDIR 

 exit 0 #Uncomment to review if patches are OK FOR woof-CE 
rm -f $WDIR/$PATCHES.tar.gz 
tar cvzf $PATCHES.tar.gz $PATCHES/ 
exit 0 

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#15 Post by mavrothal »

keyboard wrote:lol , no it was causing problems for me:

look :-

Code: Select all

 
root# ./patch_check.sh
./patch_check.sh: line 9: Please install the devx sfs or just git from the repo.: command not found
./patch_check.sh: line 10: syntax error near unexpected token `&&'
./patch_check.sh: line 10: ` && exit 1 '
after using if - fi .. the output is in the image...

although there might be something else missing here too ...hmmm...
This is more likely because you deleted (?) the backslash escape character ("") at the end of line 8. Lines 8, 9 and 10 are actually 1 line and the escape character instructs the script to ignore the following carriage return/newline.
This is a way to avoid the long and hard to read lines (even if they are very common in puppy :D ) but if you miss them you run into trouble.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
keyboard
Posts: 148
Joined: Sun 30 Nov 2014, 15:33

#16 Post by keyboard »

mavrothal wrote:
keyboard wrote:lol , no it was causing problems for me:

look :-

Code: Select all

 
root# ./patch_check.sh
./patch_check.sh: line 9: Please install the devx sfs or just git from the repo.: command not found
./patch_check.sh: line 10: syntax error near unexpected token `&&'
./patch_check.sh: line 10: ` && exit 1 '
after using if - fi .. the output is in the image...

although there might be something else missing here too ...hmmm...
This is more likely because you deleted (?) the backslash escape character ("") at the end of line 8. Lines 8, 9 and 10 are actually 1 line and the escape character instructs the script to ignore the following carriage return/newline.
This is a way to avoid the long and hard to read lines (even if they are very common in puppy :D ) but if you miss them you run into trouble.

No... there are backlash escape :roll:

here is the code of patch_check.sh

Code: Select all

#!/bin/sh 
# A script to generate woof-CE patches against a running puppy. 

Version=0.3 

. /etc/DISTRO_SPECS 
# Check if we are good to run 
[ "$(which git)" = "" ] && Xdialog --title "Error" --msgbox \ 
 "Please install the devx sfs or just git from the repo." 0 0\ 
 && exit 1 
WDIR=$(pwd) # Should be just above your freshly cloned woof-CE git 
[ ! -d $WDIR/woof-CE ] && Xdialog --title "Error" --msgbox \ 
 "This script should be in the same folder as the woof-CE git folder" 0 0\ 
 && exit 1 
GIT_BRANCH=$(cut -f3 -d'/' $WDIR/woof-CE/.git/HEAD) 
[ ! "$GIT_BRANCH" ] && Xdialog --title "Error" --msgbox \ 
 "The woof-CE folder is not a git repo. Please clone the woof-CE git" 0 0\ 
 && exit 1 
[ "$GIT_BRANCH" != "testing" ] && Xdialog --title "Error" --msgbox \ 
 "Your woof-CE repo is not in the testing branch. Please run 'git checkout testing'" 0 0\ 
 && exit 1 
GIT_HEAD=$(cut -c 1-6 $WDIR/woof-CE/.git/refs/heads/testing) 
REMOTE_HEAD=$(git ls-remote https://github.com/puppylinux-woof-CE/woof-CE.git | 
 grep 'refs/heads/testing' | cut -c 1-6) 
[ "$REMOTE_HEAD" != "$GIT_HEAD" ] && Xdialog --title "Error" --msgbox \ 
 "Your local repo is not in sysnc with the remote. Please 'git pull --all'" 0 0\ 
 && exit 1 

# Make the patches 
[ "$BUILD_FROM_WOOF" ] && FROMWOOF=_$(echo $BUILD_FROM_WOOF | cut -f 2 -d ';' | cut -c 1-6) 
PATCHES=woof_${GIT_BRANCH}${GIT_HEAD}_patches_to_$DISTRO_FILE_PREFIX-$DISTRO_VERSION$FROMWOOF 
COMP_DIR= #You could compare to any dir but the sed commands below need adjustment 
mkdir -p $WDIR/$PATCHES 
rm -rf $WDIR/$PATCHES/* 
DIRS=rootfs-skeleton 
for i in $(ls woof-CE/woof-code/rootfs-packages/) 
do 
 DIRS="$DIRS rootfs-packages/$i" 
done 
for D in $DIRS 
do 
 FOLDER=woof-CE/woof-code/$D 
 cd $WDIR/$FOLDER 
 for f in $(find ./ -type f) 
 do 
 [ "$(diff -u -N $f $COMP_DIR/$f)" != "" ] \ 
  && diff -u -N $f $COMP_DIR/$f > $WDIR/$PATCHES/$(basename $f).patch 
 done 
 exit 0 #Uncomment to check if compared correctly 
 cd $WDIR/$PATCHES 
 DS="$(echo $D | sed 's/\//\\\//')" 
 sed -i "s/\-\-\-\ \.\//\-\-\-\ a\/woof\-code\/$DS\//" * 
 sed -i "s/\+\+\+\ \/\.\//\+\+\+\ b\/woof\-code\/$DS\//" * 
done 
# Move some patches to folders for easy reviewing 
mkdir binary_files SVGs defaults docs running desktop 
for f in $( grep ^Binary * | cut -f 1 -d':') 
do 
  mv $f binary_files/ 
done 
mv *.svg.patch SVGs/ 
mv default*.patch defaults/ 
mv *.rules.patch running/ 
mv {PUPSTATE,BOOTCONFIG,clock,current_month,issue,hosts,hostname,ld.so.conf}.patch running/ 
mv *.{htm,html,css,txt}.patch docs/ 
mv *.html.*.patch docs/ 
mv *.desktop.patch desktop/ 
rm -f messages.patch 
cd $WDIR 

 exit 0 #Uncomment to review if patches are OK FOR woof-CE 
rm -f $WDIR/$PATCHES.tar.gz 
tar cvzf $PATCHES.tar.gz $PATCHES/ 
exit 0 
They are identical aren't they ?? :?

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#17 Post by mavrothal »

keyboard wrote: No... there are backlash escape :roll:

here is the code of patch_check.sh
<snip>
They are identical aren't they ?? :?
Yes they are. Any chance that thes cript went though a windows machine and saved there? Will change the "new line" characters.
Try to "cat -e <filename>" and check that actually there is a dollar sign ($) at the end of each line and certainly immediately after the backslashes. Make sure that there is not any space added.
BTW I did copy/paste what you have posted and works without any issue at my end :? :?
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#18 Post by Karl Godt »

test "`which git`" = "" && Xdialog "ERROR" && exit
does not work if Xdialog has errors or exits with non-zreo to actually exit the script .
and would happily run until the end .

It is bad and error prone coding style .

Some code in Puppy a frustrated user could call "malware" .

Take Care !
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

User avatar
keyboard
Posts: 148
Joined: Sun 30 Nov 2014, 15:33

#19 Post by keyboard »

mavrothal wrote: Yes they are. Any chance that thes cript went though a windows machine and saved there? Will change the "new line" characters.
Try to "cat -e <filename>" and check that actually there is a dollar sign ($) at the end of each line and certainly immediately after the backslashes. Make sure that there is not any space added.
BTW I did copy/paste what you have posted and works without any issue at my end :? :?
It didn't went through a windows PC. But I used a text editor which I usually use at long web developements(not in bash). Maybe that might be the issue here. There spaces between '\' and '$'

Code: Select all

root# cat -e  patch_check.sh
#!/bin/sh $
# A script to generate woof-CE patches against a running puppy. $
$
Version=0.3 $
$
. /etc/DISTRO_SPECS $
# Check if we are good to run $
[ "$(which git)" = "" ] && Xdialog --title "Error" --msgbox \ $
 "Please install the devx sfs or just git from the repo." 0 0\ $
 && exit 1 $
WDIR=$(pwd) # Should be just above your freshly cloned woof-CE git $
[ ! -d $WDIR/woof-CE ] && Xdialog --title "Error" --msgbox \ $
 "This script should be in the same folder as the woof-CE git folder" 0 0\ $
 && exit 1 $
GIT_BRANCH=$(cut -f3 -d'/' $WDIR/woof-CE/.git/HEAD) $
[ ! "$GIT_BRANCH" ] && Xdialog --title "Error" --msgbox \ $
 "The woof-CE folder is not a git repo. Please clone the woof-CE git" 0 0\ $
 && exit 1 $
[ "$GIT_BRANCH" != "testing" ] && Xdialog --title "Error" --msgbox \ $
 "Your woof-CE repo is not in the testing branch. Please run 'git checkout testing'" 0 0\ $
 && exit 1 $
GIT_HEAD=$(cut -c 1-6 $WDIR/woof-CE/.git/refs/heads/testing) $
REMOTE_HEAD=$(git ls-remote https://github.com/puppylinux-woof-CE/woof-CE.git | $
 grep 'refs/heads/testing' | cut -c 1-6) $
[ "$REMOTE_HEAD" != "$GIT_HEAD" ] && Xdialog --title "Error" --msgbox \ $
 "Your local repo is not in sysnc with the remote. Please 'git pull --all'" 0 0\ $
 && exit 1 $
$
# Make the patches $
[ "$BUILD_FROM_WOOF" ] && FROMWOOF=_$(echo $BUILD_FROM_WOOF | cut -f 2 -d ';' | cut -c 1-6) $
PATCHES=woof_${GIT_BRANCH}${GIT_HEAD}_patches_to_$DISTRO_FILE_PREFIX-$DISTRO_VERSION$FROMWOOF $
COMP_DIR= #You could compare to any dir but the sed commands below need adjustment $
mkdir -p $WDIR/$PATCHES $
rm -rf $WDIR/$PATCHES/* $
DIRS=rootfs-skeleton $
for i in $(ls woof-CE/woof-code/rootfs-packages/) $
do $
 DIRS="$DIRS rootfs-packages/$i" $
done $
for D in $DIRS $
do $
 FOLDER=woof-CE/woof-code/$D $
 cd $WDIR/$FOLDER $
 for f in $(find ./ -type f) $
 do $
 [ "$(diff -u -N $f $COMP_DIR/$f)" != "" ] \ $
  && diff -u -N $f $COMP_DIR/$f > $WDIR/$PATCHES/$(basename $f).patch $
 done $
 exit 0 #Uncomment to check if compared correctly $
 cd $WDIR/$PATCHES $
 DS="$(echo $D | sed 's/\//\\\//')" $
 sed -i "s/\-\-\-\ \.\//\-\-\-\ a\/woof\-code\/$DS\//" * $
 sed -i "s/\+\+\+\ \/\.\//\+\+\+\ b\/woof\-code\/$DS\//" * $
done $
# Move some patches to folders for easy reviewing $
mkdir binary_files SVGs defaults docs running desktop $
for f in $( grep ^Binary * | cut -f 1 -d':') $
do $
  mv $f binary_files/ $
done $
mv *.svg.patch SVGs/ $
mv default*.patch defaults/ $
mv *.rules.patch running/ $
mv {PUPSTATE,BOOTCONFIG,clock,current_month,issue,hosts,hostname,ld.so.conf}.patch running/ $
mv *.{htm,html,css,txt}.patch docs/ $
mv *.html.*.patch docs/ $
mv *.desktop.patch desktop/ $
rm -f messages.patch $
cd $WDIR $
$
 exit 0 #Uncomment to review if patches are OK FOR woof-CE $
rm -f $WDIR/$PATCHES.tar.gz $
tar cvzf $PATCHES.tar.gz $PATCHES/ $
exit 0 root# 
i will edit with vi and check if it works...

User avatar
keyboard
Posts: 148
Joined: Sun 30 Nov 2014, 15:33

#20 Post by keyboard »

no difference when using vi editor :(
Karl Godt wrote:test "`which git`" = "" && Xdialog "ERROR" && exit
does not work if Xdialog has errors or exits with non-zreo to actually exit the script .
and would happily run until the end .

It is bad and error prone coding style .

Some code in Puppy a frustrated user could call "malware" .

Take Care !
True, although it runs if i don't use && operator

Post Reply