Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4118590
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:58:48+00:00 2026-05-20T22:58:48+00:00

I want to prevent an older Debian package from stomping over a newer installed

  • 0

I want to prevent an older Debian package from stomping over a newer installed version of the Debian package.

I’m trying to do this by comparing the current Debian package version to what is currently installed in the debian/preinst maintenance script. Ideally, I’d like to provide a warning, and a (continue y/n?) prompt.

This question is closely related to How to get the newly-installed version within a Debian postinst script?. That issue was created in ’09 so I’m not sure if it’s appropriate to add my question in that question or not.

The response to the older questions was, “Why can’t you simply hard-code the version in your package?”

My response would be that I don’t want to manage the version in yet another location. The version is already in the debian/changelog and the Python module’s init.py script as version. This logic also needs to be replicated to several other internal Debian packages we’re maintaining. Ideally, I’d like to make this as simple as possible by removing steps from the process of building a Debian package.

I’ve read the relevant Debian docs http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html and while I can get the old-version there is no way to get the version I’m currently installing.

I echoed the env within debian/preinst and it does provide an environment variable that contains the version …: SUDO_COMMAND=/usr/bin/dpkg -i python-mypkg_1.9.3-2_all.deb. I should be able to get the version this way, but I’m not sure if I can rely on this variable to exist in every distribution this package will be deployed to. It also seems like a hack to do it this way.

I’m aware of dpkg-parsechangelog, which is a great tool!, but it only works when the package is unpacked. It clearly states this in the docs as well.

I’ve also tried using the Python pckg_resources module to discover the version with: pckg_resources.require(“mypkg”)[0].version. If the module is not yet installed on the target machine it will fail — which makes absolute sense.

It seems like there should be an option either in the debian/control file or some tool I can use to prevent this from happening without re-inventing the wheel. Thanks all!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:58:49+00:00Added an answer on May 20, 2026 at 10:58 pm

    I’m going to use SUDO_COMMAND. This will at least make it so I don’t have to hard-code the version into the preinst maintenance script (It already exists in two other locations!!). It’s an extreme hack, but I haven’t been able to find any useful documentation that might direct me to a more sensible approach.

    FYI, the env variable, SUDO_COMMAND, seems to exists in every Debian environment I’ve used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to prevent my asp.net / c# 2008 web pages from being cached
I want to prevent users from commenting on deleted threads. I've set a variable
I want to prevent iframe elements from triggering the OnDocumentComplete event every time. For
What solutions do I have if I want to prevent the UI from freezing
I've got a WinCE device powered over ethernet (PoE) and I want to prevent
I have an HTML textarea element. I want to prevent a user from entering
I have an input box that takes values from 0-100. I want to prevent
I want to prevent users from accessing my robots.txt file but I still want
I have an older form that I really don't want to rewrite at this
I want to block hardware back button in android ,in order to prevent from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.