WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: extension audit script  (Read 151185 times)

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: extension audit script
« Reply #15 on: October 19, 2009, 01:57:21 AM »
For running against a tce directory, "base norestore" would be the way to do it and then install coreutils into /tmp/tce.  I can drop the perl dependency as dos2unix is in base which I will use instead.  Stat was moved into coreutils so coreutils has to remain a dep.  

might add that it creates .list files in the tce dir (or wherever it's placed). 
« Last Edit: October 19, 2009, 02:26:03 AM by jpeters »

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: extension audit script
« Reply #16 on: October 19, 2009, 04:43:54 AM »
"fix" script
Here's a quick hack that fixed extension permissions in my tce dir.  eg, "fix gnumeric"

Finds extension in tce_dir and sets tce.menu, tce.installed. tce.icons  to root:staff/775.
Rebuilds and copies to tce_dir. Deletes  old md5 file.

Rerunning audit creates new md5
 
Code: [Select]
#!/bin/ash

TCEDIR="$(cat /opt/.tce_dir)"
[ -d /tmp/extract ] || sudo mkdir /tmp/extract
[ -d /tmp/work ] || sudo mkdir /tmp/work

cd ${TCEDIR}


APP="$(busybox find ${1}* | busybox grep -v .dep | busybox grep -v .txt | busybox grep -v .list )"  
if [ -z ${APP} ]; then
  echo "no match in tce dir"
  exit 1
fi
 

sudo mount ${APP} /tmp/extract -o loop,ro
sudo cp -Rp /tmp/extract/* /tmp/work
cd /tmp/work/usr/local
if [ -d tce.installed ]; then
   sudo chown -R root:staff tce.installed
   sudo chmod  775  tce.installed
   sudo chmod  644  tce.installed/*
fi
if [ -d tce.menu ]; then
   sudo chown -R root:staff tce.menu
   sudo chmod  775  tce.menu
   sudo chmod  644  tce.menu/* 
fi
if [ -d tce.icons ]; then
   sudo chown -R root:staff tce.icons
   sudo chmod  775  tce.icons
   sudo chmod  644  tce.icons/*
fi

cd /tmp/work
sudo mksquashfs  ./  /tmp/${APP}
sudo cp -p /tmp/${APP}  ${TCEDIR}


sudo rm ${TCEDIR}/${APP}.md5.txt


 

###### cleanup

sudo umount /tmp/extract
sudo rmdir /tmp/extract
sudo rm -R /tmp/work
sudo rm /tmp/${APP}

exit 0
« Last Edit: October 27, 2009, 03:16:26 AM by jpeters »

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: extension audit script
« Reply #17 on: October 19, 2009, 07:34:02 AM »
I will add a switch to prevent creating of list files as they would interfere with tce2tcz when run on the tce directory.  I didn't initially intend for this to be an audit tool for the tce directory but rather for extensions ready to be submitted.  But it does serve as a quick check for existing extensions in the tce dir especially in regards to the tce.installed thing.

I did use a "fix it" script on my mirror, using a check like in the audit script.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: extension audit script
« Reply #18 on: October 19, 2009, 10:56:56 AM »
I will add a switch to prevent creating of list files as they would interfere with tce2tcz when run on the tce directory.  I didn't initially intend for this to be an audit tool for the tce directory but rather for extensions ready to be submitted.  But it does serve as a quick check for existing extensions in the tce dir especially in regards to the tce.installed thing.

I did use a "fix it" script on my mirror, using a check like in the audit script.

I already altered update and load scripts in case people want them (only 4K for a record of extension files without an internet connection).

EDIT:  added 644 perm to tce/*
« Last Edit: October 27, 2009, 03:18:26 AM by jpeters »

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: extension audit script
« Reply #19 on: November 15, 2009, 08:17:50 PM »
Is this script still working with updated squashfs?  I tried it with a newly compiled dialog.tcz, and it complained that the file was corrupted, although it worked fine.  

edit:  seems to work after I rebooted and tried again.
« Last Edit: November 15, 2009, 08:20:04 PM by jpeters »

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: extension audit script
« Reply #20 on: November 21, 2009, 09:12:03 PM »
Updated to check for 4096 block size and echo a red error message on failing md5sum.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: extension audit script
« Reply #21 on: November 22, 2009, 02:16:04 AM »
Great tool, thanks!

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: extension audit script
« Reply #22 on: January 09, 2010, 08:01:15 PM »
Updated to check for unwanted appended data and recreate list files even if they are present.

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: extension audit script
« Reply #23 on: January 12, 2010, 02:26:39 PM »
How about auto editing the info file? this can be done for the size and the extension name...

Change Title field:
Code: [Select]
sed -i 's!^Title:.*$!Title:\t\t$F!' $F.info
Change Size field:
Code: [Select]
sed -i 's!^Size:.*$!Size:\t\t`du -h $F | cut -f 1`!' $F.info
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: extension audit script
« Reply #24 on: January 12, 2010, 02:53:19 PM »
Sure, I will add it in.

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: extension audit script
« Reply #25 on: January 20, 2010, 12:22:48 AM »
The squashfs block 4096 check needs to have unsquashfs, this check needs to be added
Code: [Select]
if [ ! -f /usr/local/tce.installed/squashfs-tools-4.0 ]; then
echo "Install squashfs-tools-4.0.tcz before proceeding."
exit 1
fi

The chown line for the tce* directories needs to have a sudo.

The -noappend flag can be added to the mksquashfs command and the rm line can be removed.
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: extension audit script
« Reply #26 on: January 27, 2010, 09:00:03 AM »
Thanks, I will work that in too.  Will get to both soon.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: extension audit script
« Reply #27 on: January 27, 2010, 09:42:43 AM »
Done

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: extension audit script
« Reply #28 on: March 06, 2010, 10:06:15 PM »
Added a check for missing entries in dep files.

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: extension audit script
« Reply #29 on: March 07, 2010, 04:44:15 AM »
 line 82: syntax error: unexpected "then" (expecting "done")
dCore user