Skip to content

Commit

Permalink
0.3
Browse files Browse the repository at this point in the history
Stable version
  • Loading branch information
zvezdochiot authored and mykaralw committed Jan 8, 2018
1 parent 0eb2e22 commit 080c631
Show file tree
Hide file tree
Showing 13 changed files with 1,045 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 zvezdochiot

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3
15 changes: 15 additions & 0 deletions control
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Package: bash-deb-build
Version: 0.3
Architecture: all
Maintainer: zvezdochiot <[email protected]>
Section: utils
Priority: optional
Installed-Size: 36
Depends: dpkg, grep, tar, gzip, coreutils, binutils
Homepage: http://mykaralw.narod.ru/
Description: Bash-script for build deb package.
Bash-script for build deb package:
build:
sudo bash-deb-build
unpack:
bash-deb-unpack package.deb
211 changes: 211 additions & 0 deletions deb-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
#!/bin/bash
#deb-build.sh

VER="0.3"
GREEN="\033[1;32m"
RED="\033[0;31m"
YELLOW="\033[1;33m"
ENDCOLOR="\033[0m"

DEFPACK="gzip"

tproc=`basename $0`
echo -e $GREEN"$tproc version $VER"$ENDCOLOR
echo ""

usage()
{
tproc=`basename $0`
echo -e $YELLOW"usage:"$ENDCOLOR
echo -e $GREEN" sudo bash $tproc [gzip|bzip2|lzma]"$ENDCOLOR
exit 0
}

goodfinish()
{
echo ""
echo -e $YELLOW"OK.\n"$ENDCOLOR
echo ""
}

testargs()
{
if [ "+$1" != "+" -a "+$1" != "+gzip" -a "+$1" != "+bzip2" -a "+$1" != "+lzma" ]
then
usage
fi
}

testcomponent()
{
tnocomp=""
tcomp="/bin/grep"
tdeb="grep_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/awk"
tdeb="gawk_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/bin/tar"
tdeb="tar_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/bin/gzip"
tdeb="gzip_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/md5sum"
tdeb="coreutils_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/ar"
tdeb="binutils_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
if [ "+$tnocomp" != "+" ]
then
echo -e $RED"Not found $tnocomp !"$ENDCOLOR
echo ""
exit 0
fi
}

testroot()
{
if [ $USER != root ]
then
echo -e $RED"You no root!"$ENDCOLOR
echo ""
usage
exit 0
fi
}

main()
{
if [ "+$1" = "+" ]
then
PACK=$DEFPACK
else
PACK="$1"
fi
if [ "$PACK" = "gzip" ]
then
PACKOPT="--gzip"
PACKSUF="tar.gz"
fi
if [ "$PACK" = "bzip2" ]
then
PACKOPT="--bzip2"
PACKSUF="tar.bz2"
fi
if [ "$PACK" = "lzma" ]
then
PACKOPT="--lzma"
PACKSUF="tar.lzma"
fi
if [ -d "config" -a -d "data" ]
then
mkdir "root"
cp -r "config" "root/control"
cp -r "data" "root/data"
cd "root"
chown -R root *
chgrp -R root *
cd "control"
rm -f "md5sums"
packname=`grep "^Package:" control | awk '{print $2}'`
vername=`grep "^Version:" control | awk '{print $2}'`
archname=`grep "^Architecture:" control | awk '{print $2}'`
debname=$packname"_"$vername"_"$archname".deb"
echo "$debname"

cd "../data"
echo "Package: $packname"
echo ""

echo "1) Compress contents of the package..."
tar -cvf "../data.tar" ./
echo ""
echo "SUMMARY:"
stat -c "%n : %s" "../data.tar"
echo ""
if [ "$PACK" = "gzip" ]
then
gzip -v "../data.tar"
fi
if [ "$PACK" = "bzip2" ]
then
bzip2 -v "../data.tar"
fi
if [ "$PACK" = "lzma" ]
then
lzma -v "../data.tar"
fi
echo ""

echo "2) Creating checksum..."
for tdir in *
do
if [ -d "$tdir" ]
then
find "$tdir" -type f -printf "\"%p\"\n" | xargs md5sum >> "../md5sums"
fi
done
cat "../md5sums"
echo ""

cd ../
mv -f "md5sums" "control"

cd control
echo "3) Compress of a package..."
tar -czvf "../control.tar.gz" ./
echo ""

cd ../
echo "4) Creating an index version packing deb package..."
echo "2.0" > "debian-binary"
cat "debian-binary"
echo ""

echo "5) Deb package assembly..."
ar -qS "$debname" "debian-binary" "control.tar.gz" "data.$PACKSUF"
cp "$debname" ../
cd ../
rm -fr root
echo ""
else
if [ ! -d "config" ]
then
echo "Not [config] packages!"
fi
if [ ! -d "data" ]
then
echo "Not [data] packages!"
fi
fi
}

