1 | # $Id:$
|
---|
2 | # functions for recording installation of a package and make a tarball,
|
---|
3 | # or using fakeroot type commands for install, then packing and installing
|
---|
4 | # the package.
|
---|
5 | # We only have access to variables PKGDIR and PKG_DEST. Other variables could
|
---|
6 | # be set in the environment
|
---|
7 |
|
---|
8 | extract_version() {
|
---|
9 | local VERSION
|
---|
10 |
|
---|
11 | case $1 in
|
---|
12 | expect*|tcl*|tk*|mozjs*)
|
---|
13 | VERSION=$(echo $1 | sed 's/^[^0-9]*//')
|
---|
14 | ;;
|
---|
15 | vim*|unzip*|zip*)
|
---|
16 | VERSION=$(echo $1 | sed 's/^[^0-9]*\([0-9]\)\([0-9]\)/\1.\2/')
|
---|
17 | ;;
|
---|
18 | wireless_tools*|LVM2*)
|
---|
19 | VERSION=$(echo $1 | sed 's/^[^.]*\.//')
|
---|
20 | ;;
|
---|
21 | x264*)
|
---|
22 | VERSION=$(echo $1 | sed 's/.*shot-//')
|
---|
23 | ;;
|
---|
24 | icu*) # No version in PCKGVRS! Use version directly from xml book.
|
---|
25 | # PACK_INSTALL contains the path to this script, which is in the
|
---|
26 | # parent dir of the book.
|
---|
27 | local PACKENT=$(dirname $PACK_INSTALL)/blfs-xml/packages.ent
|
---|
28 | local VERSION1=$(sed -n 's/.*icu-major[^0-9]*\([^"]*\).*/\1/p' $PACKENT)
|
---|
29 | local VERSION2=$(sed -n 's/.*icu-minor[^0-9]*\([^"]*\).*/\1/p' $PACKENT)
|
---|
30 | VERSION=$VERSION1.$VERSION2
|
---|
31 | ;;
|
---|
32 | exiv*)
|
---|
33 | local PACKENT=$(dirname $PACK_INSTALL)/blfs-xml/packages.ent
|
---|
34 | VERSION=$(sed -n 's/.*exiv2[^0-9]*\([^"]*\).*/\1/p' $PACKENT)
|
---|
35 | ;;
|
---|
36 | flashplayer*)
|
---|
37 | local PACKENT=$(dirname $PACK_INSTALL)/blfs-xml/packages.ent
|
---|
38 | VERSION=$(sed -n 's/.*flashplayer[^0-9]*\([^"]*\).*/\1/p' $PACKENT)
|
---|
39 | ;;
|
---|
40 | soundtouch*)
|
---|
41 | local PACKENT=$(dirname $PACK_INSTALL)/blfs-xml/packages.ent
|
---|
42 | VERSION=$(sed -n 's/.*soundtouch[^0-9]*\([^"]*\).*/\1/p' $PACKENT)
|
---|
43 | ;;
|
---|
44 | xvid*)
|
---|
45 | local PACKENT=$(dirname $PACK_INSTALL)/blfs-xml/packages.ent
|
---|
46 | VERSION=$(sed -n 's/.*xvid[^0-9]*\([^"]*\).*/\1/p' $PACKENT)
|
---|
47 | ;;
|
---|
48 | xf86-video-intel)
|
---|
49 | local PACKENT=$(dirname $PACK_INSTALL)/blfs-xml/x/installing/x7driver-intel.xml
|
---|
50 | VERSION=$(sed -n '/<!--/!s/.*-version[^;][^0-9]*\([^"]*\).*/\1/p' $PACKENT)
|
---|
51 | ;;
|
---|
52 | jdk8*)
|
---|
53 | VERSION=1.8.0.$(echo $1 | sed 's/.*u\([0-9]\+\).*/\1/')
|
---|
54 | ;;
|
---|
55 | docbook-xml)
|
---|
56 | VERSION=4.5
|
---|
57 | ;;
|
---|
58 | cacerts*)
|
---|
59 | VERSION=0.1
|
---|
60 | ;;
|
---|
61 | btrfs*|node*|x265*)
|
---|
62 | VERSION=$(echo $1 | sed 's/^.*v//')
|
---|
63 | ;;
|
---|
64 | *)
|
---|
65 | VERSION=$(echo $1 | sed 's/^.*[-_]\([0-9]\)/\1/' | sed 's/_/./g')
|
---|
66 | ;;
|
---|
67 | # the last sed above is because some package managers do not want a '_'
|
---|
68 | # in version.
|
---|
69 | esac
|
---|
70 | echo ${VERSION,,} # convert to lowercase, in case there is a capital letter
|
---|
71 | # in version
|
---|
72 | }
|
---|
73 |
|
---|
74 | # Export the previous function, since it is used by the others
|
---|
75 | export -f extract_version
|
---|
76 | # The other "official" functions, wrapInstall and packInstall, are exported
|
---|
77 | # by "envars" (in LFS), and the scripts (in BLFS).
|
---|
78 |
|
---|
79 | wrapInstall() {
|
---|
80 | # a bash command is passed as an argument (that may be a compound command).
|
---|
81 | # It is executed by this function, after various set-ups...
|
---|
82 |
|
---|
83 | # Note that PKGDIR is changed to UNPACKDIR
|
---|
84 | # and PKG_DEST is changed to PKG_DIR in BLFS tools.
|
---|
85 | # The sed for PACKAGE is therefore not needed in BLFS,
|
---|
86 | # but it does not hurt, either.
|
---|
87 | local PCKGVRS=$(basename $PKGDIR)
|
---|
88 | local TGTPKG=$(basename $PKG_DEST)
|
---|
89 | local PACKAGE=$(echo ${TGTPKG} | sed 's/^[0-9]\{3\}-//' |
|
---|
90 | sed 's/^[0-9]\{1\}-//')
|
---|
91 | # Porg converts package names to lowercase anyway, so do the conversion
|
---|
92 | # ourselves
|
---|
93 | PACKAGE=${PACKAGE,,}
|
---|
94 | # version is only accessible from PKGDIR name. Since the format of the
|
---|
95 | # name is not normalized, several hacks are necessary (now in function
|
---|
96 | # extract_version)...
|
---|
97 | VERSION=$(extract_version $PCKGVRS)
|
---|
98 | porg -lp ${PACKAGE}-${VERSION} sh << PORG_EOF
|
---|
99 | $*
|
---|
100 | PORG_EOF
|
---|
101 | }
|
---|
102 |
|
---|
103 | #----------------
|
---|
104 | packInstall() {
|
---|
105 |
|
---|
106 | # With porg, we need only the package name to make the tarball
|
---|
107 | local TGTPKG=$(basename $PKG_DEST)
|
---|
108 | local PACKAGE=$(echo ${TGTPKG} | sed 's/^[0-9]\{3\}-//' |
|
---|
109 | sed 's/^[0-9]\{1\}-//')
|
---|
110 | local PCKGVRS=$(basename $PKGDIR)
|
---|
111 | # Porg converts package names to lowercase anyway, so do the conversion
|
---|
112 | # ourselves
|
---|
113 | PACKAGE=${PACKAGE,,}
|
---|
114 | # Building the binary package
|
---|
115 | porgball ${PACKAGE}
|
---|
116 | # The package is in the current directory
|
---|
117 | VERSION=$(extract_version $PCKGVRS)
|
---|
118 | mv -v ${PACKAGE}-${VERSION}.porg* /var/lib/packages
|
---|
119 | }
|
---|