LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-22-2021, 12:07 PM   #1
Weber Kai
Member
 
Registered: Jun 2009
Location: Brasília, Brazil
Distribution: Slackware64 14.2
Posts: 38

Rep: Reputation: 24
Sharing the changes I did in doinst.sh in glibc-zoneinfo


Hi!

I am creating an ARM filesystem but some packages don't install correctly with "installpkg --root newroot".

In those packages there are 2 problem in the script install/doinst.sh:
1) Some of them are using relative binaries (in my case they are for another architecture);
2) Some of them are using absolute paths for config files messing newroot the OS files.

I've decided to fix all packages I can and to share what I did. So the devs can look at it and merge in the source tree if they wanted.

The first one is glibc-zoneinfo.

I've got the latest source at https://mirror.slackbuilds.org/slack...o/doinst.sh.gz

Current code is:

Code:
# Note on configuration change (2020-12-09):
# For the past decade and a half, this package has created a symlink
# /etc/localtime-copied-from and a file /etc/localtime to prevent
# time skew until /usr is mounted. But having a separate /usr partition
# hasn't really made sense for a long time and leads to all kinds of
# bugs these days. We're going to make /etc/localtime a symlink just
# like everyone else does so that programs that expect it to be a link
# can fetch the timezone without requiring any special patches.
# If you insist on making /usr a separate partition, you might want to
# put the pointed-to directories and timezone file in your empty /usr
# directory so that it is available before the real /usr is mounted.
# Still not recommended though.

# In a special case, we will handle the removal of the US/Pacific-New
# timezone. A bit of background information on this:
#
# "US/Pacific-New' stands for 'Pacific Presidential Election Time',
# which was passed by the House in April 1989 but never signed into law.
# In presidential election years, this rule would have delayed the
# PDT-to-PST switchover until after the election, to lessen the effect
# of broadcast news election projections on last-minute west-coast
# voters. "
#
# In nearly all cases, a machine that uses the US/Pacific-New timezone
# has chosen it by mistake. In 2016, having this as the system timezone
# actually led to clock errors, and after that it was decided that the
# timezone (only of historical interest anyway) should be removed from
# the timezone database.
#
# If we see that the machine's localtime-copied-from symlink is pointing
# to US/Pacific-New, change it to point to US/Pacific instead.
if [ "$(/bin/ls -l etc/localtime-copied-from 2> /dev/null | rev | cut -f 1,2 -d / | rev)" = "US/Pacific-New" ]; then
  ( cd etc ; rm -rf localtime-copied-from )
  ( cd etc ; ln -sf /usr/share/zoneinfo/US/Pacific localtime-copied-from )
fi
# Same with any /etc/localtime symlink:
if [ -L etc/localtime ]; then
  if [ "$(/bin/ls -l etc/localtime 2> /dev/null | rev | cut -f 1,2 -d / | rev)" = "US/Pacific-New" ]; then
    ( cd etc ; rm -rf localtime )
    ( cd etc ; ln -sf /usr/share/zoneinfo/US/Pacific localtime )
  fi
fi

# If we already have a localtime-copied-from symlink, move it over as the
# /etc/localtime symlink:
if [ -L etc/localtime-copied-from ]; then
  rm -f etc/localtime
  mv etc/localtime-copied-from etc/localtime
fi

# Add the default timezone in /etc, if none exists:
if [ ! -r etc/localtime ]; then
  ( cd etc ; rm -rf localtime localtime-copied-from )
  ( cd etc ; ln -sf /usr/share/zoneinfo/Factory localtime-copied-from )
fi

# Add a link to the timeconfig script in /usr/share/zoneinfo:
( cd usr/share/zoneinfo ; rm -rf timeconfig )
( cd usr/share/zoneinfo ; ln -sf /usr/sbin/timeconfig timeconfig )
### Make the rest of the symbolic links in the zoneinfo database:
The changed code is:

Code:
# Note on configuration change (2020-12-09):
# For the past decade and a half, this package has created a symlink
# /etc/localtime-copied-from and a file /etc/localtime to prevent
# time skew until /usr is mounted. But having a separate /usr partition
# hasn't really made sense for a long time and leads to all kinds of
# bugs these days. We're going to make /etc/localtime a symlink just
# like everyone else does so that programs that expect it to be a link
# can fetch the timezone without requiring any special patches.
# If you insist on making /usr a separate partition, you might want to
# put the pointed-to directories and timezone file in your empty /usr
# directory so that it is available before the real /usr is mounted.
# Still not recommended though.

# In a special case, we will handle the removal of the US/Pacific-New
# timezone. A bit of background information on this:
#
# "US/Pacific-New' stands for 'Pacific Presidential Election Time',
# which was passed by the House in April 1989 but never signed into law.
# In presidential election years, this rule would have delayed the
# PDT-to-PST switchover until after the election, to lessen the effect
# of broadcast news election projections on last-minute west-coast
# voters. "
#
# In nearly all cases, a machine that uses the US/Pacific-New timezone
# has chosen it by mistake. In 2016, having this as the system timezone
# actually led to clock errors, and after that it was decided that the
# timezone (only of historical interest anyway) should be removed from
# the timezone database.
#
# If we see that the machine's localtime-copied-from symlink is pointing
# to US/Pacific-New, change it to point to US/Pacific instead.
if [ "$(/bin/ls -l etc/localtime-copied-from 2> /dev/null | rev | cut -f 1,2 -d / | rev)" = "US/Pacific-New" ]; then
  ( rm -rf etc/localtime-copied-from )
  ( ln -sf usr/share/zoneinfo/US/Pacific etc/localtime-copied-from )