testargs "$@"
testcomponent
testroot
main "$@"
goodfinish

#end


119 changes: 119 additions & 0 deletions deb-unpack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash
#deb-unpack.sh

VER="0.3"
GREEN="\033[1;32m"
RED="\033[0;31m"
YELLOW="\033[1;33m"
ENDCOLOR="\033[0m"

tproc=`basename $0`
echo -e $GREEN"$tproc version $VER"$ENDCOLOR
echo ""

usage()
{
tproc=`basename $0`
echo -e $YELLOW"usage:"$ENDCOLOR
echo -e $GREEN" bash $tproc packet.deb"$ENDCOLOR
exit 0
}

goodfinish()
{
echo ""
echo -e $YELLOW"OK.\n"$ENDCOLOR
echo ""
}

testargs()
{
if [ "+$1" = "+" -o "+$1" = "+--help" -o "+$1" = "+-h" ]
then
usage
fi
}

testcomponent()
{
tnocomp=""
tcomp="/bin/grep"
tdeb="grep_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/awk"
tdeb="base_CD1"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/bin/tar"
tdeb="tar_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/bin/gzip"
tdeb="gzip_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/md5sum"
tdeb="coreutils_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/ar"
tdeb="binutils_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
if [ "+$tnocomp" != "+" ]
then
echo -e $RED"Not found $tnocomp !"$ENDCOLOR
echo ""
exit 0
fi
}

testroot()
{
if [ $USER != root ]
then
echo -e $RED"You no root!"$ENDCOLOR
echo ""
usage
exit 0
fi
}

main()
{
tdeb="$1"
if [ -f "$tdeb" ]
then
echo "Unpack $tdeb..."
mkdir -p "config"
mkdir -p "data"
echo " config..."
dpkg -e "$tdeb" "./config"
echo " data..."
dpkg -x "$tdeb" "./data"
echo "OK."
fi
}

testargs "$@"
testcomponent
#testroot
main "$@"
goodfinish

#end


Binary file added example/bash-deb-build/bash-deb-build_0.3_all.deb
Binary file not shown.
15 changes: 15 additions & 0 deletions example/bash-deb-build/config/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Package: bash-deb-build
Version: 0.3
Architecture: all
Maintainer: zvezdochiot <[email protected]>
Section: utils
Priority: optional
Installed-Size: 36
Depends: dpkg, grep, tar, gzip, coreutils, binutils
Homepage: http://mykaralw.narod.ru/
Description: Bash-script for build deb package.
Bash-script for build deb package:
build:
sudo bash-deb-build
unpack:
bash-deb-unpack package.deb
3 changes: 3 additions & 0 deletions example/bash-deb-build/config/md5sums
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
67acb21ed5eaf746338e545776ea3e62 usr/share/scripts/bash/deb-unpack.sh
5a2d6eec06ddea876015418902d5e079 usr/share/scripts/bash/deb-build.sh
9386fb1465342ba9b7660b72ea6dafda usr/share/resources/bash-deb-build/example.tar.gz
Loading

0 comments on commit 080c631

Please sign in to comment.