dir2pet 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. #!/bin/sh
  2. #Barry Kauler (c) Copyight 2007,2009 www.puppylinux.com
  3. #2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
  4. #This script will create a PET package.
  5. #Just create a directory with the name of the package, for example 'abiword-0.5.6'
  6. #and put what you want in it.
  7. #It should have abiword-0.5.6/usr/share/applications/abiword.desktop if the
  8. #application requires a menu entry, but if there isn't one this script will ask
  9. #some simple questions and create one.
  10. #This script will also create abiword-0.5.6/pet.specs, which has
  11. #some information useful to the Puppy Package Manager.
  12. #w476, w478 fixes to work with petspec.
  13. #w482 if preexisting pet.specs, read fields from it.
  14. #100201 improve reading of pet.specs
  15. #100303 fix bug detection arch-dependent pkg.
  16. #130305 rerwin: ensure package tmp directory, if any, has all permissions.
  17. #131122 support xz compressed pets (see installpkg.sh, pet2tgz)
  18. #131123 changed default to gzip, will change it back in a year or 2
  19. #141011 add command line args for unattended builds
  20. usage() {
  21. echo '
  22. -h|--help show this help
  23. -------------------------------------------------------------------------------
  24. Basic:
  25. <name-of-dir> the directory to be packaged. THIS IS THE PACKAGE.
  26. EXAMPLE:
  27. # dir2pet my_fun_game-0.1-i486
  28. -------------------------------------------------------------------------------
  29. Advanced:
  30. -s skip all questions - useful for package build scripts
  31. -p the directory of the program to be packaged. THIS IS THE PACKAGE.
  32. THE following options are only useful with the "-s" option.
  33. For best results, use as many as possible:
  34. Compression: (only use one, default if none chosen is "gz")
  35. -x use xz (high) compression
  36. -g use gz (low) compression
  37. Non-compulsory:
  38. -w="<description>" description of the application enclosed in "quotes"
  39. -d=<+deps> comma delimited dependencies, with prepended "+" sign
  40. -c=<Category> category of application; for package manager
  41. LIST of allowed Categories: (default: BuildingBlock)
  42. Desktop
  43. System
  44. Setup
  45. Utility
  46. Filesystem
  47. Graphic
  48. Document
  49. Business
  50. Personal
  51. Network
  52. Internet
  53. Multimedia
  54. Fun
  55. EXAMPLE
  56. # dir2pet -x -s -w="fun game" -d=+gtk+,+ffmpeg,+cairo -p=my_fun_game-0.1-i486
  57. '
  58. }
  59. comp=gz #default
  60. #parameters
  61. while [ $# != 0 ]; do
  62. I=1
  63. while [ $I -lt `echo $# | wc -c` ]; do
  64. case $1 in
  65. -x) comp=xz ;;
  66. -g) comp=gz ;;
  67. -s) skip=1 ;;
  68. -w=*) desc="`echo "$1"|cut -d '=' -f2`" ;;
  69. -d=*) deps=`echo $1|cut -d '=' -f2`;;
  70. -c=*) category=`echo $1|cut -d '=' -f2`;;
  71. -p=*) directory=`echo $1|cut -d '=' -f2`;;
  72. [a-z]*|[A-Z]*)dir=$1;;
  73. -h|--help|"") usage
  74. exit;;
  75. esac
  76. shift
  77. I=$(($I+1))
  78. done
  79. done
  80. ISDIR=$dir
  81. [ -z "$ISDIR" ] && dir=$directory
  82. if [ ! -d "$dir" ];then
  83. usage
  84. exit
  85. fi
  86. ADIR=$dir
  87. MYPID=${$}
  88. #split ADIR path/filename into components...
  89. BASEPKG="`basename $ADIR`"
  90. DIRPKG="`dirname $ADIR`"
  91. [ "$DIRPKG" = "/" ] && DIRPKG=""
  92. #w482 directory may already have a pet.specs, reuse it...
  93. NAMEONLY=""
  94. PUPMENUDESCR=""
  95. PUPOFFICIALDEPS=""
  96. PUPCATEGORY=""
  97. PUPPATH="" #100201
  98. ARCHDEPENDENT="yes" #100201
  99. DEFREPO="" #100201
  100. if [ -f ${1}/pet.specs ];then
  101. #new: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|
  102. #optionally on the end: compileddistro|compiledrelease|repo| (fields 11,12,13)
  103. PETSPECS="`cat ${1}/pet.specs | head -n 1`"
  104. DB_pkgname="`echo -n "$PETSPECS" | cut -f 1 -d '|'`"
  105. DB_nameonly="`echo -n "$PETSPECS" | cut -f 2 -d '|'`"
  106. NAMEONLY="$DB_nameonly"
  107. DB_version="`echo -n "$PETSPECS" | cut -f 3 -d '|'`"
  108. DB_pkgrelease="`echo -n "$PETSPECS" | cut -f 4 -d '|'`"
  109. DB_category="`echo -n "$PETSPECS" | cut -f 5 -d '|'`"
  110. PUPCATEGORY="$DB_category"
  111. DB_size="`echo -n "$PETSPECS" | cut -f 6 -d '|'`"
  112. DB_path="`echo -n "$PETSPECS" | cut -f 7 -d '|'`"
  113. PUPPATH="$DB_path" #100201
  114. DB_fullfilename="`echo -n "$PETSPECS" | cut -f 8 -d '|'`"
  115. DB_dependencies="`echo -n "$PETSPECS" | cut -f 9 -d '|'`"
  116. PUPOFFICIALDEPS="$DB_dependencies"
  117. DB_description="`echo -n "$PETSPECS" | cut -f 10 -d '|'`"
  118. PUPMENUDESCR="$DB_description"
  119. DB_compileddistro="`echo -n "$PETSPECS" | cut -f 11 -d '|'`"
  120. DB_compiledrelease="`echo -n "$PETSPECS" | cut -f 12 -d '|'`"
  121. ARCHDEPENDENT="${DB_compileddistro}|${DB_compiledrelease}"
  122. DB_repo="`echo -n "$PETSPECS" | cut -f 13 -d '|'`"
  123. DEFREPO="$DB_repo"
  124. fi
  125. #difficult task, separate package name from version part...
  126. #not perfect, some start with non-numeric version info...
  127. [ "$NAMEONLY" = "" ] && NAMEONLY="`echo -n "$BASEPKG" | sed -e 's/\-[0-9].*$//g'`"
  128. #...if that fails, do it the old way...
  129. [ "$NAMEONLY" = "$BASEPKG" ] && NAMEONLY="`echo "$BASEPKG" | cut -f 1 -d "-"`"
  130. # comp
  131. if [ "$skip" != 1 ];then
  132. clear
  133. echo "Welcome to the 'dir2pet' script."
  134. echo "This will convert a directory into a PET package. Example, you have a "
  135. echo "directory named 'abiword-0.5.6' and inside that you place whatever is"
  136. echo "needed for the package, for example usr/local/bin/abiword (the executable)"
  137. echo "and usr/share/applications/abiword.desktop (the XDG menu file)."
  138. echo "Whatever the packages needs, though don't worry if there is no .desktop"
  139. echo "file as this script will ask some simple questions and optionally create"
  140. echo "one. The package only needs a .desktop file if a menu entry is to be"
  141. echo "created, and also an icon is required for the menu."
  142. echo
  143. echo "The directory $BASEPKG must separate name of the package and"
  144. echo "version number with a dash. Ex: abiword-0.5.6"
  145. echo
  146. echo "The package may optionally have post-install and post-remove scripts,"
  147. echo "named 'pinstall.sh' and 'puninstall.sh' placed at the top directory."
  148. echo "(to create official PETs for the Unleashed suite, see its README file"
  149. echo " for more information how to create these scripts properly)"
  150. echo
  151. echo "If any of the above needs to be further sorted out, you can quit this"
  152. echo "script right now by pressing CTRL-C, otherwise just press ENTER"
  153. arch=`uname -m`
  154. default=xz char="g" other=gzip
  155. [ "${arch:0:3}" = "arm" ] && default=gzip char="x" other=xz
  156. echo "to use the default \"$default\" compression or \"$char\" then ENTER for "
  157. echo "\"$other\" compression."
  158. echo -n "Press ENTER key or \"$char\" and ENTER to continue: "
  159. read goforit
  160. case $goforit in
  161. x)EXT="xz"
  162. echo
  163. echo "xz compression chosen."
  164. sleep 1;;
  165. g)EXT="gz"
  166. echo
  167. echo "gzip compression chosen."
  168. sleep 1;;
  169. *)EXT="${default:0:2}" ;;
  170. esac #131122, 131123, 140715
  171. else
  172. EXT=$comp
  173. fi
  174. # end comp
  175. . /etc/xdg/menus/hierarchy #has PUPHIERARCHY variable.
  176. DESKTOPFILE=""
  177. ADESKTOPFILE="`find $ADIR -type f -name \*.desktop`"
  178. [ "$ADESKTOPFILE" != "" ] && DESKTOPFILE="yes"
  179. if [ "$skip" != 1 ];then
  180. echo
  181. echo -en "\\033[1;31mStep 1" #red
  182. echo -e "\\033[0;39m"
  183. if [ "$DESKTOPFILE" = "" ];then
  184. echo "Currently there is no .desktop file (they are usually at usr/share/applications"
  185. echo "or usr/local/share/applications), so perhaps this package is not supposed to"
  186. echo "have a menu entry? You can optionally create one though..."
  187. echo "If you know that the ${BASEPKG} application does not require"
  188. echo "a menu entry, press the ENTER key only."
  189. echo "If a menu entry is required, type any printable character then ENTER."
  190. echo "(if in doubt, just press ENTER key)"
  191. echo -n "Type a printable character or just ENTER key: "
  192. read YESMENU
  193. [ "$YESMENU" = "" ] && DESKTOPFILE="ignore"
  194. else #w476
  195. echo "A .desktop file was found here:"
  196. echo "$ADESKTOPFILE"
  197. echo "So this application will have a menu entry."
  198. echo "If you want to change the .desktop file in any way, open it in a text editor"
  199. echo "right now, before proceeding and make any changes you want."
  200. echo "In particular, check that the icon exists, and that 'Category' entry fits"
  201. echo "into Puppy's menu hierarchy (see file /etc/xdg/menus/hierarchy)."
  202. echo "After satisfying yourself that the .desktop file is ok, press the ENTER key"
  203. echo "to continue this script."
  204. echo "Or, type 'ignore' to build pet pkg as if there is no .desktop file."
  205. echo "Or, type 'new' if you would like this script to ask a series of"
  206. echo -n "questions and rebuild the .desktop file from scratch: "
  207. read NEWMENU
  208. [ "$NEWMENU" = "ignore" ] && DESKTOPFILE="ignore" #w478
  209. if [ "$NEWMENU" = "new" ];then
  210. for ONEDESKTOP in $ADESKTOPFILE
  211. do
  212. BASEDESK="`basename $ONEDESKTOP .desktop`"
  213. DIRDESK="`dirname $ONEDESKTOP`"
  214. echo "Moving ${DIRDESK}/${BASEDESK}.desktop to /tmp"
  215. mv -f ${DIRDESK}/${BASEDESK}.desktop /tmp/
  216. done
  217. DESKTOPFILE=""
  218. fi
  219. fi
  220. PUPAPPLICATION=""
  221. PUPEXECUTABLE=""
  222. PUPICON16=""
  223. PUPAPPLICATION=""
  224. if [ "$DESKTOPFILE" = "yes" ];then #w476
  225. #get some info out of it...
  226. FIRSTDESKTOPFILE="`echo -n "$ADESKTOPFILE" | head -n 1`"
  227. PUPCATEGORY="`cat $FIRSTDESKTOPFILE | grep '^Categories=' | cut -f 2 -d '='`"
  228. PUPEXECUTABLE="`cat $FIRSTDESKTOPFILE | grep '^Exec=' | cut -f 2 -d '='`"
  229. PUPICON16="`cat $FIRSTDESKTOPFILE | grep '^Icon=' | cut -f 2 -d '='`"
  230. PUPMENUDESCR="`cat $FIRSTDESKTOPFILE | grep '^Comment=' | cut -f 2 -d '='`"
  231. [ "$PUPMENUDESCR" = "" ] && PUPMENUDESCR="`cat $FIRSTDESKTOPFILE | grep '^Name=' | cut -f 2 -d '='`"
  232. [ "$PUPMENUDESCR" = "" ] && PUPMENUDESCR="`cat $FIRSTDESKTOPFILE | grep '^GenericName=' | cut -f 2 -d '='`"
  233. fi
  234. if [ "$DESKTOPFILE" = "" ];then
  235. echo
  236. echo -en "\\033[1;31mStep 1B" #red
  237. echo -e "\\033[0;39m"
  238. echo "Please type the category in which you want the application"
  239. echo "to create a window manager menu entry. The official Puppy"
  240. echo "has a menu hierarchy as follows:"
  241. echo "('X-' categories are unofficial, Puppy-specific)"
  242. echo "$PUPHIERARCHY"
  243. echo
  244. echo -n "Type one word from the CATEGORIES column: "
  245. read PUPCATEGORY
  246. echo
  247. echo -en "\\033[1;31mStep 1C" #red
  248. echo -e "\\033[0;39m"
  249. echo "Please enter the name of the executable. If it is in the"
  250. echo "executable-search-path, namely /bin, /sbin, /usr/bin,"
  251. echo "/usr/sbin, /root/my-applications/bin or /usr/local/bin,"
  252. echo "then you only need to enter the name of the executable"
  253. echo "not the path. Example: mtpaint"
  254. echo "(of course, if you need to specify the path here, it is"
  255. echo " the path AFTER the package is installed)"
  256. echo
  257. echo -n "Enter [path]executable: "
  258. read PUPEXECUTABLE
  259. echo
  260. echo -en "\\033[1;31mStep 1D" #red
  261. echo -e "\\033[0;39m"
  262. echo "Please enter the name of the icon that is to be used in"
  263. echo "the window manager menu entry."
  264. echo "It is preferred that you specify the full path."
  265. echo
  266. echo -n "Please type [path]icon: "
  267. read PUPICON16
  268. echo
  269. echo -en "\\033[1;31mStep 1E" #red
  270. echo -e "\\033[0;39m"
  271. echo "Please enter the name of the application, as you wish it to"
  272. echo "appear in the menu. It will be the first word in the menu entry."
  273. echo "Example: Abiword"
  274. echo
  275. echo -n "Type application name: "
  276. read PUPAPPLICATION
  277. fi
  278. if [ "$PUPMENUDESCR" = "" ];then #w476
  279. echo
  280. echo -en "\\033[1;31mDescription" #red
  281. echo -e "\\033[0;39m"
  282. echo "Please enter a description of 1-3 words."
  283. if [ "$DESKTOPFILE" = "" ];then
  284. echo "This must be extremely short. as it will appear in the window"
  285. echo "manager menu entry immediately after the application name."
  286. fi
  287. echo "This may be used for various purposes, such by PETget for package"
  288. echo "management purposes."
  289. echo "Example for Abiword: powerful wordprocessor"
  290. echo
  291. echo -n "Type the VERY SHORT description (without quotes): "
  292. read PUPMENUDESCR
  293. echo
  294. fi
  295. #if pkg is a split-off, already has a known dependency...
  296. DEPBASE="";DEPNOTE=""
  297. [ ! "`echo -n "$NAMEONLY" | grep '_DEV'`" = "" ] && DEPBASE="+`echo -n "$NAMEONLY" | sed -e 's/_DEV//g'`"
  298. [ ! "`echo -n "$NAMEONLY" | grep '_DOC'`" = "" ] && DEPBASE="+`echo -n "$NAMEONLY" | sed -e 's/_DOC//g'`"
  299. [ ! "`echo -n "$NAMEONLY" | grep '_NLS'`" = "" ] && DEPBASE="+`echo -n "$NAMEONLY" | sed -e 's/_NLS//g'`"
  300. if [ ! "$DEPBASE" = "" ];then
  301. DEPNOTE="NOTE5: It is strongly suggested that you at least enter ${DEPBASE}
  302. the main package
  303. "
  304. fi
  305. if [ "$PUPOFFICIALDEPS" = "" ];then
  306. echo
  307. echo -en "\\033[1;31mDependencies" #red
  308. echo -e "\\033[0;39m"
  309. echo "Please enter a dependency-list for the PET package that is now being"
  310. echo "created. Packages already built-in to Puppy do not need to be"
  311. echo "explicitly named as dependencies (except a cut-down barebones version"
  312. echo "of Puppy may not have all of these built in, so you may have to"
  313. echo "think of the worst-case situation)."
  314. echo "How to enter this dependency-list is shown by an example: the package"
  315. echo "'pupdvdtool-0.5b' has the following dependency list:"
  316. echo "+vamps,+vobcopy,+ffmpeg,+dvdauthor,+gtkdialog3"
  317. echo "Each package name is preceded by a '+' and delimited by a ','."
  318. echo "NOTE1: that 'gtkdialog3' requires the GTK libraries, but it is not"
  319. echo " necessary to specify sub-dependencies, as if 'gtkdialog3'"
  320. echo " needs to be installed it has its own dependency list."
  321. echo "NOTE2: You can lookup the dependency-list of each package in the"
  322. echo " /root/.packages/Packages-* database files"
  323. echo "NOTE3: it is not required to specify package version numbers,"
  324. echo " VERSION NUMBERS NOT YET SUPPORTED BY PACKAGE MANAGER"
  325. echo "NOTE4: If you don't know what to specify, just press ENTER key"
  326. echo " (the package manager will still do some basic dependency checking)"
  327. echo "$DEPNOTE"
  328. echo -n "Type dependency-list: "
  329. read PUPOFFICIALDEPS
  330. fi
  331. echo
  332. echo -en "\\033[1;31mGUI window" #red
  333. echo -e "\\033[0;39m"
  334. #create tarball...
  335. rm -f $DIRPKG/${BASEPKG}.tar 2>/dev/null
  336. rm -f $DIRPKG/${BASEPKG}.tar.${EXT} 2>/dev/null
  337. rm -f $DIRPKG/${BASEPKG}.pet 2>/dev/null
  338. if [ "$DESKTOPFILE" = "" ];then
  339. mkdir -p $DIRPKG/$BASEPKG/usr/share/applications
  340. echo '[Desktop Entry]' > $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop
  341. echo 'Encoding=UTF-8' >> $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop
  342. echo "Name=${PUPAPPLICATION} ${PUPMENUDESCR}" >> $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop
  343. echo "Icon=${PUPICON16}" >> $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop
  344. echo "Comment=${PUPAPPLICATION} ${PUPMENUDESCR}" >> $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop
  345. echo "Exec=${PUPEXECUTABLE}" >> $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop
  346. echo "Terminal=false" >> $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop
  347. echo "Type=Application" >> $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop
  348. echo "Categories=${PUPCATEGORY}" >> $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop
  349. echo "GenericName=${PUPAPPLICATION} ${PUPMENUDESCR}" >> $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop
  350. echo
  351. echo "File $DIRPKG/$BASEPKG/usr/share/applications/${NAMEONLY}.desktop created."
  352. echo
  353. fi
  354. #100201 determine if pkg is ditro-independent (scripts only)...
  355. ARCHINDEPENDENT='yes'
  356. for ONEEXEC in `find $DIRPKG/$BASEPKG -maxdepth 6 -type f -perm -o+x`
  357. do
  358. [ -f $ONEEXEC ] && [ "`file $ONEEXEC | grep ' ELF '`" != "" ] && ARCHINDEPENDENT='no'
  359. done
  360. [ "`find $DIRPKG/$BASEPKG -maxdepth 6 -type f -name '*.a' -o -type f -name 'lib*.so*' -o -type f -name '*.la'`" != "" ] && ARCHINDEPENDENT='no' #100303
  361. #[ "`echo "${BASEPKG}" | grep '_DEV'`" != "" ] && ARCHINDEPENDENT='no' #100303
  362. [ "$ARCHINDEPENDENT" = "yes" ] && ARCHDEPENDENT='no'
  363. echo "Press ENTER key to bring up a GUI window that will help you to create"
  364. echo "a database entry for the package. This will be shown in a text editor"
  365. echo "for saving somewhere, also written to file 'pet.specs' inside the pkg."
  366. echo -n "Press ENTER: "
  367. read enternow
  368. fi
  369. SIZEK="`du -s -k $DIRPKG/$BASEPKG | cut -f 1`" #w476
  370. if [ "$skip" != 1 ];then
  371. [ "${PUPCATEGORY}" = "" ] && PUPCATEGORY="EMPTY"
  372. #if PUPCATEGORY is in format 'entry1;entry2;' extract only 'entry2'...
  373. xPUPCATEGORY="`echo -n "$PUPCATEGORY" | tr ';' ' ' | tr -s ' ' | sed -e 's% $%%' | rev | cut -f 1 -d ' ' | rev`"
  374. TOPCAT="`echo "$PUPHIERARCHY" | grep "$xPUPCATEGORY" | cut -f 1 -d ' ' | head -n 1`"
  375. [ "${TOPCAT}" = "" ] && TOPCAT="EMPTY"
  376. [ "${PUPOFFICIALDEPS}" = "" ] && PUPOFFICIALDEPS="EMPTY"
  377. [ -z "${PUPMENUDESCR}" ] && PUPMENUDESCR="EMPTY"
  378. [ "${PUPPATH}" = "" ] && PUPPATH="EMPTY" #100201
  379. [ "${DEFREPO}" = "" ] && DEFREPO="EMPTY" #100201
  380. echo "a${NAMEONLY}" "b${TOPCAT}" "c${PUPOFFICIALDEPS}" "d${PUPMENUDESCR}" "e$BASEPKG" "f$SIZEK" "g$PUPPATH" "h$ARCHDEPENDENT" "i$DEFREPO"
  381. petspec "${NAMEONLY}" "${TOPCAT}" "${PUPOFFICIALDEPS}" "${PUPMENUDESCR}" "$BASEPKG" "$SIZEK" "$PUPPATH" "$ARCHDEPENDENT" "$DEFREPO" #100201
  382. if [ $? -ne 0 ];then
  383. echo "Aborted creation of PET package."
  384. exit
  385. fi
  386. else
  387. . /etc/DISTRO_SPECS
  388. PUPOFFICIALDEPS="$deps"
  389. TOPCAT="$category"
  390. [ -z "$TOPCAT" ] && TOPCAT=BuildingBlock
  391. PUPMENUDESCR="$desc"
  392. [ -z "${PUPMENUDESCR}" ] && PUPMENUDESCR="No description provided"
  393. xPATTERN="s%${NAMEONLY}%%"
  394. VERSION="`echo -n "$BASEPKG" | sed -e "$xPATTERN" -e 's%^\\-%%'`"
  395. ARCHINDEPENDENT='yes'
  396. for ONEEXEC in `find $DIRPKG/$BASEPKG -maxdepth 6 -type f -perm -o+x`
  397. do
  398. [ -f $ONEEXEC ] && [ "`file $ONEEXEC | grep ' ELF '`" != "" ] && ARCHINDEPENDENT='no'
  399. done
  400. [ "`find $DIRPKG/$BASEPKG -maxdepth 6 -type f -name '*.a' -o -type f -name 'lib*.so*' -o -type f -name '*.la'`" != "" ] && ARCHINDEPENDENT='no'
  401. [ "$ARCHINDEPENDENT" = "no" ] && COMPAT=$DISTRO_BINARY_COMPAT V=$DISTRO_COMPAT_VERSION
  402. echo "$BASEPKG|${NAMEONLY}|$VERSION||$TOPCAT|$SIZEK||${BASEPKG}.pet|$deps|$PUPMENUDESCR|$COMPAT|$V||" > /tmp/petspec_db_entry
  403. fi
  404. [ -d $DIRPKG/$BASEPKG/tmp ] && chmod 1777 $DIRPKG/$BASEPKG/tmp #130305 rerwin.
  405. cat /tmp/petspec_db_entry | tail -n 1 > $DIRPKG/$BASEPKG/pet.specs
  406. echo
  407. echo "Creating package..."
  408. tar -c -f $DIRPKG/${BASEPKG}.tar $DIRPKG/$BASEPKG/
  409. sync
  410. case $EXT in
  411. xz)xz -z -9 -e $DIRPKG/${BASEPKG}.tar ;;
  412. gz)gzip --best $DIRPKG/${BASEPKG}.tar ;;
  413. esac
  414. TARBALL="$DIRPKG/${BASEPKG}.tar.${EXT}"
  415. echo
  416. echo "File $DIRPKG/${BASEPKG}.tar.${EXT} created. Now converting to .pet..."
  417. FULLSIZE="`stat --format=%s ${TARBALL}`"
  418. MD5SUM="`md5sum $TARBALL | cut -f 1 -d ' '`"
  419. echo -n "$MD5SUM" >> $TARBALL
  420. sync
  421. mv -f $TARBALL $DIRPKG/${BASEPKG}.pet
  422. sync
  423. echo
  424. echo "${BASEPKG}.pet has been created. Finished."
  425. echo
  426. echo "If you look in ${BASEPKG} you will see the new '.specs' file."
  427. if [ "$DESKTOPFILE" = "" ];then
  428. echo "And in $BASEPKG/usr/share/applications/ the new '.desktop' file."
  429. fi
  430. echo "Directory $BASEPKG is now configured correctly as a PET package"
  431. echo "and in future you do not need to go through this script again."
  432. echo "You could manually edit the files if required, and create another"
  433. echo ".pet package just by doing this:"
  434. echo "# tar -c -f ${BASEPKG}.tar ${BASEPKG}/"
  435. case $EXT in
  436. xz)echo "# xz -z -9 -e ${BASEPKG}.tar" ;;
  437. gz)echo "# gzip --best ${BASEPKG}.tar" ;;
  438. esac
  439. echo "# tgz2pet ${BASEPKG}.tar.${EXT}"
  440. echo
  441. echo "dir2pet exited."
  442. ###END###