fi
# Same with any /etc/localtime symlink:
if [ -L etc/localtime ]; then
  if [ "$(/bin/ls -l etc/localtime 2> /dev/null | rev | cut -f 1,2 -d / | rev)" = "US/Pacific-New" ]; then
    ( rm -rf etc/localtime )
    ( ln -sf usr/share/zoneinfo/US/Pacific etc/localtime )
  fi
fi

# Add the default timezone in /etc, if none exists:
if [ ! -r etc/etc/localtime-copied-from ]; then
  ( rm -rf etc/localtime-copied-from )
  ( ln -sf usr/share/zoneinfo/Factory etc/localtime-copied-from )
fi

# If we already have a localtime-copied-from symlink, copy as the
# /etc/localtime symlink:
if [ -L etc/localtime-copied-from ]; then
  rm -f etc/localtime
  cp -P etc/localtime-copied-from etc/localtime
fi

# Add a link to the timeconfig script in /usr/share/zoneinfo:
( rm -rf usr/share/zoneinfo/timeconfig )
( ln -sf usr/sbin/timeconfig usr/share/zoneinfo/timeconfig )
### Make the rest of the symbolic links in the zoneinfo database:
( rm -rf usr/share/zoneinfo/localtime )
( ln -sf etc/localtime usr/share/zoneinfo/localtime )
With this script the package installed correctly to my ARM jail.

Thanks!
 
Old 08-22-2021, 07:34 PM   #2
babydr
Member
 
Registered: Aug 2015
Location: Fairbanks , Alaska
Distribution: Slackware-14.2 & 15.0
Posts: 231

Rep: Reputation: 45
@"Weber Kai" , Would you please post a "diff -u" of your changes as a third display ? Tia , JimL
 
Old 08-23-2021, 10:30 PM   #3
Weber Kai
Member
 
Registered: Jun 2009
Location: Brasília, Brazil
Distribution: Slackware64 14.2
Posts: 38

Original Poster
Rep: Reputation: 24
Hi!

I've changed it a little bit, to keep the doinst.sh style.

Code:
--- doinst.sh.ori	2021-08-24 00:27:12.416536979 -0300
+++ doinst.sh.new	2021-08-24 00:27:08.608482793 -0300
@@ -31,30 +31,32 @@
 # to US/Pacific-New, change it to point to US/Pacific instead.
 if [ "$(/bin/ls -l etc/localtime-copied-from 2> /dev/null | rev | cut -f 1,2 -d / | rev)" = "US/Pacific-New" ]; then
   ( cd etc ; rm -rf localtime-copied-from )
-  ( cd etc ; ln -sf /usr/share/zoneinfo/US/Pacific localtime-copied-from )
+  ( cd etc ; ln -sf ../usr/share/zoneinfo/US/Pacific localtime-copied-from )
 fi
 # Same with any /etc/localtime symlink:
 if [ -L etc/localtime ]; then
   if [ "$(/bin/ls -l etc/localtime 2> /dev/null | rev | cut -f 1,2 -d / | rev)" = "US/Pacific-New" ]; then
     ( cd etc ; rm -rf localtime )
-    ( cd etc ; ln -sf /usr/share/zoneinfo/US/Pacific localtime )
+    ( cd etc ; ln -sf ../usr/share/zoneinfo/US/Pacific localtime )
   fi
 fi
 
-# If we already have a localtime-copied-from symlink, move it over as the
-# /etc/localtime symlink:
-if [ -L etc/localtime-copied-from ]; then
-  rm -f etc/localtime
-  mv etc/localtime-copied-from etc/localtime
+# Add the default timezone in /etc, if none exists:
+if [ ! -r etc/etc/localtime-copied-from ]; then
+  ( cd etc ; rm -rf localtime-copied-from )
+  ( cd etc ; ln -sf ../usr/share/zoneinfo/Factory localtime-copied-from )
 fi
 
-# Add the default timezone in /etc, if none exists:
-if [ ! -r etc/localtime ]; then
-  ( cd etc ; rm -rf localtime localtime-copied-from )
-  ( cd etc ; ln -sf /usr/share/zoneinfo/Factory localtime-copied-from )
+# If we already have a localtime-copied-from symlink, copy as the
+# /etc/localtime symlink:
+if [ -L etc/localtime-copied-from ]; then
+  ( cd etc ; rm -f localtime )
+  ( cd etc ; cp -P localtime-copied-from localtime )
 fi
 
 # Add a link to the timeconfig script in /usr/share/zoneinfo:
 ( cd usr/share/zoneinfo ; rm -rf timeconfig )
-( cd usr/share/zoneinfo ; ln -sf /usr/sbin/timeconfig timeconfig )
+( cd usr/share/zoneinfo ; ln -sf ../../../usr/sbin/timeconfig timeconfig )
 ### Make the rest of the symbolic links in the zoneinfo database:
+( cd usr/share/zoneinfo ; rm -rf localtime )
+( cd usr/share/zoneinfo ; ln -sf ../../../etc/localtime localtime )
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
glibc-zoneinfo-2018e upgrade missing file "etc/localtime-copied-from" Slackware 14.2 kingbeowulf Slackware 2 05-13-2018 12:36 AM
Upgrading glibc-zoneinfo in slackware64-current botched /etc/localtime vaston Slackware 7 01-29-2018 06:33 AM
[PATCH 1+2+3/3] glibc-zoneinfo.SlackBuild Xsane Slackware 0 12-22-2015 01:49 AM
ldconfig: command not found upon sudo upgradepkg of glibc-zoneinfo thirdm Slackware 4 10-29-2014 11:20 AM
slackware glibc-zoneinfo-multilib-noarch update: why blacklisted/special? kingbeowulf Slackware 2 11-12-2011 05:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration