/usr/bin/jablicator is in jablicator 1.0.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | #!/bin/sh
################################################
#
# This script generates an "apt-get"-able package.
# The package is empty and has a dependency for
# everything that's on the machine.
#
# Only include packages that are both installed
# and available from the apt sources. Do not
# include anything from Priority: required
#
################################################
set -e
BOX=`hostname --fqdn | tr '[:upper:]' '[:lower:]'`
ARCH=`dpkg-architecture -qDEB_BUILD_ARCH`
VER=`date +%Y%m%d`
HUMANDATE=`date +%m/%d/%Y`
PKGNAME=`echo jablicate-${BOX} | sed 's/\\./-/g'`
PKGDIR=${PKGNAME}-${VER}
LETTER=`echo ${PKGNAME} | cut -b-1`
DISTRO=debian-custom
DEB=${PKGNAME}_${VER}_all.deb
POOLDIR=pool/contrib/${LETTER}/${PKGNAME}
SRCDIR=dists/${DISTRO}/contrib/source
DISTDIR=dists/${DISTRO}/contrib/binary-${ARCH}
#######################################
# #
# Basic program flow #
# #
#######################################
# Handle command line arguments
parse_command_line() {
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--root) ROOT=$2
shift
;;
*) echo "Usage: jablicator [--root <path>]"
exit 1 ;;
esac
shift
done
}
# Guess at maintainer email
set_bang_maintainer() {
FIRST_PART=${USER}
SECOND_PART=`hostname --domain`
if [ "$SECOND_PART" = "" ]
then
SECOND_PART=`hostname`
fi
MAINTAINER="Collection Maintainer <${FIRST_PART}@${SECOND_PART}>"
}
# Make sure system is not completely broken
sanity_check() {
if [ "`hostname --fqdn`" = "" ]
then
echo "Error: hostname command is failing."
exit
fi
}
clean ()
{
rm -rf ${PKGDIR}
rm -f ${PKGNAME}_${VER}_${ARCH}.build
}
#######################################
# #
# Figure out the dependencies #
# #
#######################################
# Record apt-get sources
sources ()
{
cat $ROOT/etc/apt/sources.list | sed 's/\#.*$//g' | grep deb
}
# Packages that are installed
install_list ()
{
# It has been suggested that dpkg --getselections may be better than
# grepping through files with grep-dctrl. I haven't yet investigated
# this in detail, but I think grep-dctrl is at the right abstraction
# level.
grep-dctrl -v --field Priority required --exact-match \
$ROOT/var/lib/dpkg/status |\
grep-dctrl --field Status "install ok installed" --exact-match |\
grep-dctrl -v --field Package xfonts \
--no-field-names --show-field $1
}
# Packages available from apt sources
available_list ()
{
# Very annoying workaround for Debian bug #234657; I want to say -r .
grep-dctrl --no-field-names --show-field Package . \
$ROOT/var/lib/apt/lists/*Packages | sort -u
}
# Packages installed + packages available
monster_list ()
{
install_list "Package"
available_list
}
# Golden list of packages
list ()
{
monster_list | sort | uniq --repeated | grep -v ${PKGNAME} | sed 's/$/,/g'
}
#######################################
# #
# Creating the Debian package #
# #
#######################################
control ()
{
PACKAGES=`list`
echo Source: ${PKGNAME}
echo Section: admin
echo Priority: optional
echo "Maintainer: ${MAINTAINER}"
echo "Build-Depends: debhelper (>> 3.0.0)"
echo Standards-Version: 3.8.0
echo
echo Package: ${PKGNAME}
echo Architecture: all
echo Depends: ${PACKAGES}
echo Description: Replicate software collection on ${BOX}
echo " Replicate the software collection from ${BOX}"
echo " A software collection is simply the group of packages"
echo " installed on a particular machine."
echo " ."
echo " This package contains dependencies that may be "
echo " fulfilled from the following sources. Check to see if "
echo " they are present in your /etc/apt/sources.list."
echo " ."
sources | sed 's/^/ /g'
}
changelog ()
{
DATE=`date -R`
echo "${PKGNAME} (${VER}) unstable; urgency=low"
echo
echo " * This package was generated by a computer progam which"
echo " does not keep track of historical data."
echo
echo " -- ${MAINTAINER} ${DATE}"
}
copyright ()
{
echo This package contains a list of the debian software that
echo was on ${BOX} on ${DATE}.
echo
echo You are welcome to call an army of lawyers and philosphers
echo to decide on the exact copyright status and/or ownership
echo of this package. If I had to guess, this package is just
echo a collection of facts and therefore public domain.
echo
echo This package in no way affects the copyright status of
echo its dependencies.
}
rules ()
{
echo "#!/usr/bin/make -f"
echo ""
echo "configure: configure-stamp"
echo "configure-stamp:"
echo " dh_testdir"
echo " touch configure-stamp"
echo ""
echo "build: configure-stamp build-stamp"
echo "build-stamp:"
echo " dh_testdir"
echo " touch build-stamp"
echo ""
echo "clean:"
echo " dh_testdir"
echo " dh_testroot"
echo " rm -f build-stamp configure-stamp"
echo " dh_clean"
echo ""
echo "install: build"
echo " dh_testdir"
echo " dh_testroot"
echo " dh_clean -k"
echo " dh_installdirs"
echo ""
echo "binary-arch:"
echo ""
echo "binary-indep: build install"
echo " dh_testdir -i"
echo " dh_testroot -i"
echo " dh_installdocs -i"
echo " dh_installchangelogs -i"
echo " dh_link -i"
echo " dh_compress -i"
echo " dh_fixperms -i"
echo " dh_installdeb -i"
echo " dh_shlibdeps -i"
echo " dh_gencontrol -i"
echo " dh_md5sums -i"
echo " dh_builddeb -i"
echo ""
echo "binary: binary-indep"
echo ".PHONY: build clean binary-indep binary install configure"
echo ""
}
build_package()
{
mkdir -p ${PKGDIR}/debian
control > ${PKGDIR}/debian/control
control
changelog > ${PKGDIR}/debian/changelog
copyright > ${PKGDIR}/debian/copyright
rules > ${PKGDIR}/debian/rules
echo 4 > ${PKGDIR}/debian/compat
chmod +x ${PKGDIR}/debian/rules
cd ${PKGDIR}
debuild -us -uc
if [ "$?" != 0 ]
then
echo "Aborting due to error."
exit
fi
cd -
}
#######################################
# #
# Apt-get publication functions #
# #
#######################################
serve ()
{
mkdir -p ${DISTDIR}
mkdir -p ${SRCDIR}
mkdir -p ${POOLDIR}
mv ${DEB} ${POOLDIR}
mv ${PKGNAME}_${VER}.dsc ${POOLDIR}
mv ${PKGNAME}_${VER}.tar.gz ${POOLDIR}
mv ${PKGNAME}_${VER}_${ARCH}.changes ${POOLDIR}
dpkg-scanpackages pool /dev/null | gzip -9c > ${DISTDIR}/Packages.gz
dpkg-scansources pool /dev/null | gzip -9c > ${SRCDIR}/Sources.gz
}
instructions ()
{
echo
echo " =============== SUCCESS ==================="
echo
echo "First, read the man page for security implications. If you wish to share"
echo "your software collection, copy the newly created dists and pool directories "
echo "to a web accessable location. Others may then replicate your software"
echo "collection by adding the following line to their /etc/apt/sources.list:"
echo
echo " deb http://<WEB LOCATION> ${DISTRO} contrib"
echo
echo "For example, if you are running a webserver on this machine you could "
echo "copy the directories to /var/www/dists and /var/www/pool. Then people could "
echo "access it via the following line in /etc/apt/sources.list:"
echo
echo " deb http://${BOX} ${DISTRO} contrib"
echo
echo "Your followers can then use their favorite apt front end, for example:"
echo
echo " apt-get update && apt-get install ${PKGNAME}"
echo
}
#######################################
# #
# ACTION #
# #
#######################################
set_bang_maintainer
parse_command_line $@
sanity_check
build_package
serve
clean
instructions
|