2

I would like to create an easily installable debian package (.deb file) for MediaWiki 1.25.1 as I know from personal experience that for web programming noobs like myself, installing MediaWiki can seem like an impossible task.

I have read some guides on how to create debian packages, like this one for Ubuntu users and this one on Debian Wiki, but correct me if I'm wrong but they only seem to mention packages that are installed via the make utility, while MediaWiki, being a Wiki application is installed (if you could even call it an installation) by creating an Apache & MySQL server database for the Wiki and running the setup scripts. But I know such a debian package can be made as there exists a really old version of MediaWiki in the PPA repositories (1.19) and it is a debian package.

I know the basic procedure of what any such package would need to do, namely (you should note that I'm getting much of this from my own memory plus this article at mediwiki.org):

  • Install LAMP, or at a bare minimum install the packages apache2, mysql-server, php5, php5-mysql and libapache2-mod-php5. Possibly via sudo apt-get install apache2 mysql-server php5 php5-mysql libapache2-mod-php5.
  • Install some additional packages (strictly speaking they're optional, but they're incredibly helpful, especially if you're new to MediaWiki) such as imagemagick, inkscape, php5-cli and phpmyadmin, also via sudo apt-get install... It would be grand if an GUI could pop up during installation and prompt users as to which of these optional packages should be installed. Such an interface could also go through the process of setting a MySQL password)
  • Extract the tarball of MediaWiki 1.25.1 into /var/lib/mediawiki
  • Create a virtual link between /var/lib/mediawiki and /var/www/html/mediawiki (by running sudo ln -s /var/lib/mediawiki /var/www/html/mediawiki)
  • Run mysql_secure_installation
  • Configure PHP (optional to the user) and restart Apache after.
  • Configure Apache (more details on the mediawiki.org article I hyperlinked)
  • Open browser to http://localhost/mediawiki to complete MediaWiki configuration.

I just don't know how to create a debian package that would do this. So all in all I would like someone's help so I may do this, so that MediaWiki installation on Ubuntu may be made that little bit easier for future users.

My attempt at creating a package myself

I created a directory, /home/fusion809/Debian packaging/bzr so I can try following this guide on the mediawiki-1.25.1.tar.gz tarball. I got down to here in the guide and the debian package I created (by running the bzr builddeb... command in my /home/fusion809/Debian packaging/bzr/mediawiki/debian directory) was only 2.4 kB in size (where the tarball is 23.7 MB) and gave the error message:

install-info: warning: no info dir entry in `/usr/share/info/lilypond/pictures/ross-beam-scan.jpg'
install-info: warning: no info dir entry in `/usr/share/info/lilypond/pictures/carter-brey.jpg'
install-info: warning: no info dir entry in `/usr/share/info/lilypond/pictures/darius-blasband.jpg'
install-info: warning: no info dir entry in `/usr/share/info/lilypond/pictures/orm-finnendahl.jpg'
install-info: warning: no info dir entry in `/usr/share/info/mime.info.gz'

when I tried to install it. If you're wondering what my control file looks like, here it is:

Source: mediawiki
Section: unknown
Priority: optional
Maintainer: Brenton Horne <brentonhorne77@gmail.com>
Build-Depends: debhelper (>= 9)
Standards-Version: 3.9.5
Homepage: <insert the upstream URL, if relevant>
#Vcs-Git: git://anonscm.debian.org/collab-maint/mediawiki.git
#Vcs-Browser: http://anonscm.debian.org/?p=collab-maint/mediawiki.git;a=summary

Package: mediawiki
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: MediaWiki, a free wiki application.
  MediaWiki is a free and open-source wiki application written in PHP that is maintained by the Wikimedia Foundation. It depends on
  Apache, MySQL and PHP.

my rules file looks like:

#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


# main packaging script based on dh7 syntax
%:
    dh $@ 

# debmake generated override targets
# This is example for Cmake (See http://bugs.debian.org/641051 )
#override_dh_auto_configure:
#   dh_auto_configure -- \
#   -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
Josh Pinto
  • 7,769
  • 22
  • 80
  • 128
  • I think this is a good question, and I've wondered some of this myself, but the title isn't the best. It makes the question sound like you're asking for opinions. All that aside, have you considered opening the MediaWiki .deb file in the archive manager and taking a look inside? – Seth May 28 '15 at 18:38
  • Whoever has made this downvote please tell me how I can rephrase or even change this question so that it doesn't cause your displeasure? Should I ask instead how to create a debian package that installs and configures a web server, so as to make it generalizable to other web applications like MoinMoin or WordPress? – Josh Pinto May 28 '15 at 18:38
  • @Seth. I wrote this question title this way as when I wrote "How do I..." in the title it suggested it would likely be marked as subjective and closed, rofl. No I haven't I'm afraid. You wouldn't have a URL I can download the package from without having to install it myself? – Josh Pinto May 28 '15 at 18:39
  • I'm not sure what version of Ubuntu you are running but on Vivid I just ran `apt-get download mediawiki`. Then right click -> open with -> Archive Manager. – Seth May 28 '15 at 18:41
  • Note that you can download the source tarball (with all of the `debian/*` files) from the PPA, and base your package off of that. – saiarcot895 May 28 '15 at 18:43
  • OK, I have the extracted files now but it's hard to know what to update for 1.25.1 and what not to... Any ideas? – Josh Pinto May 28 '15 at 18:51
  • @BrentonHorne: What I do is look for version-specific stuff (for example: it explicitly says 1.18 or something) and update or remove those (whichever is appropriate). Then, update `debian/changelog` for 1.25.1, update the source tarball, and see if it works. See also my answer below for starting from scratch. – saiarcot895 May 28 '15 at 18:53
  • @BrentonHorne: You do mean `control`, not `compat`, right? What does your `rules` file look like? Also, since the package is the same for all architectures, change `Architecture: any` to `Architecture: all`. – saiarcot895 May 29 '15 at 02:38
  • Details have been added to my question. It was control not compat. – Josh Pinto May 29 '15 at 11:06
  • You could try asking this on the [mediawiki-distributors](https://lists.wikimedia.org/mailman/listinfo/mediawiki-distributors) mailing list. – Tgr May 31 '15 at 09:17
  • Are you still working on this? Asking mediawiki-distributors, or specifically User:Platonides, would be a good idea. – Nemo Oct 13 '15 at 12:06

2 Answers2

0

Packages in Debian/Ubuntu don't have to be built using make. Technically, in debian/rules, there are just certain targets that have to be met. The following is what I (and Debian's Flightgear group) use to copy files from an arch-independent tarball (no compiling involved, just copying files) into the package.

%:
    dh $@

override_dh_auto_install:
    dh_installdirs -pflightgear-data-aircrafts-ec130 usr/share/games/flightgear/Aircraft/ec130

    find -maxdepth 1 ! -name 'debian' -exec cp -r "{}" \
       debian/flightgear-data-aircrafts-ec130/usr/share/games/flightgear/Aircraft/ec130 \;

# Fix some insane permissions
    find $(CURDIR)/debian/flightgear-data-*/usr/share/games/flightgear \
        -type f -exec chmod 644 {} \;

# Drop some silly Windows PE32 executable files
    find $(CURDIR)/debian -type f -iname "*.mdl" -delete

# Drop empty directories
    find $(CURDIR)/debian -type d -empty -delete

Basically, override_dh_auto_install just copies files form the source tarball into the final package, and removes some unneeded files. Because there is no "compiling" file in the source tarball, some of the other targets do nothing.

You can follow something like this (along with using the postinst and prerm scripts) to automate the steps you've mentioned. Note that the installation of additional packages would go into debian/control, either as Depends, Recommends, or Suggests.

saiarcot895
  • 10,727
  • 2
  • 35
  • 39
  • I'm having some trouble deciphering what you've said, you clearly know your stuff, I just don't, rofl. Um, so what you're saying is use your script on the mediawiki-1.25.1.tar.gz archive from which I installed MW 1.25.1 and it should package everything in a .deb file format? – Josh Pinto May 28 '15 at 18:55
  • That's just an example, to show that you don't have to use `make` and compile something. In your case, you might have something like `cp -r $(CURDIR) debian/mediawiki/var/lib/mediawiki/` to copy all the files in the source directory into `/var/lib/mediawiki` of the final package. (Note that `$(CURDIR)`is specially defined to be the current directory.) – saiarcot895 May 28 '15 at 18:58
  • OK, I have a suspicion that I may have to talk to ya more than that encouraged in comments in order to understand what I need to do. I know there's some chat utility here at SE although I'm not sure how to enter it, so if you don't mind answering some more questions for me could you send me a link or w/e to enter chat, please? – Josh Pinto May 28 '15 at 19:05
  • There's a way to make a question-specific chat, but I'm not sure how to. – saiarcot895 May 28 '15 at 19:16
  • From what I can gather of this deb file's structure it sort of looks like how my mediawiki installation looks. It has a `/usr/share/mediawiki` directory that looks like my `/var/lib/mediawiki` folder, with the changes probably accounted for by the fact it's an older version. In its `/var/lib/mediawiki` directory some files that I'm gathering are the bare minimum needed there are there (i.e., some of the files that are also in my `/var/lib/mediawiki` directory) but most of them are virtual-linked to the like-named folders/files in `/usr/share/mediawiki`. Is that the way deb files usually are? – Josh Pinto May 28 '15 at 20:59
  • By the way I'd recommend reading my question again as I added some details of my attempt at building this deb file. – Josh Pinto May 28 '15 at 22:34
0

I'd recommend using uupdate from devscripts to get good start for your deb package.

Install required packages

$ sudo apt-get install build-essential devscripts

Download the the old package from official repository and the new tar-ball from upstream. (I'm using 14.04)

$ mkdir ~/Downloads/mediawiki
$ cd ~/Downloads/mediawiki
$ apt-get source mediawiki
$ wget http://releases.wikimedia.org/mediawiki/1.25/mediawiki-1.25.1.tar.gz

Run uupdate to create a new source folder from the upstream tar-ball and the old debian/control

$ cd mediawiki-1.19.14+dfsg   # depends on your Ubuntu version
$ uupdate ../mediawiki-1.25.1.tar.gz 1.25.1
$ cd ../mediawiki-1.25.1

Now you should check if you need to make changes to debian/control etc files. If you're done you can build the deb package and install it

$ dpkg-buildpackage -us -uc
$ cd ..
$ sudo dpkg -i *.deb
Germar
  • 6,217
  • 2
  • 24
  • 39
  • dpkg-buildpackage -us -uc is giving the error shown here http://i.imgur.com/e4SEUf6.png. – Josh Pinto May 29 '15 at 01:06
  • Like I said you need to adjust the files in `debian` for 1.25.1. This includes checking which patches in `debian/patches` are already merged upstream or maybe need some changes before applying them. – Germar May 30 '15 at 00:20